I have tried to convert XSD to JAXB classes using mave-jaxb2 plugin and jaxb2-basics simplify plugin.
The configuration in pom.xml is available in this post
sample.xsd (complex choice type)
<xs:complexType name="doclist">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="document1" type="type1">
<xs:annotation>
<xs:appinfo>
<simplify:as-reference-property/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="document2" type="type2">
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="heading" type="xs:string" />
</xs:complexType>
However the generated JAXB classes have aOrB references.
@XmlElements({
@XmlElement(name = "document1", type = Type1.class),
@XmlElement(name = "document2", type = Type2.class)
})
protected List<Object> document1OrDocument2;
You have an elements
property so you have to place your annotation on the xs:choice
, not on the xs:element
. Please see the documentation.
And you most probably want to use <simplify:as-element-property/>
.