title: Why can't my JAXB Unmarshaller find an element declared in an imported schema?
body: <p>I have two schemas A and B with a circular dependency (it's an intermediate step).  The XML files I'm using as input validate against the schema according to xmllint and Visual Studio.  Eclipse is telling me that both schemas contain two global components with the same name.</p>
  
  <p>A.xsd:</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
    targetNamespace="http://foo.org/A"
    xmlns="http://foo.org/A"
    elementFormDefault="unqualified"
    attributeFormDefault="unqualified"&gt;
  
  &lt;xs:import schemaLocation="b.xsd" /&gt;
  </code></pre>
  
  <p>B.xsd:</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
    xmlns:foo="http://foo.org/A"
    elementFormDefault="unqualified"
    attributeFormDefault="unqualified"&gt;
  
    &lt;xs:import namespace="http://foo.org/A" schemaLocation="a.xsd" /&gt;
  </code></pre>
  
  <p>The XSD I'm passing to the Unmarshaller is A.xsd.  When it encounters an element defined in B.xsd, it complains:</p>
  
  <blockquote>
    <p>org.xml.sax.SAXParseException: cvc-elt.1: Cannot find declaration of element 'foo'.</p>
  </blockquote>
  
  <p>I've set the schema via (pseudo):</p>
  
  <pre><code>InputStream in = .. A.xsd
  SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  return factory.newSchema(new StreamSource(in);
  </code></pre>
  
  <p>Can anyone explain what I'm doing wrong?  Thanks.</p>