"Is node order important in xml ?"
This has always been a pending question, I wanted to answer.
The quick answer:
For a long time I was pretty sure the order wasn't important, you could write:
and
It was the same...
But when using eclipse and validating an xml document, the validator kept complaning if the node were not in the same order as describe in the xsd.
I didn't know if it was an eclipse validator limitation (the validator wasn't able to cop with node order) or a w3c xml requirement.
Untill I found this IBM page describing the same exact issue ;)
Principles of XML design: When the order of XML elements matters
Apparently you can specify in an relax ng schema that order doesn't matter (using ampersand "&") (see: chapter "Schema constraints of element order") but I suspect many people (me included) to use the easiest path and use the comma notation.
As a side effect that means the order does matter, but people writing schema usually don't do this on purpose...
This has always been a pending question, I wanted to answer.
The quick answer:
- No dtd, xml schema(xsd) validation, node order doesn't matter
- Any type of xml validation, order does matter (unless using a special notation in the schema)
For a long time I was pretty sure the order wasn't important, you could write:
<root>
<node1/>
<node2/>
</root>
and
<root>
<node2/>
<node1/>
</root>
It was the same...
But when using eclipse and validating an xml document, the validator kept complaning if the node were not in the same order as describe in the xsd.
I didn't know if it was an eclipse validator limitation (the validator wasn't able to cop with node order) or a w3c xml requirement.
Untill I found this IBM page describing the same exact issue ;)
Principles of XML design: When the order of XML elements matters
Apparently you can specify in an relax ng schema that order doesn't matter (using ampersand "&") (see: chapter "Schema constraints of element order") but I suspect many people (me included) to use the easiest path and use the comma notation.
As a side effect that means the order does matter, but people writing schema usually don't do this on purpose...
Technorati tags: xml