title: XSD element required despite minOccurs=0
body: <p>I am new to XSD and confused at current behavior and I am unsure what I am missing. 
  In building a WCF service in VB I am trying to creating some elements that are optional. 
  I have 2 elements defined that I want to be optional, either they are part of the webservice request or not, I don't care.  However I keep getting errors that both are required. 
  Am I missing something obvious?  Sequence and All both should be ok with minOccurrs, as well as references. </p>
  
  <p>In my research I know I am to use the minOccurs="0"
  As cited below from w3Schools</p>
  
  <p><a href="http://www.w3schools.com/schema/schema_complex_indicators.asp" rel="nofollow">MinOccurs defined...</a></p>
  
  <blockquote>
    <p>The "minOccurs" indicator specifies the minimum number of times an
    element can occur.</p>
  </blockquote>
  
  <pre><code>&lt;xs:element name="person"&gt;
     &lt;xs:complexType&gt;
       &lt;xs:sequence&gt;
         &lt;xs:element name="full_name" type="xs:string"/&gt;
         &lt;xs:element name="child_name" type="xs:string"
         maxOccurs="10" minOccurs="0"/&gt;
       &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
   &lt;/xs:element&gt; 
  </code></pre>
  
  <blockquote>
    <p>The example above indicates that the "child_name" element can occur a
    minimum of zero times and a maximum of ten times in the "person"
    element.</p>
  </blockquote>
  
  <p>With this I have defined my ThirdPartyMessage as follows:
  With the goal of having ExternalID and SecondID (no control on the name)</p>
  
  <pre><code>&lt;xs:element name="ThirdPartyMessage"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:all&gt;
          &lt;xs:element ref="Subject"/&gt;
          &lt;xs:element ref="Message"/&gt;
          &lt;xs:element ref="RequestType" /&gt;
          &lt;xs:element ref="ExternalID" minOccurs="0"/&gt;
          &lt;xs:element ref="SecondID" minOccurs="0"/&gt;
        &lt;/xs:all&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  </code></pre>
  
  <p>As well as within </p>
  
  <pre><code>  &lt;xs:complexType name="MessageHeaderType"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="RqUID" type="UUID"/&gt;
        &lt;xs:element name="AsyncRqUID" type="UUID" minOccurs="0"/&gt;
        &lt;xs:element name="PartnerKey" type="Identifier" minOccurs="0"/&gt;
        &lt;xs:element ref="ExternalID" minOccurs="0" maxOccurs="1"/&gt;
        &lt;xs:element ref="SecondID" minOccurs="0" maxOccurs="1"/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>Defined as </p>
  
  <pre><code>  &lt;xs:element name="ExternalID"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:minLength value="0"/&gt;
          &lt;xs:maxLength value="15"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:element&gt;
  
    &lt;xs:element name="SecondID"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="Integer"&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:element&gt;
  </code></pre>