【发布时间】:2019-06-23 17:42:33
【问题描述】:
我发现了关于此主题的类似讨论here。但是那里的情况与这个完全不同,解决方案对我不起作用。所以我再次提出这个问题。
我的 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' 之间的冲突吗?提前致谢。
【问题讨论】:
标签: binding xsd jaxb schema xjc