title: JAXB: Generate Object from attributes and another from elements
body: <p>I need to know if is possible to unmarshall an xml and generate child objects.</p>
  
  <p>for example:</p>
  
  <pre><code>&lt;car&gt;
      &lt;nWheels&gt;4&lt;/nWheels&gt;
      &lt;nDoors&gt;5&lt;/nDoors&gt;
      &lt;motor id="1" type="cc" model="kly"&gt;
          &lt;na&gt;A&lt;/na&gt;
          &lt;nb&gt;B&lt;/nb&gt;
          &lt;nc&gt;C&lt;/nc&gt;
          &lt;nd&gt;D&lt;/nd&gt;
      &lt;/motor&gt;
      &lt;motor id="2" type="cc2" model="kly2"&gt;
          &lt;na&gt;E&lt;/na&gt;
          &lt;nb&gt;F&lt;/nb&gt;
          &lt;nc&gt;G&lt;/nc&gt;
          &lt;nd&gt;H&lt;/nd&gt;
      &lt;/motor&gt;
  &lt;/car&gt;
  </code></pre>
  
  <p>With this xml I want generate 3 objects. 
  A class which contains a list of motors and every motor object a class with its elements.</p>
  
  <p>another class:</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Motor {
  
      @XmlAttribute(name = "id")
      private Long id;
  
      @XmlAttribute(name = "type")
      private int type;
  
      @XmlAttribute(name = "model")
      private String model;
  
      //if possible generate another class from motor
      // ??????
      private MotorProperties properties;
  
  }
  
  @XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class MotorProperties {
  
          @XmlElement(name = "na")
          private String na;
  
          @XmlElement(name = "nb")
          private String nb;
  
          @XmlElement(name = "nc")
          private String nc;
  
          @XmlElement(name = "nd")
          private String nd;
  }
  </code></pre>
  
  <p>Is possible to do this? I couldn't find a good example.</p>