title: XSD Unique Validation
body: <p>I have tried the following to test that an element has a unique identifier.  So far, .net has said that the xml is valid with the xsd but it shouldn't be.</p>
  
  <p>The XML:</p>
  
  <pre><code>&lt;Document&gt;
     &lt;Record&gt;
       &lt;Id&gt;1&lt;/Id&gt;
     &lt;/Record&gt;
     &lt;Record&gt;
       &lt;Id&gt;1&lt;/Id&gt;
     &lt;/Record&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>The XSD:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="Filing_new"
             targetNamespace="http://tempuri.org/Filing_new.xsd"
             elementFormDefault="qualified"
             xmlns="http://tempuri.org/Filing_new.xsd"
             xmlns:mstns="http://tempuri.org/Filing_new.xsd"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
      &lt;!-- Document Schema --&gt;
      &lt;xs:element name="Document"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="Record" minOccurs="1" maxOccurs="unbounded"&gt;
                    &lt;xs:complexType&gt;
                      &lt;xs:sequence&gt;
                        &lt;xs:element name="Id" type="xs:integer" /&gt;
                      &lt;/xs:sequence&gt;
                    &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
          &lt;xs:unique name="sequence"&gt;
              &lt;xs:selector xpath="Record" /&gt;
              &lt;xs:field xpath="Id" /&gt;
          &lt;/xs:unique&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>