I'm want to generate java classes from a schema using jaxb, but I am getting a parsing error from xjc. I have 2 elements wrapped in a choice then one of the element is again repeated just after choice:
<xs:element name="A">
<xs:complexType>
<xs:choice>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="X"/>
<xs:element ref="Y"/>
</xs:sequence>
<xs:element ref="Y"/>
</xs:choice>
</xs:complexType>
</xs:element>
jaxb is throwing:
[ERROR] Element "{*something*}Y" shows up in more than one properties.
line *something* of file:/*something*.xsd
PS: my jaxb version is 2.1.13
Take a look at this post on SO. The solution is to provide a custom binding file that maps your Y outside the choice to use another property name.
I would probably also map the recurring sequence to a class with two properties (X and Y), but that's something else.
I've also tried a test schema (derived from yours, just added dummy complex elements for X and Y) with version 7.1 of the free NetBeans IDE and it worked out without any need for a custom binding file. The JAXB version that I've used is 2.2.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With