users@jaxb.java.net

Re: problem of anytype

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 3 May 2010 14:16:10 +0200

The short answer: Simply compile the XML schema and see what happens :-)

The longer answer: In absence of any type, java.lang.Object is used as
the type for the sync field of class CreateFields. Before marshalling,
you can use setSync to set the value, e.g., using a java.lang.String.
After unmarshalling getSync() returns an Object, which actually is a
java.lang.String object.

-W


On Mon, May 3, 2010 at 1:31 PM, Rochak Gupta <rochak005_at_gmail.com> wrote:
> Here is my snippet of the xsd:
>
>
>
>       <complexType name="CreateFields">
>
>             <sequence>
>
>                   <element name="ACT" type="idm:ActionType"/>
>
>                   <element name="ORD" type="idm:ServiceOrder"/>
>
>                   <group ref="idm:CommonOrderFields"/>
>
>                   <element name="Notes" type="idm:CircuitNotes"/>
>
>             </sequence>
>
>       </complexType>
>
>
>
>       <group name="CommonOrderFields">
>
>             <sequence>
>
>                   <element name="NEW_CKT" type="idm:TNorCLS"/>
>
>                   <element name="DD" type="date"/>
>
>                   <element name="CN" type="idm:NSPName" default="JoeNSP"/>
>
>                   <element name="CA" type="idm:NSPLiteralName"
> minOccurs="0"/>
>
>                   <element name="SN" type="idm:SubscriberName"/>
>
>                   <element name="SA" type="idm:SubscriberAddr"/>
>
>                   <element name="CSU" type="idm:Usoc"/>
>
>                   <element name="EXK" type="idm:ExchangeKey"/>
>
>                   <element name="WC" type="idm:WireCenter"/>
>
>                   <element name="CMNT" type="string"/>
>
>                   <element name="MFC" type="string"/>
>
>                   <element name="FLC" type="string"/>
>
>                   <element name="SYNC" minOccurs="0"/>
>
>                   <!-- element name="CircuitType" type="idm:CircuitType"/
> -->
>
>             </sequence>
>
>       </group>
>
>
> where CommonOrderFields  group is being referenced by the CreateFields
> complextype. CommonOrderFields group has an element SYNC which has no type
> defined.
>
> Now, I need to know how to handle that “SYNC” element in JAXB2.
>
> Since, my requirement is not allow me to change the xsd file, so can I add
> some external binding to define some type for it OR is there any other way
> to acess SYNC element in application
>
>