Interface ISchematronResource

All Superinterfaces:
com.helger.commons.id.IHasID<String>
All Known Subinterfaces:
ISchematronXSLTBasedResource
All Known Implementing Classes:
AbstractSchematronResource, AbstractSchematronXSLTBasedResource

public interface ISchematronResource extends com.helger.commons.id.IHasID<String>
Base interface for a Schematron resource. The implementation can e.g. be a SCH file that needs preprocessing to XSLT or an already precompiled XSLT file.
Author:
Philip Helger
  • Method Details

    • getResource

      @Nonnull com.helger.commons.io.resource.IReadableResource getResource()
      Returns:
      The non-null resource from which to read the Schematron rules.
    • isUseCache

      boolean isUseCache()
      Returns:
      true to use caching, if applicable.
      Since:
      5.0.2 in this interface
    • setUseCache

      void setUseCache(boolean bUseCache)
      Enable or disable caching.
      Parameters:
      bUseCache - true to use the cache, false to not use it.
      Since:
      5.0.2 in this interface
    • isLenient

      boolean isLenient()
      This is currently only supported for the "pure Schematron".
      Returns:
      true if 'old' schematron NS is tolerated, false if not. Default is false.
      Since:
      5.4.1
    • setLenient

      void setLenient(boolean bLenient)
      This is currently only supported for the "pure Schematron". Allow use of 'old' schematron NS.
      Parameters:
      bLenient - true if 'old' schematron NS is tolerated, false if not.
      Since:
      5.4.1
    • getEntityResolver

      @Nullable EntityResolver getEntityResolver()
      Returns:
      The XML entity resolver to be used to read the Schematron or XML to be validated. May be null.
      Since:
      4.1.1 in implementation, 5.0.2 in this interface
    • isValidSchematron

      boolean isValidSchematron()
      Returns:
      true if this Schematron can be used to validate XML instances. If not, the Schematron is invalid and the log files must be investigated.
    • getSchematronValidity

      @Nonnull com.helger.commons.state.EValidity getSchematronValidity(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      A method to check if the passed XML DOM node matches the Schematron rules or not. This is the quick check method, as it breaks upon the first failed assertion or the first successful report, if the implementation supports it (as e.g. the native pure Schematron version).
      Parameters:
      aXMLResource - The source XML to read and validate against the Schematron. May not be null.
      Returns:
      EValidity.VALID if the document is valid, EValidity.INVALID if it is invalid.
      Throws:
      Exception - in case of a sever error validating the schema
    • getSchematronValidity

      @Nonnull com.helger.commons.state.EValidity getSchematronValidity(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception
      A method to check if the passed DOM node matches the Schematron rules or not. This is the quick check method, as it breaks upon the first failed assertion or the first successful report, if the implementation supports it (as e.g. the native pure Schematron version).
      Parameters:
      aXMLNode - The source DOM node to validate against the Schematron. May not be null.
      sBaseURI - The Base URI of the XML document to be validated. May be null.
      Returns:
      EValidity.VALID if the document is valid, EValidity.INVALID if it is invalid.
      Throws:
      Exception - in case of a sever error validating the schema
    • getSchematronValidity

      @Nonnull com.helger.commons.state.EValidity getSchematronValidity(@Nonnull Source aXMLSource) throws Exception
      A method to check if the passed XML DOM node matches the Schematron rules or not. This is the quick check method, as it breaks upon the first failed assertion or the first successful report, if the implementation supports it (as e.g. the native pure Schematron version).
      Parameters:
      aXMLSource - The source XML to be validated against the Schematron. May not be null.
      Returns:
      EValidity.VALID if the document is valid, EValidity.INVALID if it is invalid.
      Throws:
      Exception - in case of a sever error validating the schema
    • applySchematronValidation

      @Nullable Document applySchematronValidation(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Apply the Schematron validation on the passed XML resource and return an SVRL XML DOM Document.
      Parameters:
      aXMLResource - The XML resource to be validated via Schematron. May not be null.
      Returns:
      null if the passed resource does not exist or the non- null SVRL document otherwise.
      Throws:
      Exception - In case the transformation somehow goes wrong.
      See Also:
    • applySchematronValidation

      @Nullable Document applySchematronValidation(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception
      Apply the Schematron validation on the passed DOM node and return an SVRL XML DOM Document.
      Parameters:
      aXMLNode - The DOM node to be validated via Schematron. May not be null.
      sBaseURI - The Base URI of the XML document to be validated. May be null.
      Returns:
      null if the passed resource does not exist or the non- null SVRL document otherwise.
      Throws:
      Exception - In case the transformation somehow goes wrong.
      See Also:
    • applySchematronValidation

      @Nullable Document applySchematronValidation(@Nonnull Source aXMLSource) throws Exception
      Apply the Schematron validation on the passed XML source and return an SVRL XML DOM Document.
      Parameters:
      aXMLSource - The XML source to be validated via Schematron. May not be null.
      Returns:
      The SVRL XML document containing the result. May be null when interpreting the Schematron failed.
      Throws:
      Exception - In case the transformation somehow goes wrong.
      See Also:
    • applySchematronValidationToSVRL

      @Nullable SchematronOutputType applySchematronValidationToSVRL(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Apply the Schematron validation on the passed XML resource and return a SchematronOutputType object.
      Parameters:
      aXMLResource - The XML resource to be validated via Schematron. May not be null.
      Returns:
      The SVRL object containing the result. May be null when interpreting the Schematron failed.
      Throws:
      Exception - In case the transformation somehow goes wrong.
    • applySchematronValidationToSVRL

      @Nullable SchematronOutputType applySchematronValidationToSVRL(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception
      Apply the Schematron validation on the passed DOM Node and return a SchematronOutputType object.
      Parameters:
      aXMLNode - The DOM node to be validated via Schematron. May not be null.
      sBaseURI - The Base URI of the XML document to be validated. May be null.
      Returns:
      The SVRL object containing the result. May be null when interpreting the Schematron failed.
      Throws:
      Exception - In case the transformation somehow goes wrong.
    • applySchematronValidationToSVRL

      @Nullable SchematronOutputType applySchematronValidationToSVRL(@Nonnull Source aXMLSource) throws Exception
      Apply the Schematron validation on the passed XML source and return a SchematronOutputType object.
      Parameters:
      aXMLSource - The XML source to be validated via Schematron. May not be null.
      Returns:
      The SVRL object containing the result. May be null when interpreting the Schematron failed.
      Throws:
      Exception - In case the transformation somehow goes wrong.