title: Validate an XML against an XSD in Java / Getting a hold of the schemaLocation
body: <p>How can one validate an XML file using an XSD in Java? We don't know the schema in advance. I would like to be able to get the <code>schemaLocation</code>, download the XSD, cache it and then perform the actual validation. </p>
  
  <p>The problem is, that with <code>javax.xml.parsers.DocumentBuilder</code>/<code>DocumentBuilderFactory</code> classes I can't seem to be able to get a hold of the <code>schemaLocation</code> in advance. What's the trick for this? Which classes should I look into?</p>
  
  <p>Perhaps there's a more suitable API I can use? The whole problem is that we need to validate dynamically, without (necessarily) having the XSDs locally.</p>
  
  <p>How could one get a hold of the URL of <code>schemaLocation</code> defined in the XSD file?</p>
  
  <p>I know you can set features/attributes, but that's a different thing. I need to get the <code>schemaLocation</code> from the XSD first.</p>
  
  <p>Please advise!</p>