code: public static void validateXMLSchema(String xsdPath, String xmlPath) throws IOException, SAXException {
  		InputStream xsdStream = null;
  		InputStream xmlStream = null;
  		try {
  			xsdStream = XmlUtils.class.getResourceAsStream(xsdPath);
  		
  			//try loading from classpath first - fallback to disk
  			if (xsdStream == null) {
  				File xsdFile = new File(xsdPath);
  			    xsdStream = new FileInputStream(xsdFile);
  			}
  			
  			xmlStream = XmlUtils.class.getResourceAsStream(xmlPath);
  			
  			//try loading from classpath first - fallback to disk
  			if (xmlStream == null) {
  				File xmlFile = new File(xmlPath);
  				xmlStream = new FileInputStream(xmlFile);
  			}
  			
  			validateXMLSchema(xsdStream, xmlStream);
  			
  		} finally {
  			if (xsdStream != null) {
  				try {
  					xsdStream.close();
  				} catch(Exception e) {
  					xsdStream = null;
  				}
  			}
  			if (xmlStream != null) {
  				try {
  					xmlStream.close();
  				} catch(Exception e) {
  					xmlStream = null;
  				}
  			}
  		}
      }
docs: Validate XML matches XSD. Path-based method.
  Simple redirect to the overloaded version that accepts streams.
  
  @param xsdPath resource based path to XSD file
  @param xmlPath resource based path to XML file
  @throws IOException io exception for loading files
  @throws SAXException sax exception for parsing files