Class XmlSchemaValidator

java.lang.Object
io.github.microcks.util.XmlSchemaValidator

public class XmlSchemaValidator extends Object
Helper class for easy access to a Xml Schema validation. Validators embed an error handler and use a specific LSResourceResolver allowing for resolving relative dependencies from provided XmlSchemas.
Author:
laurent
  • Method Details

    • validateXml

      public static List<String> validateXml(InputStream schemaStream, String xmlString) throws Exception
      Validation the Xml string with provided stream on its Xml schema.
      Parameters:
      schemaStream - A stream on reference Xml Schema
      xmlString - String representation of Xml to validate
      Returns:
      A list of validation errors that mey be empty if validation is ok
      Throws:
      Exception - if validator cannot be initialized (in case of malformed schema stream)
    • validateXml

      public static List<String> validateXml(InputStream schemaStream, String xmlString, String baseResourceUrl) throws Exception
      Validation the Xml string with provided stream on its Xml schema. A resource URL can be provided to resolved relative includes found into Xml Schema stream.
      Parameters:
      schemaStream - A stream on reference Xml Schema
      xmlString - String representation of Xml to validate
      baseResourceUrl - Base resource URL for resolving relative dependencies
      Returns:
      A list of validation errors that mey be empty if validation is ok
      Throws:
      Exception - if validator cannot be initialized (in case of malformed schema stream)