diff attribute for matched node
vaibhgupta157 opened this issue · comments
Hi xmldiff community,
I am using this library in my project. I got following requirement with my use-case.
I have two xmls:
XML1:
<config>
<commands>
<cmd>test1</cmd>
<cmd>test2</cmd>
<cmd>test3</cmd>
</commands>
</config>
XML2:
<config>
<commands>
<cmd>test1</cmd>
<cmd>test4</cmd>
<cmd>adfdf</cmd>
</commands>
</config>
When I do:
formatter = formatting.XMLFormatter(normalize=formatting.WS_BOTH)
print (main.diff_texts(XML1, XML2, formatter=formatter, diff_options={'F': 1.0}))
Output:
<config xmlns:diff="http://namespaces.shoobx.com/diff">
<commands diff:insert="">
<cmd diff:insert="">test1</cmd>
<cmd diff:insert="">test4</cmd>
<cmd diff:insert="">adfdf</cmd>
</commands>
<commands diff:delete="">
<cmd diff:delete="">test1</cmd>
<cmd diff:delete="">test2</cmd>
<cmd diff:delete="">test3</cmd>
</commands>
</config>
Why in the output it is inserting and deleting node with value "test1". It should not be touched as it is same in both XMLs?
And even if it is deleting it should be delete first and then insert.
My requirement is to get output in following manner:
<config xmlns:diff="http://namespaces.shoobx.com/diff">
<commands>
<cmd>test1</cmd>
<cmd diff:delete="">test2</cmd>
<cmd diff:insert="">test4</cmd>
<cmd diff:delete="">test3</cmd>
<cmd diff:insert="">adfdf</cmd>
</commands>
</config>
Is there anything I am missing
Version 2.5, which will be released shortly, will behave better in this particular case.