Note that there are some explanatory texts on larger screens.

plurals
  1. POhelp please: xjc throws "Two declarations cause a collision in the ObjectFactory class"
    primarykey
    data
    text
    <p>Take the following over simplified XSD:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema targetNamespace="com.acme" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="Widget"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" name="color" nillable="true" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="WidgetColor" type="xs:string" /&gt; &lt;/xs:schema&gt; </code></pre> <p>Then, attempt the following:</p> <pre><code>xjc test.xsd </code></pre> <p>You should invariably get the following exception:</p> <pre><code>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. </code></pre> <p>Notice that There is an element name "<strong>Widget</strong>" which is a complexType and has elements named "<strong>color</strong>". There is also, at the same level as the element "<strong>Widget</strong>", an simple element named "<strong>WidgetColor</strong>".</p> <p>What is more puzzling is that if you <em>remove</em> the attribute minOccurs="0" <strong><em>OR</em></strong> you <em>remove</em> the attribute nillable="true" from the "color" element sequence, xjc compiles the schema successfully.</p> <p>Has anyone ever seen this problem or can suggest a solution?</p> <p>Thanks,</p> <p>Mike.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload