Я нашел похожее обсуждение по этой теме здесь .Но сценарий там полностью отличался от этого, и решение не работает для меня.Поэтому я снова поднимаю этот вопрос.
Мой 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>
Мой XML
<field>
<ProgramLevel value="x" />
</field>
<field>
<Program>
<Level value="y" />
</Program>
</field>
Следующая ошибка при запуске команды xjc
[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.
Есть идеи, как решить конфликт между 'ProgramLevel'
и 'Program->Level'
с помощью файла привязки?Заранее спасибо.