title: Validating XML - Have one attribute define valid name for other attributes
body: <p>I have an XML structure containing something like this:</p>
  
  <pre><code>&lt;goal id="doStuff" .. /&gt;
  &lt;score goal="doStuff" value="true" points="10" /&gt;
  </code></pre>
  
  <p>Works great... until the input became more complex: scores can now rely on multiple goals. We considered:</p>
  
  <pre><code>&lt;goal id="doStuff" .. /&gt;
  &lt;goal id="doOtherStuff" .. /&gt;
  &lt;goal id="dontDoThis" .. /&gt;
  &lt;score goal1="doStuff" value1="true" points="10" /&gt;
  &lt;score goal1="doOtherStuff" value1="true" goal2="dontDoThis" value2="false" points="20" /&gt;
  </code></pre>
  
  <p>But there is no limit to the number of goals a score can depend upon, so at some point this format could break. In the end we came up with:</p>
  
  <pre><code>&lt;goal id="doStuff" .. /&gt;
  &lt;goal id="doOtherStuff" .. /&gt;
  &lt;goal id="dontDoThis" .. /&gt;
  &lt;score doStuff="true" points="10" /&gt;
  &lt;score doOtherStuff="true" dontDoThis="false" points="20" /&gt;
  </code></pre>
  
  <p>This works for the application itself, but I've been unable to figure out how to write XML Schema to validate this properly; it does not seem possible having valid names for the element defined by another element (I have to admit only having read Part 0 of the XML Schema spec, I only threw a couple Ctrl+Fs at Part 1 and Part 2).</p>
  
  <p>Scores have to be calculated according to rules outside of my control; changing the way goals are defined is not an option for instance. The only flexibility I have is the structure of the XML. Could somebody suggest a way to encode the given structure into XML in such a way it can be validated with XML Schema?</p>