Find & Replace sets of value with an unique of values
-
Hi all!
in a mine XML i have to replace these lines (example):
<relationship identifier=“id-742789” source=“id-830939” target=“id-830997” xsi:type=“Composition”>
<name xml:lang=“en”></name>
</relationship>
<relationship identifier=“id-830947” source=“id-830939” target=“id-830948” xsi:type=“Composition”>
<name xml:lang=“en”></name>with this:
<relationship identifier=“id-999999” source=“id-830939” target=“id-830997” xsi:type=“Composition”>
<name xml:lang=“en”></name>
</relationship>
<relationship identifier=“id-999999” source=“id-830939” target=“id-830948” xsi:type=“Composition”>
<name xml:lang=“en”></name>and after, starting from here:
<connection identifier=“id-742788” xsi:type=“Relationship” relationshipRef=“id-742789” source=“id-742790” target=“id-742779”>
<style lineWidth=“1”>
<fillColor r=“0” g=“176” b=“80” a=“100”/>
<lineColor r=“0” g=“176” b=“80” a=“100”/>
<font name=“Sky Text” size=“10” style=“plain”>
<color r=“0” g=“0” b=“0” a=“100”/>
</font>
</style>
<sourceAttachment x=“540” y=“333”/>
<bendpoint x=“540” y=“487”/>
<targetAttachment x=“667” y=“487”/>
</connection>with:
<connection identifier=“id-742788” xsi:type=“Relationship” relationshipRef=“id-999999” source=“id-742790” target=“id-742779”>
<style lineWidth=“1”>
<fillColor r=“0” g=“176” b=“80” a=“100”/>
<lineColor r=“0” g=“176” b=“80” a=“100”/>
<font name=“Sky Text” size=“10” style=“plain”>
<color r=“0” g=“0” b=“0” a=“100”/>
</font>
</style>
<sourceAttachment x=“540” y=“333”/>
<bendpoint x=“540” y=“487”/>
<targetAttachment x=“667” y=“487”/>
</connection>How i can do that?
Best
-
Probably THIS helps you.
-
@alan-kilborn thank you, i also looked here but in twice links doesn’t modify inside a tag but only btw brackets :(
-
@luigi-giuseppe-de-franceschi said in Find & Replace sets of value with an unique of values:
i also looked here
Yes, that is better than my link.
but in twice links doesn’t modify inside a tag but only btw bracket
Not sure what that means…
In fact, now I’m unclear on what exactly you need to do, so I’ll let someone else who does understand jump in and help.
-
@alan-kilborn no problem :)
i applied a brute force approach and now i hope my xml will work:
step 1) find <relationship and replace with <relationship>FYY ( *
step 2) find source and replace with ) source *
Step 3) find (?-s)(?-i:<relationship>|(?!\A)\G).?\K(?:\x20(.+?)) with identifier=“id-999999”
Step 4) find >FYY and replace with " "
Step 5) find <connection and replace with <connection>FYY
Step 6) find relationshipRef and replace with ( relationshipRef
Step 7) find (?-s)(?-i:<connection>|(?!\A)\G).?\K(?:\x20(.+?)) and replace with relationshipRef=“id-999999”
Step 8) find >FYY and replace with " "
Step 9) find ) source and replace with sourceam i mad? :D