Package net.sf.saxon.lib
Class StandardInvalidityHandler
- java.lang.Object
-
- net.sf.saxon.lib.StandardDiagnostics
-
- net.sf.saxon.lib.StandardInvalidityHandler
-
- All Implemented Interfaces:
InvalidityHandler
- Direct Known Subclasses:
InvalidityReportGenerator
public class StandardInvalidityHandler extends StandardDiagnostics 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 suppliedConfiguration
as the default destination.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.lib.StandardDiagnostics
MAX_MESSAGE_LENGTH, MAX_MESSAGE_LINE_LENGTH, MIN_MESSAGE_LINE_LENGTH, TARGET_MESSAGE_LINE_LENGTH
-
-
Constructor Summary
Constructors Constructor Description StandardInvalidityHandler(Configuration config)
Create a Standard Invalidity Handler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sequence
endReporting()
Get the value to be associated with a validation exception.Configuration
getConfiguration()
Get the Saxon Configuration objectjava.lang.String
getConstraintReferenceMessage(Invalidity err)
Get the constraint reference as a string for inserting into an error message.java.lang.String
getExpandedMessage(Invalidity err)
Get a string containing the message for this exception and all contained exceptionsjava.lang.String
getLocationMessage(Invalidity err)
Get a string identifying the location of an error.Logger
getLogger()
Get the Logger used for displaying messagesvoid
reportInvalidity(Invalidity failure)
Receive notification of a validity error.void
setLogger(Logger logger)
Set output destination for error messages (default is the Logger registered with the Configuration)void
startReporting(java.lang.String systemId)
At the start of a validation episode, initialize the handler-
Methods inherited from class net.sf.saxon.lib.StandardDiagnostics
abbreviateLocationURI, abbreviateLocationURIDefault, expandSpecialCharacters, formatListOfOffendingNodes, getInstructionName, getInstructionNameDefault, getLocationMessageText, printStackTrace, showOriginator, wordWrap
-
-
-
-
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 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:
reportInvalidity
in 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 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.
-
getConstraintReferenceMessage
public java.lang.String getConstraintReferenceMessage(Invalidity err)
Get the constraint reference as a string for inserting into an error message. The default implementation formats a message containing the values ofInvalidity.getSchemaPart()
,Invalidity.getConstraintName()
, andInvalidity.getConstraintClauseNumber()
.- Returns:
- the constraint 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:
endReporting
in 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
-
-