[xsd-users] Preserving XML element order
Barrie Kovish
barrie.kovish at singularsoftware.com
Wed Feb 10 19:22:56 EST 2010
I had a look at the archive but couldn't find a definitive answer to this question.
I am reading an XML file in and writing it out using classes generated by XSD. In general I need to make a few simple modifications to the XML file. But even if I don't modify the XML file the order of the elements is not preserved. i.e. if the XSD classes read in
...
<X>1</X>
<Y>2</Y>
The XSD classes might write out
...
<Y>2</Y>
<X>1</X>
This is a big problem for me because the program which uses these XML files is sensitive to the order of the elements. Note that the schema does note impose an order on the elements and the program which generates the XML files does not order the elements in a specific way. However it is important for a specific document that the order not change.
In addition to using the XSD classes to serialize out the XML I tried using the Xerces XML parser. However it appears that changes I make via the XSD classes do not get propagated to the Xerces DOM.
Is there a solution to this?
Thanks,
Barrie
More information about the xsd-users
mailing list