title: element is nil and must be empty
body: <p>I have a legacy c++ application that communicates using XML, with the following xml schema for an element.</p>
  <pre><code>        &lt;xs:simpleType name=&quot;CountryType&quot;&gt;
                  &lt;xs:restriction base=&quot;xs:string&quot;&gt;
                          &lt;xs:minLength value=&quot;2&quot;/&gt;
                          &lt;xs:maxLength value=&quot;3&quot;/&gt;
                          &lt;xs:whiteSpace value=&quot;collapse&quot;/&gt;
                          &lt;xs:enumeration value=&quot;ABW&quot;/&gt;
                          &lt;xs:enumeration value=&quot;ALB&quot;/&gt;
                          &lt;xs:enumeration value=&quot;ALG&quot;/&gt;
                          &lt;xs:enumeration value=&quot;AND&quot;/&gt;
                          ...
                  &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
  
          &lt;xs:element name=&quot;Country&quot; nillable=&quot;true&quot;&gt;
                  &lt;xs:complexType&gt;
                          &lt;xs:simpleContent&gt;
                                  &lt;xs:extension base=&quot;CountryType&quot;&gt;
                                          &lt;xs:attribute ref=&quot;searchCriteria&quot; use=&quot;optional&quot;/&gt;
                                  &lt;/xs:extension&gt;
                          &lt;/xs:simpleContent&gt;
                  &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
  </code></pre>
  <p>Even though nillable is set to true, but when</p>
  <pre><code>&lt;Country xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:nil=&quot;true&quot;/&gt;
  </code></pre>
  <p>is passed in, xerces-c schema validation fails, with the error message &quot;element 'Country' is nil and must be empty&quot;.</p>
  <p>Why does it fail?  CountryType has a minLength of 2, so I thought that should restricts it from being empty, but schema validation does not complain when the input is empty and the below is accepted.</p>
  <pre><code>&lt;Country&gt;&lt;/Country&gt;
  </code></pre>
  <p>Is there anyway to make it accept nil?</p>
  <pre><code>&lt;Country xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:nil=&quot;true&quot;/&gt;
  </code></pre>
  <p>The xerces-c library used is of version 3.0. The schema parser settings are:</p>
  <pre><code>      XercesDOMParser *schemaParser = null;
        schemaParser = new XercesDOMParser();
        schemaParser-&gt;setDoNamespaces(true);
        schemaParser-&gt;setDoSchema(true);
        schemaParser-&gt;setValidationScheme(XercesDOMParser::Val_Always);
        schemaParser-&gt;setExternalNoNamespaceSchemaLocation(getSchemaFile());
        schemaParser-&gt;setIncludeIgnorableWhitespace(false);
        schemaParser-&gt;cacheGrammarFromParse(true);
  </code></pre>