[Zope-dev] Depending on attribute order is not XML compliant

Don Hopkins xardox@mindspring.com
Thu, 9 May 2002 23:48:14 -0700


I feel compelled to take the XML hard line, and point out that depending on
the ordering of XML attributes is not compliant:

http://www.w3.org/TR/xml-infoset/

XML Information Set
W3C Recommendation 24 October 2001
2. Information Items
2.2. Element Information Items
An element information item has the following properties:
  5. [attributes] An unordered set of attribute information items, one for
each of the attributes (specified or defaulted from the DTD) of this
element. Namespace declarations do not appear in this set. If the element
has no attributes, this set has no members.

If you're going to use XML, then use XML, and don't break the spec.
The worse thing you could do is to use
something-that-almost-looks-like-xml-but-is-slightly-different.
That's asking for trouble, and guarantees there will be problems down the
line.
The whole point of using XML is so people can have the valid expectation
that their XML data will work with any compliant XML tool.
As somebody else pointed out, many XML editors reorder the attributes (which
they are 100% justified in doing), and that is as much a fact of life as
what they do with the newlines and white space.
If you're going to define a language that's not XML because it depends on
attribute ordering, then please use an obviously different syntax (like
parenthesis instead of angled brackets), so as not to mislead and confuse
people, or corrupt data.
If you just want to attach ordered items to an XML element, then use
sub-elements which can be ordered, not attributes which are by definition
unordered.

    -Don