Sorry, my mistake. I think I see what the problem is. The problem is not with dom4j. The problem is that I read a properties file using java.util.Properties.load()
The properties file contains key value pairs. Each key-value pair consists of an xPath string (key) followed by the value So an entry of the file would look like /Document/RecordsList/FirstName=John After I load the properties file into a java.util.Properties object, I then loop through the entries in the Properties object // Create an xml document Document document = DocumentHelper.createDocument(); /* .... some code ... */ Enumeration keys = props.propertyNames(); while (keys.hasMoreElements()) { String xPath = (String) keys.nextElement(); String value = props.getProperty(xPath); // Create xml tag specified by the xPath Element element = DocumentHelper.makeElement(document, xPath); // Add text value to xml tag element.add(new DefaultCDATA(value)); /* .... some code ... */ } So the problem appears to be with the Properties object which does not maintain the entries in a sequential order. So now I just have to write some code that would load the properties file into java.util.LinkedHashMap or something that would maintain the order of its entries. Thanks for pointing to me that dom4j does handle ordered xml tags. -Saladin --- Edwin Dankert <[EMAIL PROTECTED]> wrote: > > and then you dynamically create xml tags on that > > document object, one by one, the resulting xml > > document does not preserve the sequentail order of > the > > xml tags in the order in which I created them. > > Can you show us how you create these elements > sequentially and can you show us how you serialize > your dom4j document? > > > And like I said, the xml ordering is important in > > order for it to pass the schema validation, > because > > the XSD file specifies that the xml tags need to > be in > > order (i.e. the XSD uses the <sequence> tag to > > specify the xml tag ordering). > > The order of XML Elements is indeed very important. > > I could not reproduce your problem, using the > following code: > > Document document = DocumentHelper.createDocument(); > Element root = document.addElement("Document"); > Element records = root.addElement("RecordsList"); > records.addElement("FirstName").setText("John"); > records.addElement("LastName").setText("John"); > records.addElement("Age").setText("55"); > > XMLWriter writer = new XMLWriter(System.out); > writer.write(document); > > Regards, > Edwin > -- > http://www.edankert.com/ > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support > web services, security? > Get stuff done quickly with pre-integrated > technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 > based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user