title: JAXB xjc: Two declarations cause a collision
body: <p>I found a similar discussion on this topic <a href="https://stackoverflow.com/questions/13422253/xjc-two-declarations-cause-a-collision-in-the-objectfactory-class">here</a>. But the scenario there was completely different from this one and the solution does not work for me. So I am bringing this question again.</p>
  
  <p><strong>My XSD</strong> (sample.xsd)</p>
  
  <pre><code>&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;xsd:element name="field"&gt;
        &lt;xsd:complexType&gt;
           &lt;xsd:choice maxOccurs="unbounded" minOccurs="0"&gt;
              &lt;xsd:element maxOccurs="unbounded" minOccurs="0" name="ProgramLevel"&gt;
                 &lt;xsd:complexType&gt;
                    &lt;xsd:attribute name="value" type="xsd:string" use="optional"/&gt;
                    &lt;xsd:attribute name="desc" type="xsd:string" use="optional"/&gt;
                 &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element maxOccurs="unbounded" minOccurs="0" name="Program"&gt;
                 &lt;xsd:complexType&gt;
                    &lt;xsd:sequence maxOccurs="unbounded" minOccurs="0"&gt;
                       &lt;xsd:element maxOccurs="unbounded" minOccurs="0" name="Level"&gt;
                          &lt;xsd:complexType&gt;
                             &lt;xsd:attribute name="value" type="xsd:string" use="optional"/&gt;
                             &lt;xsd:attribute name="desc" type="xsd:string" use="optional"/&gt;
                          &lt;/xsd:complexType&gt;
                       &lt;/xsd:element&gt;
                    &lt;/xsd:sequence&gt;
                 &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
           &lt;/xsd:choice&gt;
        &lt;/xsd:complexType&gt;
      &lt;/xsd:element&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p><strong>My XML</strong></p>
  
  <pre><code>&lt;field&gt;
      &lt;ProgramLevel value="x" /&gt;
  &lt;/field&gt;
  &lt;field&gt;
      &lt;Program&gt;
          &lt;Level value="y" /&gt;
      &lt;/Program&gt;
  &lt;/field&gt;
  </code></pre>
  
  <p>Following error coming on running xjc command</p>
  
  <pre><code>[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.
  </code></pre>
  
  <p>Any idea how to solve the conflict between <code>'ProgramLevel'</code> and <code>'Program-&gt;Level'</code> with the help of binding file? Thanks in advance.</p>