title: XSD Schema with unique id as attribute
body: <p>I want to write a XSD Schema for the following XML:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;yes&quot;?&gt;
  &lt;siss-statusquery xmlns=&quot;http://www.example.de/test&quot;&gt;
      &lt;myhash id=&quot;1&quot;&gt;DG5F6DFG13DFG5641DG5F6DFG13DFG56411337AS&lt;/myhash&gt;
      &lt;myhash id=&quot;2&quot;&gt;123AWDFG13DFG5641DG5F6DFG13GFG56411337AS&lt;/myhash&gt;
      &lt;myhash id=&quot;3&quot;&gt;DG5F6DFG13DFG5641DG5F6325DFG13DFG5641143&lt;/myhash&gt;
  &lt;/siss-statusquery&gt;
  </code></pre>
  <p>Conditions:</p>
  <ul>
  <li><code>&lt;myhash /&gt;</code> tag, minoccurs: <code>1</code> , maxoccurs: <code>unbounded</code></li>
  <li><code>id</code> attribute, type: <code>unsignedInt</code>, is <code>unique</code>, is <code>required</code></li>
  <li><code>&lt;myhash /&gt;</code> tag value pattern: <code>[0-9A-Z]{40,40}</code></li>
  </ul>
  <p>My attempt:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;xs:schema attributeFormDefault=&quot;unqualified&quot;
             elementFormDefault=&quot;qualified&quot; 
             xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
             targetNamespace=&quot;http://www.example.de/test&quot; 
             xmlns:lhs=&quot;http://www.example.de/test&quot;&gt;
  
    &lt;xs:simpleType name=&quot;myhashType&quot;&gt;
      &lt;xs:restriction base=&quot;xs:string&quot;&gt;
        &lt;xs:pattern value=&quot;[0-9A-Z]{40,40}&quot; /&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  
    &lt;xs:element name=&quot;siss-statusquery&quot;&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name=&quot;myhash&quot;
                      maxOccurs=&quot;unbounded&quot;
                      minOccurs=&quot;1&quot;&gt;
            &lt;xs:complexType&gt;
              &lt;xs:simpleContent&gt;
                &lt;xs:extension base=&quot;lhs:myhashType&quot;&gt;
                  &lt;xs:attribute type=&quot;xs:unsignedInt&quot; name=&quot;id&quot; use=&quot;required&quot; /&gt;
                &lt;/xs:extension&gt;
              &lt;/xs:simpleContent&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>How can I constrict/restrict the <code>id</code> attribute as unique?</p>