[jdom-interest] Are Children under an Element returned in the
GB/DEV - Philip Nelson
philip.nelson at omniresources.com
Thu Mar 8 09:11:52 PST 2001
> If JDOM did not maintain this order, then reading a
> document into JDOM and outputting it back to an XML
> string could take a valid document and make it
> I don't think it is an accident that the current JDOM
> preserves the order of elements, and hopefully this
> thread will be a reminder to any potential
> contributers that order can matter in an XML document,
> and so should be preserved by JDOM.
I'm definately wishing I had put silent mode on earlier ;-)
I haven't worked or tested this part of the api so those folks will have to
comment for a better answer than mine.
When I made the statement, I was thinking of two things over which JDOM
would have a hard time controlling. First, as someone else pointed out,
JDOM relies on the order the parser returns. In the case of Sax, it will
always be the order of the original, but Sax parsers are separate from JDOM.
So the enforcment or order is not from JDOM. However, you can insert child
elements yourself in the the list. A JDOM Element can not tell the
difference between SaxBuilder inserting children or you inserting children,
and a JDOM Element will simply do what it is told. Order is *absolutely*
preserved in Element. The List implementation was chosen for that reason
and I have seen many comments from Jason and Brett instructing users to use
the List methods to insert elements in a specific ordinal position.
And now I will wait for an answer from someone who actually worked on
More information about the jdom-interest