views:

89

answers:

1

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

+1  A: 

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 differe slightly due to rounding errors. Simple lexical comparison does not work (x="1.99999994" and x="2" are not lexical identical but may be equal within a given epsilon).

peter.murray.rust