I found a similar discussion on this topic here. But the scenario there was completely different from this one and the solution does not work for me. So I am bringing this question again.
My XSD (sample.xsd)
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="field">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ProgramLevel">
<xsd:complexType>
<xsd:attribute name="value" type="xsd:string" use="optional"/>
<xsd:attribute name="desc" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Program">
<xsd:complexType>
<xsd:sequence maxOccurs="unbounded" minOccurs="0">
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Level">
<xsd:complexType>
<xsd:attribute name="value" type="xsd:string" use="optional"/>
<xsd:attribute name="desc" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
My XML
<field>
<ProgramLevel value="x" />
</field>
<field>
<Program>
<Level value="y" />
</Program>
</field>
Following error coming on running xjc command
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 7 of file:/D:/ProgramPractice/CreateXSD/JAXB/sample.xsd
[ERROR] (Related to above error) This is the other declaration.
line 16 of file:/D:/ProgramPractice/CreateXSD/JAXB/sample.xsd
Failed to produce code.
Any idea how to solve the conflict between 'ProgramLevel'
and 'Program->Level'
with the help of binding file? Thanks in advance.