users@jaxb.java.net

Re: xmlRootElement issue

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Wed, 13 Feb 2008 16:13:42 +0100

Hi.

> I've an extremely simple XSD which is included below.
>
> <xs:group name="responseElementGroup">
> <xs:sequence>
> <xs:element name="statusCode" type="xs:int" />
> <xs:element name="statusText" type="xs:string" />
> <xs:element name="statusDetailCode" type="xs:int" />
> <xs:element name="requiestId" type="xs:string" />
> <xs:element name="data" type="xs:string" />
> </xs:sequence>
> </xs:group>
>
> <!-- root element response -->
> <xs:element name="response">
> <xs:complexType>
> <xs:group ref="responseElementGroup" />
> </xs:complexType>
> </xs:element>
>
> Now this one works fine for JAXB. Now if I re-write my XSD to be the
> following (as far as I can tell this describes the same schema.
>
> <xs:group name="responseElementGroup">
> <xs:sequence>
> <xs:element name="statusCode" type="xs:int" />
> <xs:element name="statusText" type="xs:string" />
> <xs:element name="statusDetailCode" type="xs:int" />
> <xs:element name="requiestId" type="xs:string" />
> <xs:element name="data" type="xs:string" />
> </xs:sequence>
> </xs:group>
>
> <!-- root element response type -->
> <xs:complexType name="response">
> <xs:group ref="responseElementGroup" />
> </xs:complexType>
>
> <!-- root element response -->
> <xs:element name="response" type='response"/>
>
> However when generating JAXB classes with the second variation, JAXB does
> not put XmlRootElement annotation on top of the Response class...is this
> because JAXB is getting confused between REsponse being a complexType
> __AND__ an element? (note: I have this working, this email is merely out of
> curiosity).

http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html

Bye.
/lexi