Take the following 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 follow these steps:
xjc test.xsd
You should definitely 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.
Note that there is a widget element name that is complexType and has elements named color . At the same level as the Widget element, there is a simple element called WidgetColor .
What is more puzzling is that if you remove the minOccurs = "0" OR attribute, you remove the nillable = "true" attribute from the sequence of color elements, xjc will successfully compile the circuit.
Has anyone seen this problem or can offer a solution?
Thanks,
Mike.
Mike source share