users@jaxb.java.net

Re: marshalling and unmarhalling a sequence of any element

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Fri, 28 Sep 2007 13:40:32 +0200

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?

Maybe I did not express myself clear enough.
<any> or generic content elements is represented in JAXB by the JAXBElement.

JAXBElement contains:
* Element name (QName).
* Declared type.
* Scope (whether it's a global element or a local definition).
* Value - an unmarshalled object.
* Whether it's nillled or not.

So. There IS a way to recover the type of the object inside the <any>.
Take a look at the declared type of simply use the value - it IS the
typed unmarshalled object.

Maybe I'm not understanding your difficulties, would you post the code
you experience problems with?

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

http://www.nabble.com/How-can-I-unmarshall-a-xsd%3Aany-element---tf4067146.html

Bye.
/lexi