code: public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException  {
          if (_errorHandler == null) {
              _errorHandler = new XmlErrorHandlers.XmlErrorHandlerQuiet();
          }
          DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
          dbFac.setValidating(true);
          dbFac.setNamespaceAware(_namespaceAware);
          dbFac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                       "http://www.w3.org/2001/XMLSchema");
          try {
              DocumentBuilder builder = dbFac.newDocumentBuilder();
              builder.setErrorHandler(_errorHandler);
              return builder.parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
  
          } catch (IOException _ex) {
              throw _ex;
          } catch (Exception _ex) {
              throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
          }
      }
docs: Loads XML from string and uses referenced XSD to validate the content.
  
  
  @param _xmlStr string to validate
  @param _namespaceAware take care of namespace
  @param _errorHandler e.g. {@link XmlErrorHandlers.XmlErrorHandlerQuiet} or {@link XmlErrorHandlers.XmlErrorHandlerRuntimeException}
  @return Document
  @throws IOException on error