[jdom-interest] Validate XML by XSD failes with jDOM and Xerces 2.10.0

Ronny Ronny at bigfunfitness.de
Sat Apr 6 05:16:20 PDT 2013

Hi list,

I've got a problem validating a xml by a xsd.

A short preview about the xsd:

<complexType name="MyType2">
 <attribute name="MyAttribute" type="string" use="required" />

<complexType name="MyType1 ... />

<element name="MyRoot">
   <element name="MyType1" ... />
   <element name="MyType2" type="MyType2" minOccurs="1" maxOccurs="1" />

Ok, my XML file looks like this:

<MyRoot xmlns="..." ...>
 <MyType2 MyAttribute="something">

Now I try to validate this with jDOM by using xerces. Then I got the
following error:
 - Error on line 6: cvc-complex-type.3.2.2: Attribute "MyAttribute" must
not occur in element "MyType2".

I configured jDOM1 to use xerces:
SAXBuilder builder = new
SAXBuilder("org.apache.xerces.parsers.SAXParser", true);

I validated the same xml with the same xsd with oXygen (which also uses
xerces) and with some online validators. All told me that the xml is valid.

So my question is, why does the JAVA implementation gives tells me that
the xml is not valid.

I'm grateful for some hints.


Best regards,

More information about the jdom-interest mailing list