Class AbstractSchematronResource

java.lang.Object
com.helger.schematron.AbstractSchematronResource
All Implemented Interfaces:
com.helger.commons.id.IHasID<String>, ISchematronResource
Direct Known Subclasses:
AbstractSchematronXSLTBasedResource

@NotThreadSafe public abstract class AbstractSchematronResource extends Object implements ISchematronResource
Abstract implementation of the ISchematronResource interface handling the underlying resource and wrapping one method.
Author:
Philip Helger
  • Field Details

  • Constructor Details

    • AbstractSchematronResource

      public AbstractSchematronResource(@Nonnull com.helger.commons.io.resource.IReadableResource aResource)
      Constructor
      Parameters:
      aResource - The Schematron resource. May not be null.
  • Method Details

    • getID

      @Nonnull public final String getID()
      Specified by:
      getID in interface com.helger.commons.id.IHasID<String>
    • getResource

      @Nonnull public final com.helger.commons.io.resource.IReadableResource getResource()
      Specified by:
      getResource in interface ISchematronResource
      Returns:
      The non-null resource from which to read the Schematron rules.
    • isUseCache

      public final boolean isUseCache()
      Specified by:
      isUseCache in interface ISchematronResource
      Returns:
      true to use caching, if applicable.
    • setUseCache

      public final void setUseCache(boolean bUseCache)
      Description copied from interface: ISchematronResource
      Enable or disable caching.
      Specified by:
      setUseCache in interface ISchematronResource
      Parameters:
      bUseCache - true to use the cache, false to not use it.
    • isLenient

      public final boolean isLenient()
      Description copied from interface: ISchematronResource
      This is currently only supported for the "pure Schematron".
      Specified by:
      isLenient in interface ISchematronResource
      Returns:
      true if 'old' schematron NS is tolerated, false if not. Default is false.
    • setLenient

      public final void setLenient(boolean bLenient)
      Description copied from interface: ISchematronResource
      This is currently only supported for the "pure Schematron". Allow use of 'old' schematron NS.
      Specified by:
      setLenient in interface ISchematronResource
      Parameters:
      bLenient - true if 'old' schematron NS is tolerated, false if not.
    • getEntityResolver

      @Nullable public final EntityResolver getEntityResolver()
      Specified by:
      getEntityResolver in interface ISchematronResource
      Returns:
      The XML entity resolver to be used to read the Schematron or XML to be validated. May be null.
    • internalSetEntityResolver

      protected final void internalSetEntityResolver(@Nullable EntityResolver aEntityResolver)
      Set the XML entity resolver to be used when reading the Schematron or the XML to be validated. This can only be set before the Schematron is bound. If it is already bound an exception is thrown to indicate the unnecessity of the call.
      Parameters:
      aEntityResolver - The entity resolver to set. May be null.
      Since:
      4.2.3
    • internalCreateDOMReaderSettings

      @Nonnull @ReturnsMutableCopy protected com.helger.xml.serialize.read.DOMReaderSettings internalCreateDOMReaderSettings()
      Returns:
      The DOMReaderSettings to be used for reading the XML files to be validated. This includes the EntityResolver to be used.
      See Also:
    • getAsNode

      @Nullable @OverrideOnDemand protected AbstractSchematronResource.NodeAndBaseURI getAsNode(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Throws:
      Exception
    • getAsNode

      @Nullable @OverrideOnDemand protected Node getAsNode(@Nonnull Source aXMLSource) throws Exception
      Throws:
      Exception
    • getSchematronValidity

      @Nonnull public com.helger.commons.state.EValidity getSchematronValidity(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Description copied from interface: ISchematronResource
      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).
      Specified by:
      getSchematronValidity in interface ISchematronResource
      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 public com.helger.commons.state.EValidity getSchematronValidity(@Nonnull Source aXMLSource) throws Exception
      Description copied from interface: ISchematronResource
      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).
      Specified by:
      getSchematronValidity in interface ISchematronResource
      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 public Document applySchematronValidation(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Description copied from interface: ISchematronResource
      Apply the Schematron validation on the passed XML resource and return an SVRL XML DOM Document.
      Specified by:
      applySchematronValidation in interface ISchematronResource
      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 public Document applySchematronValidation(@Nonnull Source aXMLSource) throws Exception
      Description copied from interface: ISchematronResource
      Apply the Schematron validation on the passed XML source and return an SVRL XML DOM Document.
      Specified by:
      applySchematronValidation in interface ISchematronResource
      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 public SchematronOutputType applySchematronValidationToSVRL(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception
      Description copied from interface: ISchematronResource
      Apply the Schematron validation on the passed XML resource and return a SchematronOutputType object.
      Specified by:
      applySchematronValidationToSVRL in interface ISchematronResource
      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 public SchematronOutputType applySchematronValidationToSVRL(@Nonnull Source aXMLSource) throws Exception
      Description copied from interface: ISchematronResource
      Apply the Schematron validation on the passed XML source and return a SchematronOutputType object.
      Specified by:
      applySchematronValidationToSVRL in interface ISchematronResource
      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object