title: XSD - Child elements depending on attribute value
body: <p>I am trying to create an XSD schema for the following XML:</p>
  
  <pre><code>&lt;root&gt;
    &lt;!-- The actual file must contain one of the following constraints --&gt;
    &lt;constraint type="interval"&gt;
      &lt;min&gt;100&lt;/min&gt;
      &lt;max&gt;200&lt;/max&gt;
    &lt;/constraint&gt;
  
    &lt;constraint type="equals"&gt;
      &lt;value&gt;EOF&lt;/value&gt;
    &lt;/constraint&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>The child elements of the constraint element depends on the value of the type attribute.</p>
  
  <p>I have successfully validated the XML using an abstract type defining the type attribute, and two extending types defining the child elements. This would require me to decorate the XML with an xsi:type attribute, naming the actual extending type:</p>
  
  <pre><code>  &lt;constraint type="interval" xsi:type="intervalConstraintType"&gt;
      &lt;min&gt;100&lt;/min&gt;
      &lt;max&gt;200&lt;/max&gt;
    &lt;/constraint&gt;
  </code></pre>
  
  <p>Sadly, I'm not in control of the XML-structure and new attributes will be hard to introduce.</p>
  
  <p>Is this doable with XSD? Are there alternatives that are more suitable?</p>