Re: Validate XML by XSD failes with jDOM and Xerces 2.10.0
Ronny <[email protected]>
| Newsgroups | gmane.text.xml.xerces-j.user |
|---|---|
| Message-ID | <13dde4c8844.2769.9b5ac8ddb5b3f9ec0f7d1a9ec613a0ef@bigfunfitness.de> |
Hi, JDOM is looking for a xerces class in the class path. Therefore I downloaded the latest xerces and put it in the JAVA_HOME/lib/ext folder. So it seems JDOM is using the right xerces implementation. But the error still occurs. Regards, Ronny Vom Handy gesendet. Am 6. April 2013 05:29:40 schrieb Mukul Gandhi <[email protected]>: > Does JDOM has a native Xerces-J XSD integration? If its kind of that, > then the XSD processor active within your JDOM runtime may have a > validator bug. If that is so, you may need to report this problem to > JDOM forum. > > As far as I know, Xerces-J doesn't provide explicit JDOM integration. > Another approach you can try is if you're constrained to use a JDOM > representation of your input XML for XSD validation is to following > steps like below, > 1) Serialize the JDOM tree into an XML document (like a file, string etc). > 2) Then use result of step 1) and your XSD document, to do schema > validation with Xerces-J. This would also allow you to integrate an > externally available (which may have a better XSD compliance, that the > validator currently active in your JDOM implementation) Xerces-J > library, with your JDOM input. > > Having written all of this, I really haven't verified the internals of > JDOM. Please correct me, if I'm wrong. > > On Fri, Apr 5, 2013 at 7:41 PM, Ronny <[email protected]> wrote: > > > > 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 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 unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > -- > Regards, > Mukul Gandhi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >