title: XSD Validation: This parser does not support specification "null" version "null"
body: <p>I am trying to validate XML files using standard Java libraries and get the above error. My XSD file <code>test1.xsd</code> is</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;xsd:complexType name="foo"&gt;
          &lt;xsd:attribute name="bar" type="xsd:string" /&gt;
      &lt;/xsd:complexType&gt;  
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>with code (running as Junit test in Eclipse):</p>
  
  <pre><code>@Test
  public void testValidatingParser1() throws Exception {
      String SCHEMA_PATH = "test1.xsd";
      InputStream SCHEMA_STREAM = getClass().getResourceAsStream(SCHEMA_PATH);
      StreamSource SCHEMA_SOURCE = new StreamSource(SCHEMA_STREAM);
      SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Schema schema = sf.newSchema(SCHEMA_SOURCE);
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setSchema(schema);
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
  at javax.xml.parsers.DocumentBuilderFactory.setSchema(Unknown Source)
  at org.xmlcml.graphics.misc.SchemaTest.testValidatingParser1(SchemaTest.java:123)
  </code></pre>
  
  <p>This error seems to arise from incompatibilities with XML parsers (such as Xerces) see <a href="https://stackoverflow.com/questions/8715023/tomcat-this-parser-does-not-support-specification-null-version-null">this post</a> but I have no frameworks (other than Eclipse and Junit). I do not have xerces explicitly in my POM. Is there a simple workround (I don't mind what parser I use as long as it validates).</p>