title: Converting Java Object to XML in the order of Schema xml
body: <p>I have a java object</p>
  
  <pre><code>@XmlRootElement
  public class Customer {
  
      private String name;
      private List&lt;PhoneNumber&gt; phoneNumbers = new ArrayList&lt;PhoneNumber&gt;();
      private String id;
      private Date startDate;
      private Date endDate;
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      @XmlElement(name = "phone-number")
      public List&lt;PhoneNumber&gt; getPhoneNumbers() {
          return phoneNumbers;
      }
      public void setPhoneNumbers(List&lt;PhoneNumber&gt; phoneNumbers) {
          this.phoneNumbers = phoneNumbers;
      }
  }
  </code></pre>
  
  <p>I want to define a schema xml (customer.xsd) which should be used to set the order of tags while generating xml, 
  The Object to xml generated should be like below in different order compared to object members order.</p>
  
  <pre><code>&lt;customer&gt;
      &lt;startDate&gt;&lt;/startDate&gt;
      &lt;endDate&gt;&lt;/endDate&gt;
      &lt;name&gt;&lt;/name&gt;
      &lt;id&gt;&lt;/id&gt;
      &lt;phoneNumbers&gt;&lt;/phoneNumbers&gt; 
  &lt;/customer&gt;
  </code></pre>
  
  <p>Both the Marshalling and Unmarshalling code should be based on the same schema xml.</p>
  
  <p>Can someone help me how to create this schema and how to achieve my ordering??</p>