users@jaxb.java.net

xmlRootElement issue

From: Alessandro Ferrucci <alessandroferrucci_at_gmail.com>
Date: Wed, 13 Feb 2008 10:04:07 -0500

Hello folks,

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).

Thanks

Alessandro Ferrucci :)

alessandroferrucci_at_gmail.com