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?
kenny
Kohsuke Kawaguchi wrote:
> Kenny MacLeod wrote:
>> Folks,
>>
>> Take the following schema fragment:
>>
>> <xs:complexType name="MyMixedType" mixed="true">
>> <xs:sequence>
>> <xs:element name="inner" type="MyInnerType" minOccurs="0"
>> maxOccurs="unbounded"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <xs:complexType name="MyInnerType">
>> <xs:simpleContent>
>> <xs:extension base="xs:string"/>
>> </xs:simpleContent>
>> </xs:complexType>
>>
>>
>> When passed through XJC, the MyMixedType class will have a
>> List<Serializable> property. However, because MyInnerType isn't
>> Serializable, you have to wrap instances of MyInnerType in JAXBElement
>> before adding them to MyMixedType's list.
>>
>> This isn't very nice behaviour, given JAXB2's pojo-friendly emphasis.
>> Why doesn't XJC generate List<Object> instead?
>
> I think this is an anomaly in the common base type computation algorithm.
>
> Can you file a bug for this?
>