On Nov 11, 2005, at 11:08 AM, Watson Gary (Mr GA) wrote:
While I think it is fine for Xerces to sort attributes alphabetically, for 
fast attribute access times, it does have one or two side 
effects. For example, if you load up an XML document in DOM and 
simply write it back out, a "diff" of the input and output files will 
show the file to have changed because the attributes have 
been re-ordered


However, attribute order is only one of syntax difference that can get lost when an stream is parsed:  Line-feeds are normalized, white-space within tags are dropped, whether matching quotes or apostrophes are used in to enclose attribute values, and others.  If you were going to be able to diff an arbitrary XML file after parsing and serialization, you'd need to preserve a lot more than just attribute order or be lucky, for example, that your serializer used the same character to enclose attribute values.

If you are interested in the issue: take a look at the Canonical XML recommendation (http://www.w3.org/TR/2001/REC-xml-c14n-20010315) which describes a method for serializing an XML document so that logically equivalent documents result in a consistent stream representation.

p.s.: IANAXC (I am not a Xerces committer).



Reply via email to