title: xsd validate xml optional sub-elements
body: <p>I have been trying to construct an XSD file to validate some xml</p>
  
  <p><em>XSD Example</em></p>
  
  <pre><code>&lt;xs:element name="person" type="persontype"/&gt;
  &lt;xs:complexType name="persontype"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="firstname" type="xs:string"/&gt;
      &lt;xs:element name="lastname" type="xs:string"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p><em>XML Example</em></p>
  
  <pre><code>&lt;persontype&gt;
    &lt;firstname/&gt;
    &lt;lastname/&gt;
  &lt;/persontype&gt;
  </code></pre>
  
  <p>How can I construct the xsd to require that the 'firstname' is mandatory, and the 'lastname' is not even necessary for the xml to be valid, and that the sequence does not have to be in order, so long as the hierarchy is respected?</p>
  
  <p>End Result of XMLs which could be encountered, and which I would like to be considered valid according to my final xsd.</p>
  
  <p><strong>Valid Scenario 1</strong></p>
  
  <pre><code>&lt;persontype&gt;
    &lt;firstname/&gt;
  &lt;/persontype&gt;
  </code></pre>
  
  <p><strong>Valid Scenario 2</strong></p>
  
  <pre><code>&lt;persontype&gt;
    &lt;lastname/&gt;
    &lt;firstname/&gt;
  &lt;/persontype&gt;
  </code></pre>
  
  <p>Appreciate your time with the help.</p>