title: XML element values restricted by other element values
body: <p>I'm trying to create a XSD schema and I'm not sure how to achieve one functionality (or even if it's possible at all).
  Basically let say I have the following XML:</p>
  
  <pre><code>&lt;root&gt;
  &lt;allowedElements&gt;
      &lt;element name="a"/&gt;
      &lt;element name="b" /&gt;
  &lt;/allowedElements&gt;
  
  &lt;someList&gt;
      &lt;listEntry elementA="has to be value from allowedElements"/&gt;
  &lt;/someList&gt;
  </code></pre>
  
  <p></p>
  
  <p>Is it possible (and if so, how) to write the XSD schema in such a way that the 'elementA' attribute from 'listEntry' element would have to have value specified in the  element? I.e. </p>
  
  <p>This XML:</p>
  
  <pre><code>&lt;root&gt;
  &lt;allowedElements&gt;
      &lt;element name="a"/&gt;
      &lt;element name="b" /&gt;
  &lt;/allowedElements&gt;
  
  &lt;someList&gt;
      &lt;listEntry elementA="b"/&gt;
  &lt;/someList&gt;
  </code></pre>
  
  <p></p>
  
  <p>Would validate, but the one below would/should throw invalid value exception:</p>
  
  <pre><code>&lt;root&gt;
  &lt;allowedElements&gt;
      &lt;element name="a"/&gt;
      &lt;element name="b" /&gt;
  &lt;/allowedElements&gt;
  
  &lt;someList&gt;
      &lt;listEntry elementA="XYZ"/&gt;
  &lt;/someList&gt;
  </code></pre>
  
  <p></p>