users@jaxb.java.net

Re: mixed="true", JAXBElement and List<Serializable>

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Thu, 13 Jul 2006 09:36:55 +0100

Kohsuke Kawaguchi wrote:
> Kenny MacLeod wrote:
>> Kohsuke Kawaguchi wrote:
>>> Kenny MacLeod wrote:
>>>> As a follow-on to this problem, I need a halfway-decent way to
>>>> construct a List<Serializable> of JAXBElement objects for later
>>>> marshalling. At the level of code which uses the JAXB binding,
>>>> there is no access to the QName or namespace of the schema, making
>>>> it difficult to construct JAXBElement objects.
>>>>
>>>> My initial thought it to use reflection to look at the
>>>> @XmlElementRefs annotations at runtime, and infer the required QName
>>>> from that, but that seems like a rather backdoor way of going about
>>>> things.
>>>>
>>>> Any other suggestions?
>>>
>>> What if you just customize the schema compilation process that you
>>> get List<JAXBElement<?>> property to begin with, as opposed to
>>> List<Serializable>?
>>
>> That wouldn't seem to address the problem of constructing the
>> JAXBElement objects myself, though. Or am I missing something?
>
> Maybe I'm misunderstanding your question, then. Maybe you want to create
> JAXBElement<List<Object>> ?

My problem is constructing objects from XJC-generated types, where XJC has generated a field of type
List<Serializable>>, because of the mixed="true" schema type. The generated comments say that the
list must be populated with JAXBElement objects.

For application code which is treating the XJC-generated class model as a POJO model, this is very
invasive.

kenny