[jdom-interest] How to sort a JDOM tree to simplify it's validation by XSD schema

Olivier Coppel olivier.coppel at akazi.com
Thu Sep 12 02:32:52 PDT 2002


Hi,

Our application built a JDOM tree but elements are unordered. The only way
to validate with xsd an unordered sequence of elements is to use "xsd:all"
tag. But problem is that that I want to ignore some elements that don't
belong to our namespace. In xsd, it's corrsponding to "xsd:any" tag. But
it's IMPOSSIBLE to use "xsd:any" in "xsd:all" tag.
Here is an example of JDOM tree that I want to validate with xsd (elements
are unordered and elemetns from gui namesapce must be ignored) :

<?xml version="1.0" encoding="ISO-8859-1"?>
<root xmlns="http://mynamespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
xmlns:gui="http://namespacetoignore" xsi:schemaLocation="http://mynamespace
xxx.xsd">
    <gui:tagtoignore1/>
    <goodtag1/>
    <gui:tagtoignore2/>
    <gui:tagtoignore3/>
    <goodtag2/>
</root>

So I think that the best way to validate my JDOM tree is to sort it to be
able to use "xsd:sequence" tag in my schema.

My question : is there a way to build an ordered JDOM tree ? or is there a
way to sort a JDOM tree before saving it ?

Many thanks.

Olivier Coppel

mailto:olivier.coppel at akazi.com





More information about the jdom-interest mailing list