title: Validate an XML File Against Multiple Schema Definitions
body: <p>I'm trying to validate an XML file against a number of different schemas (apologies for the contrived example):</p>
  
  <ul>
  <li>a.xsd </li>
  <li>b.xsd </li>
  <li>c.xsd</li>
  </ul>
  
  <p>c.xsd in particular imports b.xsd and b.xsd imports a.xsd, using:</p>
  
  <p><code>&lt;xs:include schemaLocation="b.xsd"/&gt;</code></p>
  
  <p>I'm trying to do this via Xerces in the following manner:</p>
  
  <pre><code>XMLSchemaFactory xmlSchemaFactory = new XMLSchemaFactory();
  Schema schema = xmlSchemaFactory.newSchema(new StreamSource[] { new StreamSource(this.getClass().getResourceAsStream("a.xsd"), "a.xsd"),
                                                           new StreamSource(this.getClass().getResourceAsStream("b.xsd"), "b.xsd"),
                                                           new StreamSource(this.getClass().getResourceAsStream("c.xsd"), "c.xsd")});     
  Validator validator = schema.newValidator();
  validator.validate(new StreamSource(new StringReader(xmlContent)));
  </code></pre>
  
  <p>but this is failing to import all three of the schemas correctly resulting in cannot resolve the name 'blah' to a(n) 'group' component.  </p>
  
  <p>I've validated this successfully using <strong>Python</strong>, but having real problems with <strong>Java 6.0</strong> and <strong>Xerces 2.8.1</strong>.  Can anybody suggest what's going wrong here, or an easier approach to validate my XML documents?</p>