private static void validateSchema(Document document, String schemaFilePath)
      throws ValidateXMLSchemaException {
    // create a SchemaFactory capable of understanding WXS schemas
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

    // load a WXS schema, represented by a Schema instance
    InputStream is = factory.getClass().getResourceAsStream(schemaFilePath);
    Source schemaFile = new StreamSource(is);
    Schema schema;
    try {
      schema = factory.newSchema(schemaFile);
    } catch (SAXException e) {
      throw new ValidateXMLSchemaException(e);
    }

    // create a Validator instance, which can be used to validate an
    // instance document
    Validator validator = schema.newValidator();

    // validate the DOM tree
    try {
      validator.validate(new DOMSource(document));
    } catch (SAXException e) {
      throw new ValidateXMLSchemaException(e);
    } catch (IOException e) {
      throw new ValidateXMLSchemaException(e);
    }
  }