users@jaxb.java.net

Re: marshalling and unmarhalling a sequence of any element

From: Davide Gesino <williamkidd_at_libero.it>
Date: Fri, 28 Sep 2007 04:26:47 -0700 (PDT)

Hi,

At first I wanted to put into the any a complex type, then I decided to
switch to a String.
So there is not any way to recover the type of the objects inside the <any>?
I mean... it is a structural problem of a bug that will be fixed in future
releases?
I'll try chainging the schema as you suggested, using a global element
inside the<any>.
Can you attach the URL of one of your previous discussions on the argument?
I could not find them.
Thanx for the help.


Aleksei Valikov wrote:
>
> Hi.
>
>> I am encountering a problem mashalling and unmasrhalling data containing
>> a
>> List of any objects, such as:
>>
>> <xs:complexType name="MEVendorExtensions_T">
>> <xs:sequence>
>> <xs:any namespace="##any" processContents="lax"
>> minOccurs="3" maxOccurs="unbounded" />
>> </xs:sequence>
>> </xs:complexType>.
>>
>> JAXB converts an annotation like this in an ArrayList of object.
>> I have a question.
>> How can I marshall and unmarshall some data in this list of objects?
>
> JAXB does it for you, if your schema allows it.
>
>> I have
>> tried marshalling a complex type encapsulating it in a JAXBElement in ths
>> way:
>>
>> JAXBElement<String> jxNameAndStrVal =
>> new JAXBElement<String>(new QName("tmf854.v1"),
>>
>> String.class,
>>
>> elementToPass);
>
> Why JAXBElement<String> and String.class if you have a complex type?
>
>> the marshalling seems to work fine ( the SOAP message seems formatted
>> correct).
>>
>> Anyway when the client receives the data he get the elements encapsulated
>> in
>> a xerces NMElement, and he cannot recover the class of the object he
>> gets.
>> (I noticed the "type" in the nmelement is null).
>
> Seems like the content simply can't be unmarshalled. If you include
> some elements as contents of xsd:any, they should be unmarshallable
> with given schema - this especially means there must be an appropriate
> root/global element declared.
> Otherwise unmarshalling will fail and JAXB will simply add the
> contents as DOM elements.
>
> See my earlier post as well.
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/marshalling-and-unmarhalling-a-sequence-of-any-element-tf4533411.html#a12938732
Sent from the java.net - jaxb users mailing list archive at Nabble.com.