Class StandardInvalidityHandler

  • All Implemented Interfaces:
    InvalidityHandler
    Direct Known Subclasses:
    InvalidityReportGenerator

    public class StandardInvalidityHandler
    extends StandardDiagnostics
    implements InvalidityHandler
    This class StandardInvalidityHandler, despite its name, is not directly used by Saxon, and in particular it is NOT the default InvalidityHandler. It is however available for use by applications, either directly or by subclassing. (The default InvalidityHandler wraps a supplied ErrorListener). This InvalidityHandler logs validation error messages to a supplied Logger, using the Logger belonging to the supplied Configuration as the default destination.
    • Constructor Detail

      • StandardInvalidityHandler

        public StandardInvalidityHandler​(Configuration config)
        Create a Standard Invalidity Handler
        Parameters:
        config - the Saxon configuration
    • Method Detail

      • setLogger

        public void setLogger​(Logger logger)
        Set output destination for error messages (default is the Logger registered with the Configuration)
        Parameters:
        logger - The Logger to use for error messages
      • getLogger

        public Logger getLogger()
        Get the Logger used for displaying messages
        Returns:
        the registered Logger. This defaults to the Logger supplied by the Configuration
      • getConfiguration

        public Configuration getConfiguration()
        Get the Saxon Configuration object
        Returns:
        the configuration
      • startReporting

        public void startReporting​(java.lang.String systemId)
                            throws XPathException
        At the start of a validation episode, initialize the handler
        Specified by:
        startReporting in interface InvalidityHandler
        Parameters:
        systemId - optional; may be used to represent the destination of any report produced
        Throws:
        XPathException - if initialization of the invalidity handler fails for any reason
      • reportInvalidity

        public void reportInvalidity​(Invalidity failure)
                              throws XPathException
        Receive notification of a validity error.
        Specified by:
        reportInvalidity in interface InvalidityHandler
        Parameters:
        failure - Information about the nature of the invalidity
        Throws:
        XPathException - - if the validation error cannot be reported. This is fatal and will cause the validation run to be abandoned
      • getLocationMessage

        public java.lang.String getLocationMessage​(Invalidity err)
        Get a string identifying the location of an error.
        Parameters:
        err - the exception containing the location information
        Returns:
        a message string describing the location
      • getExpandedMessage

        public java.lang.String getExpandedMessage​(Invalidity err)
        Get a string containing the message for this exception and all contained exceptions
        Parameters:
        err - the exception containing the required information
        Returns:
        a message that concatenates the message of this exception with its contained exceptions, also including information about the error code and location.
      • endReporting

        public Sequence endReporting()
                              throws XPathException
        Get the value to be associated with a validation exception. May return null. In the case of the InvalidityReportGenerator, this returns the XML document containing the validation report
        Specified by:
        endReporting in interface InvalidityHandler
        Returns:
        a value (or null). This will be the value returned as the value of the variable $err:value during try/catch processing
        Throws:
        XPathException - if an error occurs creating any validation report