title: Is it valid for XSD to define a complex element as compulsory but all children elements are optional?
body: <p>I am trying to write a XML generator from a set of xpaths and values. And the generated XML needs to be valid according to its XSD. So an example is like below</p>
  
  <p>XSD. XSD version is 1.0.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:element name="products"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="books"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element type="xs:string" name="book" maxOccurs="unbounded" minOccurs="0"/&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;xs:element name="cards" minOccurs="1" maxOccurs="1"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element type="xs:string" name="card" maxOccurs="unbounded" minOccurs="0"/&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>According to the XSD, the <code>cards</code> is required. Although no card is not required with <code>minOccurs="0"</code>.</p>
  
  <p>The set of xpaths and the values are in a CSV file. The values may be from database, so it is not guaranteed to have <code>cards</code>.</p>
  
  <pre><code>/products/books/book[0],book1_name
  /products/books/book[1],book2_name
  </code></pre>
  
  <p>Generated XML</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;products&gt;
      &lt;books&gt;
          &lt;book&gt;book1_name&lt;/book&gt;
          &lt;book&gt;book2_name&lt;/book&gt;
      &lt;/books&gt;
  &lt;/products&gt;
  </code></pre>
  
  <p>So the XML is not valid for its XSD because <code>cards</code> node is not there.</p>
  
  <ul>
  <li>In terms of XSD, is it valid to make the parent (<code>cards</code>) compulsory, but all children (<code>card</code>) optional? </li>
  <li>In terms of the meaning of XML, does it make sense to have <code>cards</code> but without any children or value?</li>
  </ul>