title: Validating large XML files against large XSDs, is there a quick way to do this?
body: <p>I'm trying to quickly validate large XML documents against large XSD's. The XML can be anywhere between 500 to 39000 lines long, and the XSD's are in the region of 2000 - 3000 lines.</p>
  
  <p>The result so far has been horribly slow performance, the initialization of the parser with such large XSDs can take up to 30 seconds, however, this is fine as we can do this once and then just inject it.</p>
  
  <p>But, when it comes to actually using this to validate the XML, depending on the implementation it can take anywhere from 30 seconds to 2 minutes.</p>
  
  <p>This is really odd as a command line tool called xmllint:
  <code>xmllint --schema test.xsd valid.xml</code>
  Is able to do the same job but finishes instantly.</p>
  
  <p>I've tried the JDOM library, the SAXReader method and I've settled on the jdom2 stuff, here's how I'm constructing it:</p>
  
  <pre><code>URL xsd = Resources.getResource("test-xml/test.xsd");
  XMLReaderJDOMFactory factory = new XMLReaderXSDFactory(xsd);
  builder = new SAXBuilder(factory);
  </code></pre>
  
  <p>And here's the parsing in action:</p>
  
  <pre><code>InputStream stream = new ByteArrayInputStream(inputXml.getBytes());
  Document document = builder.build(stream);
  </code></pre>
  
  <p>The builder.build part is the line that needs to be borderline instant.</p>
  
  <p>In terms of the desired solution, I don't mind using C, Kotlin, whatever as long as the output is sensible to read and quick.</p>
  
  <p>Thanks</p>