title: How to write my XSD in order to match the desired XML and Java format using JAXB and XJC
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2447091/how-generate-xmlelementwrapper-annotation-with-xjc-and-customized-binding">How generate XMLElementWrapper annotation with xjc and customized binding</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to be able to process XML of this format using JAXB ...</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
    &lt;!-- more content here --&gt;
    &lt;things&gt;
      &lt;thing&gt;
        &lt;name&gt;xx1&lt;/name&gt;
        &lt;value&gt;yy1&lt;/value&gt;
      &lt;/thing&gt;
      &lt;thing&gt;
        &lt;name&gt;xx2&lt;/name&gt;
        &lt;value&gt;yy2&lt;/value&gt;
      &lt;/thing&gt;
    &lt;/things&gt;
    &lt;!-- more content here --&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I'd like to marshal the above XML into these Java classes (for simplicity, I left modifiers such as <code>public</code>, <code>protected</code> as well as getters/setters away):</p>
  
  <pre class="lang-java prettyprint-override"><code>class Configuration {
    List&lt;Thing&gt; things;
  }
  
  class Thing {
    String name;
    String value;
  }
  </code></pre>
  
  <p>The relevant part of my current XSD structure roughly looks like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;complexType name="Configuration"&gt;
    &lt;sequence&gt;
      &lt;!-- ... --&gt;
      &lt;element name="things" type="ns:Things" minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;!-- ... --&gt;
    &lt;/sequence&gt;
  &lt;/complexType&gt;
  
  &lt;complexType name="Things"&gt;
    &lt;sequence&gt;
      &lt;element name="thing" type="ns:Thing" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/sequence&gt;
  &lt;/complexType&gt;
  </code></pre>
  
  <p>Unfortunately, XJC generates also a class for <code>Things</code> even if that is really unnecessary in the Java part of the processing. So my output is this:</p>
  
  <pre class="lang-java prettyprint-override"><code>class Configuration {
    Things things;
  }
  
  class Things {
    List&lt;Thing&gt; thing;
  }
  
  class Thing {
    String name;
    String value;
  }
  </code></pre>
  
  <p>Is there any way I can tell XJC to avoid generating this unnecessary class? Or is there any way I can re-phrase my XSD in order to avoid that generation? Both options would be fine with me.</p>
  
  <p>In fact, I guess I would need to generate the <code>@XmlElementWrapper</code> annotation as documented here:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4047998/mapping-java-collections-which-contains-super-and-sub-types-with-jaxb">Mapping Java collections which contains super- and sub-types with JAXB</a></li>
  <li><a href="https://stackoverflow.com/questions/4863655/jaxb-list-tag-creating-inner-class#4863808">JAXB List Tag creating inner class</a></li>
  </ul>