You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ronny <Ro...@bigfunfitness.de> on 2013/04/05 16:11:39 UTC

Validate XML by XSD failes with jDOM and Xerces 2.10.0

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: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validate XML by XSD failes with jDOM and Xerces 2.10.0

Posted by Ronny <Ro...@bigfunfitness.de>.
Sorry. Of course I configured jdom to use the external xerces. Without 
putting the xerces jar into the class path I get errors.

Vom Handy gesendet.



Am 6. April 2013 10:48:55 schrieb Mukul Gandhi <mu...@apache.org>:
> On Sat, Apr 6, 2013 at 1:13 PM, Ronny <Ro...@bigfunfitness.de> wrote:
>
> > JDOM is looking for a xerces class in the class path.
>
> That is fine and then you should provide a Xerces jar within your
> classpath, which you seem to have already done.
>
> > Therefore I downloaded
> > the latest xerces and put it in the JAVA_HOME/lib/ext folder.
>
> I'm really not sure, if substituting a latest Xerces jar within your
> JDOM runtime classpath, may be sufficient to make available
> functionality of this Xerces jar to your JDOM runtime. Your JDOM
> runtime may be using Xerces in some other way.
>
> > So it seems
> > JDOM is using the right xerces implementation. But the error still occurs.
>
> As I wrote earlier, simply placing a new Xerces jar within your JDOM
> classpath may not be a sufficient condition to make available
> functionality of this Xerces jar to your JDOM application.
>
> Therefore, my guess currently wrt this issue are,
> 1) Either JDOM doesn't support using new Xerces jars, in this way.
> 2) Or you may need to do a JDOM specific configuration, to be able to
> use new Xerces jars
>
> You may have to ask support for this query, to JDOM forum or if
> someone here can provide a better explanation perhaps.
>
>
> Sorry if this is not helpful.
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validate XML by XSD failes with jDOM and Xerces 2.10.0

Posted by Mukul Gandhi <mu...@apache.org>.
On Sat, Apr 6, 2013 at 1:13 PM, Ronny <Ro...@bigfunfitness.de> wrote:

> JDOM is looking for a xerces class in the class path.

That is fine and then you should provide a Xerces jar within your
classpath, which you seem to have already done.

> Therefore I downloaded
> the latest xerces and put it in the JAVA_HOME/lib/ext folder.

I'm really not sure, if substituting a latest Xerces jar within your
JDOM runtime classpath, may be sufficient to make available
functionality of this Xerces jar to your JDOM runtime. Your JDOM
runtime may be using Xerces in some other way.

> So it seems
> JDOM is using the right xerces implementation. But the error still occurs.

As I wrote earlier, simply placing a new Xerces jar within your JDOM
classpath may not be a sufficient condition to make available
functionality of this Xerces jar to your JDOM application.

Therefore, my guess currently wrt this issue are,
1) Either JDOM doesn't support using new Xerces jars, in this way.
2) Or you may need to do a JDOM specific configuration, to be able to
use new Xerces jars

You may have to ask support for this query, to JDOM forum or if
someone here can provide a better explanation perhaps.


Sorry if this is not helpful.


-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validate XML by XSD failes with jDOM and Xerces 2.10.0

Posted by Ronny <Ro...@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 <mu...@apache.org>:
> 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 <Ro...@bigfunfitness.de> 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: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validate XML by XSD failes with jDOM and Xerces 2.10.0

Posted by Mukul Gandhi <mu...@apache.org>.
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 <Ro...@bigfunfitness.de> 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: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org


--
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org