6
看看下面的过度简化XSD:帮助请:XJC抛出“两个声明引起ObjectFactory类碰撞”
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="com.acme" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Widget">
<xs:complexType>
<xs:sequence>
<xs:element
minOccurs="0" name="color" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="WidgetColor" type="xs:string" />
</xs:schema>
然后,尝试以下操作:
xjc test.xsd
你应该总是得到以下例外:
parsing a schema...
compiling a schema...
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 11 of file:/C:/test.xsd
[ERROR] (Related to above error) This is the other declaration.
line 7 of file:/C:/test.xsd
Failed to produce code.
请注意,有一个元素名称“Widget“这是一个复杂类型,并具有名为”颜色“的元素。还有,与元素“Widget”相同的级别,名为“WidgetColor”的简单元素。
什么是更令人费解的是,如果你删除属性的minOccurs =“0” OR您从“色”元素序列中删除属性的nillable =“真”,XJC编译模式成功。
有没有人见过这个问题或可以提出解决方案?
谢谢,
迈克。