Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
21.14k stars 346 forks source link

XML attribute ordering should not matter #758

Closed bannmann closed 2 months ago

bannmann commented 2 months ago

According to section 3.1 of the XML specification, the order of attributes does not matter:

Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

However, Difftastic 0.60.0 says it does:

$ difft --syntax-highlight off --display=inline a.xml b.xml
b.xml --- XML
1    <foo bar="1" quux="true"/>
   1 <foo quux="true" bar="1"/>

Operating system is Windows 10 with WSL (Ubuntu 22.04).

a.xml

<foo bar="1" quux="true"/>

b.xml

<foo quux="true" bar="1"/>

Background

I have frequently been in the situation of having to compare XML files that had different attribute ordering. I was hoping that Difftastic would spare me at least part of the manual "normalization" work that I then have to do. (The other parts relate to formatting, which difft makes unnecessary but is easy to do, and namespace prefix numbering, which I won't ask Difftastic authors about in the interest of their sanity.)

Wilfred commented 2 months ago

This isn't supported I'm afraid: https://github.com/wilfred/difftastic?tab=readme-ov-file#can-difftastic-ignore-reordering