users@jaxb.java.net

Re: jaxb2 - duplicate element issue

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Tue, 01 Apr 2008 19:21:32 +0100

JAXB2 cannot generate code from that schema, sadly. Consecutive
elements of the same name have to be modelled as sequences.



Ajay Aggarwal wrote:
> We have a type in our schema, which looks like below. Our intent for
> this type is to have at least one property element followed by any
> combination of property or compound elements.
>
>
>
> <xsd:complexType name="foo">
>
> <xsd:sequence>
>
> <xsd:element name="property" type="typeA"/>
>
> <xsd:choice maxOccurs="unbounded">
>
> <xsd:element name="property" type="typeA"/>
>
> <xsd:element name="compound" type="typeB"/>
>
> </xsd:choice>
>
> </xsd:sequence>
>
> </xsd:complexType>
>
>
>
> This was working fine with JAXB1 based xjc tool. But with JAXB2, it
> gives following error. To the best of my knowledge, above is a valid
> schema. Is this a limitation of JAXB2? Is there any other way to
> formulate this schema to make JAXB2/xjc happy?
>
>
>
> Errors from jaxb2 xjc ant task
>
> [xjc] Consider using <depends>/<produces> so that XJC won't do
> unnecessary compilation
>
> [xjc] [ERROR] Element "property" shows up in more than one properties.
>
>
>
>
>
>
>