title: Validate a XSD file
body: <p>I want to validate an XSD file (not XML). The approach i am using is to treat the XSD as any other XML file and use this <a href="http://www.w3.org/2001/XMLSchema.xsd" rel="nofollow">www.w3.org/2001/XMLSchema.xsd</a> as the schema. </p>
  
  <p>I am using the following code:</p>
  
  <pre><code>String schemaLang = "http://www.w3.org/2001/XMLSchema";
  SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
  Schema schema = factory.newSchema(new StreamSource("C:\\Users\\aprasad\\Desktop\\XMLSchema.xsd"));
  Validator validator = schema.newValidator();        
  validator.validate(new StreamSource("shiporder.xsd"));
  </code></pre>
  
  <p>But i am getting the following error:</p>
  
  <blockquote>
    <p>Failed to read schema document 'XMLSchema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <code>&lt;xsd:schema&gt;</code>.</p>
  </blockquote>
  
  <p>Not sure what the error is as the file path is correct.</p>
  
  <p>Please tell me the correct approach to validate an XSD file.</p>