Kbase P132883: XML attributes are re-ordered alphabetically by the DOM parser
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/7/2008 |
|
Status: Unverified
SYMPTOM(s):
Using SET-ATTRIBUTE to create attributes for an XML document.
XML attributes are re-ordered alphabetically by the DOM parser.
Attributes are being displayed in alphabetical order suggesting that the parser is sorting them.
FACT(s) (Environment):
Progress 9.1x
OpenEdge 10.x
All Supported Operating Systems
CAUSE:
This is expected behavior. According to the XML specifications from the W3C, the attribute order is not significant, and XML Schema does not impose that requirement either.
XML Information Set
W3C Recommendation 4 February 2004
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.
From that respect, many XML editors happen to reorder the attributes and are still XML-compliant.
Depending on attribute order is not XML-compliant.
FIX:
If you are going to define a language that is not XML-compliant because it depends on attribute ordering, you should use a different syntax (like parenthesis instead of angled brackets) to prevent data corruption or confusion with the XML language.
If you are using XML but just want to attach custom-ordered items to an XML element, then use sub-elements which can be ordered, not attributes, which are by definition unordered.