title: XML to be validated against multiple xsd schemas
body: <p>I'm writing the xsd and the code to validate, so I have great control here.</p>
  
  <p>I would like to have an upload facility that adds stuff to my application based on an xml file.  One part of the xml file should be validated against different schemas based on one of the values in the other part of it.  Here's an example to illustrate:</p>
  
  <pre><code>&lt;foo&gt;
    &lt;name&gt;Harold&lt;/name&gt;
    &lt;bar&gt;Alpha&lt;/bar&gt;
    &lt;baz&gt;Mercury&lt;/baz&gt;
    &lt;!-- ... more general info that applies to all foos ... --&gt;
  
    &lt;bar-config&gt;
      &lt;!-- the content here is specific to the bar named "Alpha" --&gt;
    &lt;/bar-config&gt;
    &lt;baz-config&gt;
      &lt;!-- the content here is specific to the baz named "Mercury" --&gt;
    &lt;/baz&gt;
  &lt;/foo&gt;
  </code></pre>
  
  <p>In this case, there is some controlled vocabulary for the content of <code>&lt;bar&gt;</code>, and I can handle that part just fine.  Then, based on the bar value, the appropriate xml schema should be used to validate the content of bar-config. Similarly for baz and baz-config.</p>
  
  <p>The code doing the parsing/validation is written in Java.  Not sure how language-dependent the solution will be.</p>
  
  <p>Ideally, the solution would permit the xml author to declare the appropriate schema locations and what-not so that s/he could get the xml validated on the fly in a sufficiently smart editor.</p>
  
  <p>Also, the possible values for <code>&lt;bar&gt;</code> and <code>&lt;baz&gt;</code> are orthogonal, so I don't want to do this by extension for every possible bar/baz combo.  What I mean is, if there are 24 possible bar values/schemas and 8 possible baz values/schemas, I want to be able to write 1 + 24 + 8 = 33 total schemas, instead of 1 * 24 * 8 = 192 total schemas.</p>
  
  <p>Also, I'd prefer to NOT break out the bar-config and baz-config into separate xml files if possible.  I realize that might make all the problems much easier, as each xml file would have a single schema, but I'm trying to see if there is a good single-xml-file solution.</p>