jaxb2-basics
jaxb2-basics copied to clipboard
multiple choice element that implement thesame base class
I have a question.
I've got the following xsd element
<xsd:complexType name="Types">
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="TypeA" type="TypeA"/>
<xsd:element name="TypeB" type="TypeB"/>
<xsd:element name="TypeC" type="TypeC"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
and in my bindings file
<jaxb:bindings schemaLocation="types/typeA-v2.xsd" node="/xsd:schema">
...
<jaxb:bindings node="xsd:complexType[@name='TypeA']">
<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="types/typeB-v1.xsd" node="/xsd:schema">
...
<jaxb:bindings node="xsd:complexType[@name='TypeB']">
<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="types/typeC-v1.xsd" node="/xsd:schema">
...
<jaxb:bindings node="xsd:complexType[@name='TypeC']">
<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
</jaxb:bindings>
</jaxb:bindings>
The generated code now creates a List of Serializables, which is not really what I want. The Simplify plugin looks promising, but would give me three seperate lists.
Is there a way for me to make it a generated list of AbstractTypes using the inheritance plugin.
PS: I simplified the code a bit.
This type of construct works for me
<jaxb:bindings node="x-path-to-where-Types-is-used">
<jaxb:property>
<jaxb:baseType name="nl.jaxb2-basics.example.dto.AbstractType"/>
</jaxb:property>
</jaxb:bindings>