users@jaxb.java.net

Re: jaxb can't handle this schema?

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Wed, 24 Sep 2003 19:38:18 -0400

The schema is ambiguous as far as JAXB's databinding rules. For example,
you have a choice that is either <a/><b/> or <b/><a/>. In order to
differentiate
whether the original document was the first or second case, JAXB databinding
requires that the second case in your choice to bind to different JAXB
properties.
Thus, you will need properties a, b, and aPrime and bPrime to indicate in
the Java API which order this data should be when marshalled.

To see how to place name customizations on the elements that the JAXB
binding
compiler is flagging, see jaxb/samples/fix-collide. Once you customize
the JAXB
property name for each of the cases, you should be able to complete the
binding
process.

-Joe Fialli, Sun Microsystems

Philip, Tim wrote:

>I have a rather complicated schema definition provided
>by a 3rd party. I'm trying to use JAXB to help me
>handle this information. It is dying while trying to
>figure out how to handle this section of schema. I've
>trimed down the schema a lot to remove clutter, this
>is about as small as I can get it, and still have it
>reproduce the problem.
>
>Is there something inherently wrong with this schema?
>Or have I hit some limitation in JAXB? XMLSpy thinks
>the schema is fine ... which doesn't necessary mean
>a lot. :)
>
>Schema and errors follow ...
>
>
>Thanks!
>Tim.
>
>----- Schema ---------
>
><?xml version="1.0" encoding="utf-8" standalone="no"?>
><xsd:schema elementFormDefault="unqualified"
>xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <xsd:element name="Funk" type="FunkyList"/>
>
> <xsd:complexType name="FunkyList">
> <xsd:choice>
> <xsd:sequence>
> <xsd:choice>
> <xsd:sequence>
> <xsd:element
>name="InstanceA" type="TypeA"/>
> <xsd:element
>name="InstanceB" type="TypeB"/>
> </xsd:sequence>
> <xsd:sequence>
> <xsd:element
>name="InstanceB" type="TypeB"/>
> <xsd:element
>name="InstanceA" type="TypeA"/>
> </xsd:sequence>
> </xsd:choice>
> </xsd:sequence>
> <xsd:sequence>
> <xsd:choice>
> <xsd:element name="InstanceA"
>type="TypeA"/>
> <xsd:element name="InstanceB"
>type="TypeB"/>
> </xsd:choice>
> <xsd:choice>
> <xsd:element name="InstanceB"
>type="TypeB"/>
> <xsd:element name="InstanceA"
>type="TypeA"/>
> </xsd:choice>
> </xsd:sequence>
> </xsd:choice>
> </xsd:complexType>
>
> <xsd:complexType name="TypeA">
> <xsd:sequence>
> <xsd:element name="A1" type="xsd:string"/>
> <xsd:element name="A2" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="TypeB">
> <xsd:sequence>
> <xsd:element name="B1" type="xsd:string"/>
> <xsd:element name="B2" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
>
></xsd:schema>
>
>----- Errors Generated ------
>
>C:\jax>%JWSDP_HOME%\jaxb\bin\xjc.bat -nv -p problem problem2.xsd
>parsing a schema...
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceB"
>is already in use.
> line 15 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 12 of problem2.xsd
>
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceA"
>is already in use.
> line 16 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 11 of problem2.xsd
>
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceA"
>is already in use.
> line 22 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 11 of problem2.xsd
>
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceB"
>is already in use.
> line 23 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 12 of problem2.xsd
>
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceB"
>is already in use.
> line 26 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 12 of problem2.xsd
>
>[ERROR] A class/interface with the same name "problem.FunkyList.InstanceA"
>is already in use.
> line 27 of problem2.xsd
>
>[ERROR] (Relevant to above error) another one is generated from here.
> line 11 of problem2.xsd
>
>Failed to parse a schema.
>C:\jax>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net