title: How to validate a xml file against a given xsd file while parsing it with a sax parser?
body: <p>I want to parse a xml file using a SAXParser or XMLReader and verify that the file conforms to a specific xsd <strong>file</strong> (<code>new File( "example.xsd" )</code>).</p>
  
  <p>It's easy to </p>
  
  <ol>
  <li><p>do the validation against a xsd file in an extra step using a <code>Validator</code> like in <a href="https://stackoverflow.com/questions/15732/whats-the-best-way-to-validate-an-xml-file-against-an-xsd-file/16054#16054">this SO answer</a>.</p></li>
  <li><p>to validate while parsing by specifying the name of the xsd as <code>"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"</code> like in <a href="https://stackoverflow.com/questions/15732/whats-the-best-way-to-validate-an-xml-file-against-an-xsd-file/15739#15739">this SO answer</a>.</p></li>
  </ol>
  
  <p>But how can I validate against a <code>new File( "example.xsd" )</code> <strong>while parsing</strong>?</p>