title: How to generate java from XSD files using JAXB when the same field name is used twice inside a xs:choice?
body: <p>I have a Java maven project and need to generate Java classes from a collection of XSD files. I'm using jaxb2-maven-plugin 2.4. One of the XSD files contains this snippet:</p>
  
  <pre><code>&lt;xs:choice&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="LOT_DIVISION" type="lot_division_f01"/&gt;
          &lt;xs:element name="OBJECT_DESCR" type="object_f01"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element ref="NO_LOT_DIVISION"/&gt;
          &lt;xs:element name="OBJECT_DESCR" type="object_f01"/&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:choice&gt;
  </code></pre>
  
  <p>When I try to auto-generate Java classes for this, using JAXB, I end up with something like this:</p>
  
  <pre><code>/**
   * Gets the rest of the content model. 
   * 
   * &lt;p&gt;
   * You are getting this "catch-all" property because of the following reason: 
   * The field name "OBJECTDESCR" is used by two different parts of a schema. See: 
   * line 142 of file:/C:/Projects/main/web/service/src/xsd/ted/209/F01_2014.xsd
   * line 138 of file:/C:/Projects/main/web/service/src/xsd/ted/209/F01_2014.xsd
   * &lt;p&gt;
   * To get rid of this property, apply a property customization to one 
   * of both of the following declarations to change their names: 
   * Gets the value of the content property.
   * 
   * &lt;p&gt;
   * This accessor method returns a reference to the live list,
   * not a snapshot. Therefore any modification you make to the
   * returned list will be present inside the JAXB object.
   * This is why there is not a &lt;CODE&gt;set&lt;/CODE&gt; method for the content property.
   * 
   * &lt;p&gt;
   * For example, to add a new item, do as follows:
   * &lt;pre&gt;
   *    getContent().add(newItem);
   * &lt;/pre&gt;
   * 
   * 
   * &lt;p&gt;
   * Objects of the following type(s) are allowed in the list
   * {@link JAXBElement }{@code &lt;}{@link TextFtSingleLine }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link String }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link CpvSet }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link TypeContract }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link TextFtMultiLines }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link Val }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link LotDivisionF01 }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link ObjectF01 }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link Empty }{@code &gt;}
   * {@link JAXBElement }{@code &lt;}{@link XMLGregorianCalendar }{@code &gt;}
   * 
   * 
   */
  public List&lt;JAXBElement&lt;?&gt;&gt; getContent() {
      if (content == null) {
          content = new ArrayList&lt;JAXBElement&lt;?&gt;&gt;();
      }
      return this.content;
  }
  </code></pre>
  
  <p>I was expecting a getter for each property, but instead I get this catch-all nightmare.</p>
  
  <p>It says that it is because OBJECTDESCR is used in 2 different parts of the schema, which is right. And normally I would just use bindings.xjb to rename one or the other, but I don't see how in this case.</p>
  
  <p>The XML data and XSD files are from <a href="http://ftp.ted.europa.eu/TED/main/HomePage.do" rel="nofollow noreferrer">http://ftp.ted.europa.eu/TED/main/HomePage.do</a> so I have little control over those parts. But I need to read their data.</p>
  
  <p>The entire collection of XSD files are available here: <a href="http://publications.europa.eu/mdr/resource/eprocurement/ted/R2.0.9/publication/latest/" rel="nofollow noreferrer">http://publications.europa.eu/mdr/resource/eprocurement/ted/R2.0.9/publication/latest/</a> and the snippet is from F01_2014.xsd.</p>