Class XSLTValidator

java.lang.Object
net.ionite.docval.validation.validator.XSLTValidator
All Implemented Interfaces:
DocumentValidator
Direct Known Subclasses:
SCHValidator

public class XSLTValidator extends Object implements DocumentValidator
This class implements the DocumentValidor interface for Schematron- XSLT validation files. These are XSLT files that transform an input document to a document following the SVRL schema, and are generally distributed as the 'compiled' version of schematron files. Using these files is much faster than using .SCH files with the SCHValidator directly.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The XSLT file created from a schematron definition, if this validator is initialized with a file.
    protected InputStream
    The InputStream containing the XSLT created from a schematron definition, if this validator is initialized with an inputstream.
    protected org.slf4j.Logger
    General Logger instance
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an Schematron XSLT Validator with the given input stream
    Construct an Schematron XSLT Validator with the given XSLT file.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Transformer
    Load the transformer in the given input stream.
    void
    Reload the XSLT file this validator was initialized with.
    protected Transformer
    Initialize the Saxon Transformer
    validate(byte[] source)
    Validate the given XML document, and return a new ValidationResult structure containing the validation results.
    validate(byte[] source, ValidationResult result)
    Validate the given XML document, and add the validation results to the given ValidationResult structure

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _filename

      protected String _filename
      The XSLT file created from a schematron definition, if this validator is initialized with a file. Null otherwise.
    • _stream

      protected InputStream _stream
      The InputStream containing the XSLT created from a schematron definition, if this validator is initialized with an inputstream. Null otherwise.
    • logger

      protected org.slf4j.Logger logger
      General Logger instance
  • Constructor Details

    • XSLTValidator

      public XSLTValidator(String filename)
      Construct an Schematron XSLT Validator with the given XSLT file.
      Parameters:
      filename - The XSLT file created from a schematron definition
    • XSLTValidator

      public XSLTValidator(InputStream stream)
      Construct an Schematron XSLT Validator with the given input stream
      Parameters:
      stream - the InputStream containing the XSLT created from a schematron definition
  • Method Details

    • reload

      public void reload()
      Reload the XSLT file this validator was initialized with.
      Specified by:
      reload in interface DocumentValidator
      Throws:
      ValidatorException - If there is an error reloading the file, or if this validator was initialized with an input stream.
    • validate

      public ValidationResult validate(byte[] source) throws ValidatorException
      Validate the given XML document, and return a new ValidationResult structure containing the validation results.
      Specified by:
      validate in interface DocumentValidator
      Parameters:
      source - Byte-array containing the XML document to validate
      Returns:
      A newly initialized ValidationResult containing the results of the validation
      Throws:
      ValidatorException - Thrown when there is an error performing the validation
    • validate

      public ValidationResult validate(byte[] source, ValidationResult result) throws ValidatorException
      Validate the given XML document, and add the validation results to the given ValidationResult structure
      Specified by:
      validate in interface DocumentValidator
      Parameters:
      source - Byte-array containing the XML document to validate
      result - The structure to add the validation results to
      Returns:
      The modified ValidationResult instance
      Throws:
      ValidatorException - Thrown when there is an error performing the validation
    • setupTransformer

      protected Transformer setupTransformer()
      Initialize the Saxon Transformer
    • loadTransformer

      protected Transformer loadTransformer(InputStream inputStream)
      Load the transformer in the given input stream.
      Parameters:
      inputStream - The input stream containing the XSLT
      Throws:
      ValidatorException - if the transformer cannot be initialized from the given stream data