title: Resolving which version of an XML Schema to use for XML documents with a version attribute
body: <p>I have to write some code to handle reading and validating XML documents that use a version attribute in their root element to declare a version number, like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt; 
  &lt;Junk xmlns="urn:com:initech:tps" 
      xmlns:xsi="http://www3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="urn:com:initech.tps:schemas/foo/Junk.xsd"
      VersionAttribute="2.0"&gt;
  </code></pre>
  
  <p>There are a bunch of nested schemas, my code has an <a href="http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/ls/LSResourceResolver.html" rel="nofollow"><code>org.w3c.dom.ls.LsResourceResolver</code></a> to figure out what schema to use, implementing this method:</p>
  
  <pre><code>LSInput resolveResource(String type,
                          String namespaceURI,
                          String publicId,
                          String systemId,
                          String baseURI)
  </code></pre>
  
  <p>Previous versions of the schema have embedded the schema version into the namespace, so I could use the namespaceURI and systemId to decide which schema to provide. Now the version number has been switched to an attribute in the root element, and my resolver doesn't have access to that. How am I supposed to figure out the version of the XML document in the <code>LsResourceResolver</code>? </p>