users@jaxb.java.net

Re: problem of anytype

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

Well, what do you want to be in the XML output? A java.lang.Object()
has no value that can be represented in XML. If you want an empty
element <sync>, use setSync( "" )
-W

On Mon, May 3, 2010 at 3:20 PM, Rochak Gupta <rochak005_at_gmail.com> wrote:
> Thanks for quick reply….
>
>
>
> We are doing something similar e.g. before marshalling , we are setting
> Object in setSync()  (setSync(new Object()), but getting the following
> exception :-
>
>
>
> java.lang.ClassCastException: java.lang.Object cannot be cast to
> org.w3c.dom.Element
>
>
>
> Since it is expecting org.w3c.dom.Element ,we need to have some implementer
>  of it to set it in setSync()
>
>
>
> Please suggest
>
>
> Thanks and regards,
> Rochak Gupta
>
> On Mon, May 3, 2010 at 5:46 PM, Wolfgang Laun <wolfgang.laun_at_gmail.com>
> wrote:
>>
>> 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
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>
>