title: Set XSD duplicate constraint at document-level
body: <p>I have the following XML:</p>
  
  <pre><code>&lt;Movies&gt;
      &lt;Title&gt;
          &lt;Platform&gt;Hulu&lt;/Platform&gt;
          &lt;PlatformID&gt;50019855&lt;/PlatformID&gt; &lt;!-- Reject xml based on duplicate PlatformID --&gt;
          &lt;UnixTimestamp&gt;1431892827&lt;/UnixTimestamp&gt;
      &lt;/Title&gt;
      &lt;Title&gt;
          &lt;Platform&gt;Hulu&lt;/Platform&gt;
          &lt;PlatformID&gt;50019855&lt;/PlatformID&gt; &lt;!-- Reject xml based on duplicate PlatformID --&gt;
          &lt;UnixTimestamp&gt;1431892127&lt;/UnixTimestamp&gt;
      &lt;/Title&gt;
  &lt;/Movies&gt;
  </code></pre>
  
  <p>The following XSD validates, however I want it to reject it because <strong>it has a duplicate <code>PlatformID</code></strong>.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
  &lt;xs:element name="Movies"&gt;
    &lt;xs:complexType&gt;
  
      &lt;xs:sequence&gt;
        &lt;xs:element name="Title" maxOccurs="unbounded"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="Platform" type="xs:string"/&gt;
              &lt;xs:element name="PlatformID" type="xs:string" maxOccurs="unbounded"/&gt;
              &lt;xs:element name="UnixTimestamp" type="xs:positiveInteger"/&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;xs:unique name="uniquePlatformID"&gt;
          &lt;xs:selector xpath=".//Title/PlatformID"/&gt;
          &lt;xs:field xpath="."/&gt;
        &lt;/xs:unique&gt;
  
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>What would be the correct XSD here, to reject it based on the duplicate <code>PlatformID</code> above? What is wrong with the XSD I'm currently using? I believe the issue is that I'm trying to create a unique constraint within the <code>Title</code> node, whereas I need to create it document-wide at the <code>Movies/Title/PlatformID</code> level.</p>