Take the following over simplified XSD:
<?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>
Then, attempt the following:
xjc test.xsd
You should invariably get the following exception:
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.
Notice that There is an element name "Widget" which is a complexType and has elements named "color". There is also, at the same level as the element "Widget", an simple element named "WidgetColor".
What is more puzzling is that if you remove the attribute minOccurs="0" OR you remove the attribute nillable="true" from the "color" element sequence, xjc compiles the schema successfully.
Has anyone ever seen this problem or can suggest a solution?
Thanks,
Mike.