title: Validating XML against XSD containing xsd:import without location
body: <p>How to validate XML against the XSD Schema containing import without schema-location?</p>
  
  <p>Fragment of XSD:</p>
  
  <pre><code>&lt;xs:schema xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types
      xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/types"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://schemas.microsoft.com/exchange/services/2006/types"
      elementFormDefault="qualified" version="Exchange2010_SP2" id="types"&gt;
      &lt;xs:import namespace="http://www.w3.org/XML/1998/namespace"/&gt;
  ...
  </code></pre>
  
  <p>Already read and tried:</p>
  
  <p><a href="https://stackoverflow.com/questions/2342808/problem-validating-an-xml-file-using-java-with-an-xsd-having-an-include/2342859#2342859">This one</a> and <a href="https://stackoverflow.com/questions/2624763/xml-to-be-validated-against-multiple-xsd-schemas">this too</a>... Unsuccessfully.</p>
  
  <p>Cannot remove this import from schema, because it contains reference of xml:lang attribute.</p>
  
  <p>In <strong>variant 1</strong> ResourceResolver resolveResource method fired with systemId = <strong>null</strong></p>
  
  <pre><code>public class ResourceResolver  implements LSResourceResolver {
  
      public LSInput resolveResource(String type, String namespaceURI,
              String publicId, String systemId, String baseURI) {
  
        //Some implementation
  
        return new Input(publicId, systemId, resourceAsStream);
  </code></pre>
  
  <p>In <strong>variant 2</strong> tried like this:</p>
  
  <pre><code>SchemaFactory sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
          //sFactory.setResourceResolver(new ResourceResolver());
          Schema schema = sFactory.newSchema(new Source[] {
              new StreamSource("http://www.w3.org/XML/1998/namespace"),
              new StreamSource(MailGateMQBinding.class.getResourceAsStream("/types.xsd")),
          });
  validator = messageSchema.newValidator();
              source = new DOMSource(inDocBody);
              validator.validate(source);
  </code></pre>
  
  <p>But have an Exception: 
  without <code>new StreamSource("http://www.w3.org/XML/1998/namespace")</code> <strong>org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'xml:lang' to a(n) 'attribute declaration'.</strong></p>
  
  <p>and with this <code>new StreamSource("http://www.w3.org/XML/1998/namespace")</code>
  <strong>org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'.. Saw 'The "xml:" Namespace'.</strong></p>
  
  <p>Any help would be greatly appreciated.</p>