title: Jaxb marshalling - getting all fields in xml from java object
body: <p>I am using JAXB for marshalling java object to XML. I have generated the required java objects from xsd. I am able to marshall and get the xml as described below. </p>
  
  <pre><code>&lt;Disk&gt;
   &lt;Details&gt;
    &lt;status&gt;attached&lt;/status&gt;
    &lt;size&gt;10000000000&lt;/size&gt;
    &lt;freeSpace&gt;25600000&lt;freeSpace&gt;
    &lt;id&gt;MI45563PO&lt;/id&gt;
   &lt;/Details&gt;
  &lt;/Disk&gt;
  </code></pre>
  
  <p>But the xml contains only the fields, for which am setting the values and the mandatory fields (default values)in the schema. I need all the fields defined in the xsd(as empty) along with the fields, for which I have set values.</p>
  
  <p>Java Code: </p>
  
  <pre><code>    Disk disk = new Disk();
      Details details = new Details();
      details.setSize(100000000);
      details .setDetails(details);
  
      JAXBContext context = JAXBContext.newInstance("com.samplefile");        
  
      Marshaller marshaller = context.createMarshaller();
  
      marshaller.setProperty("jaxb.formatted.output",Boolean.TRUE);
  
      marshalle.marshal(details ,new FileOutputStream(new                           
       File("C:/test/Sample.xml")));
  </code></pre>
  
  <p>Any help is appreciated.</p>