Issue
I am using the following xsd schema file to generate java classes
<xsd:complexType name="Instruction">
<xsd:choice>
<xsd:sequence>
<xsd:element name="InstructionIndicator" type="InstructionIndicator">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:sequence minOccurs="0" maxOccurs="49">
<xsd:element name="MultipleTimingModifier" type="ANDOR"
minOccurs="0">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="TimingAndDuration" type="TimingAndDuration" />
</xsd:sequence>
</xsd:sequence>
<xsd:sequence>
<xsd:choice>
<xsd:element name="AdministrationIndicator" type="AdministrationIndicator">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:sequence>
<xsd:element name="DoseAdministration" type="DoseAdministration" />
<xsd:element name="TimingAndDuration" type="TimingAndDuration">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:sequence minOccurs="0" maxOccurs="49">
<xsd:element name="MultipleTimingModifier" type="ANDOR"
minOccurs="0">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="TimingAndDuration" type="TimingAndDuration" />
</xsd:sequence>
</xsd:sequence>
</xsd:choice>
<xsd:sequence minOccurs="0">
<xsd:element name="IndicationForUse" type="Indication"
maxOccurs="50">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="IndicationClarifyingFreeText" type="an1..255"
minOccurs="0" />
</xsd:sequence>
<xsd:element name="MaximumDoseRestriction" type="MaximumDoseRestriction"
minOccurs="0" maxOccurs="50">
<xsd:annotation>
<xsd:documentation>some text</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:choice>
But processing this results in an error
Property "MultipleTimingModifierAndTimingAndDuration" is already defined. Use <jaxb:property> to resolve this conflict.
To resolve this i wrote a binding file with following content
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc" version="2.0">
<jaxb:bindings schemaLocation="structures.xsd"
node="//xs:complexType[@name='Instruction']/xs:choice[1]
/xs:sequence[1]/xs:sequence/xs:element[@name='MultipleTimingModifier']">
<jaxb:property name="MultipleTimingModifier1" />
</jaxb:bindings>
<jaxb:bindings schemaLocation="structures.xsd"
node="//xs:complexType[@name='Instruction']/xs:choice
/xs:sequence[1]/xs:sequence/xs:element[@name='TimingAndDuration']">
<jaxb:property name="TimingAndDuration1" />
</jaxb:bindings>
after adding this binding file while generating Jaxb classes in elcipse the following error is produced
compiler was unable to honor this property customization. It is attached to a wrong place, or its inconsistent with other bindings.
the classes will successfully generate if maxoccurs="49" constraint is removed from targeted sequence node
Note:
- the schema is a combination of 5 different files and is of more then 2000 lines
- only the part in which error is produced is shared here
- if you are going to down vote this please also leave a reason in the comments so i can improve the question
- i have tried all the existing answers out there but none of them worked for me
Solution
Using the following binding code i have resolved my issue
<jaxb:bindings
schemaLocation="structures.xsd"
node="//xs:complexType[@name='Instruction']/xs:choice/xs:sequence[1]/xs:sequence[1]">
<jaxb:property name="seq1"/>
</jaxb:bindings>
Answered By - Abdul Ahad
Answer Checked By - David Goodson (JavaFixing Volunteer)