title: Creating an XML file from XSD from JAXB
body: <p>I'm having trouble creating an XML file from XSD using JAXB below is the XSD file used to create it. (Note: Names have been edited due to confidentiality)</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ibm.org/seleniumframework" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
      &lt;xs:element name="Test" type="sel:Test"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:choice minOccurs="1" maxOccurs="unbounded"&gt;
                  &lt;xs:element name="Option1" type="sel:Option1Type" xmlns:sel="http://ibm.org/seleniumframework"/&gt;
                  &lt;xs:element name="Option2" type="sel:Option2Type" xmlns:sel="http://ibm.org/seleniumframework"/&gt;
                  &lt;xs:element name="Option3" type="sel:ScreensType" xmlns:sel="http://ibm.org/seleniumframework"/&gt;
              &lt;/xs:choice&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:complexType name="ScreensType"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element type="sel:ScreenType" name="Screen" minOccurs="1" maxOccurs="unbounded" xmlns:sel="http://ibm.org/seleniumframework"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  
      &lt;xs:complexType name="ScreenType"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="ScreenData" minOccurs="1" maxOccurs="unbounded" xmlns:sel="http://ibm.org/seleniumframework"/&gt;
          &lt;/xs:sequence&gt;
          &lt;xs:attribute type="xs:string" name="name1" use="required" /&gt;
          &lt;xs:attribute type="xs:string" name="name2" use="required" /&gt;
          &lt;xs:attribute type="xs:string" name="name3" use="required" /&gt;
      &lt;/xs:complexType&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>This is the code I am using to try and create the XML:</p>
  
  <pre><code>public void generateXml() throws JAXBException, IOException {
  
              Test test = new Test();
              ScreensType screens = new ScreensType();
              ScreenType screen = new ScreenType();
              screen.setName1("a");
              screen.setName2("b");
              screen.setName3("c");
  
              File f = new File("new.xml");
              JAXBContext context= JAXBContext.newInstance("com.q1labs.qa.xmlgenerator.model.generatedxmlclasses");
              Marshaller jaxbMarshaller = context.createMarshaller();
              jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  
              jaxbMarshaller.marshal(test, f);
              jaxbMarshaller.marshal(test, System.out);
  
          }
  </code></pre>
  
  <p>This is the output</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
          &lt;Test xmlns="http://ibm.org/seleniumframework"/&gt;
  </code></pre>
  
  <p>How can I get the code to output the screens and the screen tag along with it's properties, I'm not sure what I'm doing wrong.</p>