The order and readability of attributes As commentators noted, the order of attributes does not make sense in XML, i.e. It does not change the value of an element:
<tag attr1="val1" attr2="val2"/> <tag attr2="val2" attr1="val1"/>
In SQL, there is a similar characteristic where the order of the columns does not change the value of the table definition. The XML attributes and SQL columns are a set (not an ordered set), and therefore all that can be βofficiallyβ said about one of them is whether there is an attribute or column in the set.
However, it definitely matters for the human readability that orders these things to appear in situations where constructions like this are authors and appear in the text (for example, the source code) and must be interpreted, careful ordering makes a lot of sense to me .
Typical parser behavior
Any XML parser that treats the order of attributes as meaningful would not conform to the XML standard. This does not mean that this cannot happen, but in my experience this, of course, is unusual. However, depending on the origin of the tool you are mentioning, this is an opportunity that may be worth checking out.
As far as I know, lxml does not have a mechanism for specifying order attributes in serial XML, and I would be surprised if this happened.
To test the behavior, I would really like to just write a text template to generate enough XML to validate it:
id = 1 name = 'Development Signature' puid = 'dev/1' version = '1.0' mimetype = 'text/x-test-signature' template = ('<FileFormat ID="%d" Name="%s" PUID="%s" Version="%s" ' 'MIMEType="%s">') xml = template % (id, name, puid, version, mimetype)
scanny
source share