Java Mailing List Archive

http://www.junlu.com/

Home » JDOM Projects »

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

Ronny

2013-04-06


Author LoginPost Reply
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>

<complexType name="MyType1 ... />

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


Ok, my XML file looks like this:

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


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.

Thanks!

Best regards,
Ronny
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.