title: How can I generate a XSD with an xs:element which is optional using JAXB?
body: <p>My model object look something like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRootElement(name = "appConfig")
  @XmlType(propOrder = {})
  public class Config implements Serializable {
  ...
  private int advancedFooBar;
  ...
  @XmlElement(name = "advancedfoobar")
  public int getAdvancedFooBar() {
      return advancedFooBar;
  }
  
  public void setAdvancedFooBar(int advancedFooBar) {
      this.advancedFooBar = advancedFooBar ;
  }
  </code></pre>
  
  <p>When I generate a schema against this class w/JXC I end up with the following for the above property:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;xs:element name="advancedfoobar" type="xs:int"/&gt;
  </code></pre>
  
  <p>I'd like this to be an optional element so I tried changing </p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlElement(name = "advancedfoobar")
  </code></pre>
  
  <p>to</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlElement(name = "advancedfoobar", required=false)
  </code></pre>
  
  <p>However, that did not result any change to the generated schema.  What do I need to do so that the "advancedfoobar" element will be defined as optional in the generated schema?</p>
  
  <p>I am using JDK 1.7.0_U3 on Windows 7 Ultimate x64.</p>
  
  <p>Thanks.</p>
  
  <p>-Noah</p>