Package net.sf.saxon.lib
Class StandardInvalidityHandler
- java.lang.Object
-
- net.sf.saxon.lib.StandardInvalidityHandler
-
- All Implemented Interfaces:
InvalidityHandler
- Direct Known Subclasses:
InvalidityReportGenerator
public class StandardInvalidityHandler extends Object implements InvalidityHandler
This classStandardInvalidityHandler, 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 suppliedLogger, using the Logger belonging to the suppliedConfigurationas the default destination.
-
-
Constructor Summary
Constructors Constructor Description StandardInvalidityHandler(Configuration config)Create a Standard Invalidity Handler
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringabbreviatePath(String uri)Abbreviate a URI (if requested)Sequence<?>endReporting()Get the value to be associated with a validation exception.ConfigurationgetConfiguration()static StringgetConstraintReferenceMessage(Invalidity err)Get the constraint reference as a string for inserting into an error message.StringgetExpandedMessage(Invalidity err)Get a string containing the message for this exception and all contained exceptionsStringgetLocationMessage(Invalidity err)Get a string identifying the location of an error.LoggergetLogger()Get the error output streamvoidreportInvalidity(Invalidity failure)Receive notification of a validity error.voidsetLogger(Logger logger)Set output destination for error messages (default is the Logger registered with the Configuration)voidstartReporting(String systemId)At the start of a validation episode, initialize the handler
-
-
-
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 error output stream- Returns:
- the error output stream
-
getConfiguration
public Configuration getConfiguration()
-
startReporting
public void startReporting(String systemId) throws XPathException
At the start of a validation episode, initialize the handler- Specified by:
startReportingin interfaceInvalidityHandler- 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:
reportInvalidityin interfaceInvalidityHandler- 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 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
-
abbreviatePath
public static String abbreviatePath(String uri)
Abbreviate a URI (if requested)- Parameters:
uri- the URI to be abbreviated- Returns:
- the abbreviated URI, unless full path names were requested, in which case the URI as supplied
-
getExpandedMessage
public 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.
-
getConstraintReferenceMessage
public static String getConstraintReferenceMessage(Invalidity err)
Get the constraint reference as a string for inserting into an error message.- Returns:
- the reference as a message, or null if no information is available
-
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:
endReportingin interfaceInvalidityHandler- 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
-
-