code: public NodeList validate(Document xmlEntity, String schemaRef, String phase) {
  
          if (xmlEntity == null || xmlEntity.getDocumentElement() == null)
              throw new IllegalArgumentException("No XML entity supplied (null).");
          InputSource xmlInputSource = null;
          try {
              InputStream inputStream = DocumentToInputStream(xmlEntity);
              xmlInputSource = new InputSource(inputStream);
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
          PropertyMapBuilder builder = new PropertyMapBuilder();
          SchematronProperty.DIAGNOSE.add(builder);
          if (null != phase && !phase.isEmpty()) {
              builder.put(SchematronProperty.PHASE, phase);
          }
          XmlErrorHandler errHandler = new XmlErrorHandler();
          builder.put(ValidateProperty.ERROR_HANDLER, errHandler);
          ValidationDriver driver = createDriver(builder.toPropertyMap());
          InputStream schStream = this.getClass().getResourceAsStream(schemaRef.trim());
          try {
              InputSource input = new InputSource(schStream);
              try {
                  boolean loaded = driver.loadSchema(input);
                  if (!loaded) {
                      throw new Exception("Failed to load schema at " + schemaRef.trim()
                              + "\nIs the schema valid? Is the phase defined?");
                  }
              } finally {
                  schStream.close();
              }
              driver.validate(xmlInputSource);
          } catch (Exception e) {
              throw new RuntimeException("Schematron validation failed.", e);
          }
          NodeList errList = errHandler.toNodeList();
          if (LOGR.isLoggable(Level.FINER)) {
              LOGR.finer(String.format(
                      "Found %d Schematron rule violation(s):%n %s",
                      errList.getLength(), errHandler.toString()));
          }
          return errList;
      }
docs: Checks the content of an XML entity against the applicable rules defined
  in a Schematron schema. The designated phase identifies the active
  patterns (rule sets); if not specified, the default phase is executed.
  
  @param xmlEntity
  A DOM Document representing the XML entity to validate.
  @param schemaRef
  A (classpath) reference to a Schematron 1.5 schema.
  @param phase
  The phase to execute.
  @return A NodeList containing validation errors (it may be empty).