title: Restrict attribute value to child attribute (reference existing value)
body: <p>I have a xml like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;userCredentials default="user1" &gt;
      &lt;userCredential username="user1" password="pwd" /&gt;
      &lt;userCredential username="user2" password="pwd" /&gt;
      &lt;userCredential username="user3" password="pwd" /&gt;
  &lt;/userCredentials&gt;
  </code></pre>
  
  <p>How can I resrict value of attribute <code>default</code> to be only one of <code>//userCredential[@username]</code> value?</p>
  
  <p>Below my xsd scheme:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;xs:complexType name="userCredential"&gt;
    &lt;xs:attribute name="username" type="xs:string" use="required" /&gt;
    &lt;xs:attribute name="password" type="xs:string" use="required" /&gt;
  &lt;/xs:complexType&gt;    
  
  &lt;xs:complexType name="userCredentials"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="userCredential" type="tns:userCredential" minOccurs="1"
                  maxOccurs="unbounded" /&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="default" use="required" &gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction&gt;
            &lt;xs:pattern value="" /&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;        
  &lt;/xs:complexType&gt;  
  </code></pre>