code: public static void validateXMLSchema(InputStream xsdStream, InputStream xmlStream) throws IOException, SAXException {
          SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
          Schema schema = factory.newSchema(new StreamSource(xsdStream));
          Validator validator = schema.newValidator();
          validator.validate(new StreamSource(xmlStream));
      }
docs: Validate XML matches XSD. Stream-based method.
  
  @param xsdStream resource based path to XSD file
  @param xmlStream resource based path to XML file
  @throws IOException io exception for loading files
  @throws SAXException sax exception for parsing files