Hi Mark,

I don't think there is a proper API for the things you want to do. However, you could use this 'hack' to solve your problem: instead of adding the "name" and "addr" elements to the person element, you could add them to the list returned by the Element.elements() method:

Element person = ...;
Element addr = ...;
Element name = ...;
List elements = person.elements();
elements.add(addr);
elements.add(0, name);

Maarten

Mark Woon wrote:

Hi all,

I'm new to dom4j so please point me to the appropriate docs if I've missed something. I'm trying to build an XML document with dom4j that complies with a schema in which the order of elements matter. For example, the following is valid:

<person>
 <name />
 <addr />
</person>

But this isn't:

<person>
 <addr />
 <name />
</person>


Unfortunately, as I'm constructing the document, I will not always be able to add the elements in the right order. Is there a way to specify the order in which the elements should be sorted, or do I have to do something like use the visitor pattern to visit every element to make sure that it's properly sorted before printing the document?



Thanks, -Mark


------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X.

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user



------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to