title: Can Jaxb marshal child elements without the root element?
body: <p>I'm not sure if the following question is possible with jaxb, but I'll ask anyway.</p>
  
  <p>In a certain project, we're using jaxb with a defined schema to create the next structure of xml file.</p>
  
  <pre><code>&lt;aaa&gt;
       &lt;bbb&gt;
          more inner children here
       &lt;/bbb&gt;
       &lt;bbb&gt;
          more inner children here
       &lt;/bbb&gt;
  &lt;/aaa&gt;
  </code></pre>
  
  <p>We're also using the automatic class generating of jaxb which creates the classes: aaa and bbb, <strong>where aaa was generated as the @XmlRootElement.</strong></p>
  
  <p>We now want to use the same schema in a new project, that will be also compatible with the previous project.
  What I would like to do, is to use the same jaxb generated classes, without performing any changes in the schema in order to marshal only a single bbb object into xml.</p>
  
  <pre><code>JAXBContext jc = JAXBContext.newInstance("generated");
  Marshaller marshaller = jc.createMarshaller();
  marshaller.marshal(bbb, writer);
  </code></pre>
  
  <p>So we would get the next result:</p>
  
  <pre><code> &lt;bbb&gt;
      &lt;inner child1/&gt;
      &lt;inner child2/&gt;
      ...
   &lt;/bbb&gt;
  </code></pre>
  
  <p>I'm currently not able to do so as the marshaller yells that I do not have a @XmlRootElement defined.</p>
  
  <p>We're actually trying to avoid the case of separating the schema into 2 schemas, one of only bbb and the other where aaa imports bbb.</p>
  
  <p>Thanks in advance!</p>