I'm using jQuery to load arbitrary XML strings (fragments of a larger document) into the browser DOM and manipulate them, then using XMLSerializer to load them back to strings and send them back to the server, where they are processed (by python and lxml) and re-integrated into a full XML document.
The XML starts and ends in a git repository. I've found that the attributes on elements processed by XMLSerializer are reversed in order, resulting in spurious changes showing up in my repository, like so:
- <literal><token kind="w" id="en-us-esv-xeaugcbzgo">sent</token><token kind="s" id="en-us-esv-xeaugcbzgw"> </token></literal>
+ <literal><token id="en-us-esv-xeaugcbzgo" kind="w">sent</token><token id="en-us-esv-xeaugcbzgw" kind="s"> </token></literal>
This isn't a bug with any of the tools I'm using. Of course, the order of attributes on an xml element aren't supposed to matter. But, because git is a line-oriented SCM, these spurious and insignificant changes will distract from the actual substantive changes that I want to track.
The Question: Is there a way to keep the serializer from re-ordering my attributes? Alternately, do any tools exist to specify/constrain the ordering of attributes?
Edited above for clarity: I am aware that, according to the XML Specification, "the order of attribute specifications in a start-tag or empty-element tag is not significant": http://www.w3.org/TR/REC-xml/#sec-starttags. Suffice it to say, the ordering of attributes is significant to me. :)