title: XML Schema: element with attributes and text with restrictions
body: <p>I'm a beginner with XML Schema and I'm trying to solve a (in my opinion) rather simple problem: I want to match a tag in the form</p>
  
  <pre><code>&lt;foo bar="123"&gt;some text&lt;/foo&gt;
  </code></pre>
  
  <p>i.e. a tag with both text and and attribute. Basically, I know how this can be done with the <code>extension</code> facility. It seems rather unintuitive, but works. This is the basic idiom:</p>
  
  <pre><code>&lt;xs:element name="option"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:string"&gt;
          &lt;xs:attribute name="value" type="xs:string"&gt;
          &lt;/xs:attribute&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>However, I also want to impose restrictions on text and attribute! The text shouldn't exceed a certain length and the attribute should be in an integer in a certain range. How can I achieve that? It seems that I cannot use restrictions for the text when I use an extension.</p>