Reputation: 147
Can anyone suggest a command line xml differencing tool for Solaris? I want to call one in a regression test script, so it's important that the tool can be called from the command line and return a status to indicate whether the files contain any differences.
The tool must have an option to ignore attribute order.
Thanks, Dave
Upvotes: 1
Views: 788
Reputation: 46518
You can try diffxml. Attribute order is ignored (as per the XML spec).
Upvotes: 0
Reputation: 38063
I had this problem and ended up writing my own because I needed to know what the difference was[1]. If you can manage with simply knowing whether the expected and actual XML are identical the simplest thing is to canonicalize the XML into a string and diff the strings.
Canonicalization is part of the XML toolkits spec and produces a string which is independent of attribute order, type of quoting, normalization of CDATA, etc.
All good XML parsers should have this. I use XOM (http://www.xom.nu) (Java) which has a canonicalizer and is simple to use.
[1] My XML contained representations of real numbers which might differ slightly due to rounding errors. Simple lexical comparison does not work (x="1.99999994" and x="2" are not lexically identical but may be equal within a given epsilon).
Upvotes: 2