code: public static boolean validate(final Source input, final Source[] schemas) {
          boolean isValid = true;
          try {
              final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
              factory.setResourceResolver(new SchemaLSResourceResolver());
              final Validator val = factory.newSchema(schemas).newValidator();
              final ParserErrorHandler eh = new ParserErrorHandler();
              val.setErrorHandler(eh);
              val.validate(input);
              if (eh.didErrorOccur()) {
                  isValid = false;
                  eh.logErrors(LOGGER);
              }
          } catch (final Exception ex) {
              LOGGER.error("Problem validating the given process definition.", ex);
              isValid = false;
          }
  
          return isValid;
      }
docs: Validate an XML document against an XML Schema definition.
  
  @param input
  The input XML document.
  @param schemas
  The XML Schema(s) against which the document must be validated.
  @return Whether the validation was successful.