title: JAXB output not in proper format
body: <p>I Have a problem with marshalling the code as expected XML </p>
  
  <pre><code>public void xmleg() throws XMLStreamException
      {
  
  
       XMLOutputFactory factory = XMLOutputFactory.newInstance();
       XMLStreamWriter writer = factory.createXMLStreamWriter(System.out);
       writer.writeStartDocument();
       writer.writeStartElement("Zoos1"); 
  
  
           QName q=new QName("","Zoo"); 
           for(Zoo add: zoo_list)
          {
          try 
           {
  
            JAXBContext jaxbContext = JAXBContext.newInstance(Zoos.class);
                Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
  
  
  
               jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
               jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
               jaxbMarshaller.marshal(new JAXBElement&lt;Zoot&gt;(q,Zoo.class,add),System.out);
  
           } catch (JAXBException e) {
              e.printStackTrace();
                }
          }
          writer.writeEndDocument();
           writer.close();
          }
  
  
  }
  </code></pre>
  
  <p>Have used the XMLStreamWriter to print the tags required as default..But all the write statements are printed at the last Start tag,start element as well.</p>
  
  <p><strong>The generated output is:</strong></p>
  
  <pre><code>&lt;Zoo&gt;
      &lt;linkId&gt;0&lt;/linkId&gt;
      &lt;name&gt;fjjfjfrj&lt;/name&gt;
  
  &lt;/Zoo&gt;
  
  &lt;Zoo&gt;
      &lt;linkId&gt;0&lt;/linkId&gt;
      &lt;name&gt;fgjfjfj&lt;/name&gt;
  &lt;/Zoo&gt;
  &lt;?xml version="1.0" ?&gt;&lt;Zoos&gt;&lt;/Zoos&gt;
  </code></pre>
  
  <p><strong>The expected output should be:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;Zoo&gt;
      &lt;linkId&gt;0&lt;/linkId&gt;
      &lt;name&gt;fjjfjfrj&lt;/name&gt;
      &lt;/Zoo&gt;
  
   &lt;Zoo&gt;
      &lt;linkId&gt;0&lt;/linkId&gt;
      &lt;name&gt;fgjfjfj&lt;/name&gt;
  &lt;/Zoo&gt;
  </code></pre>
  
  <p></p>