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
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.-
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
ConstructorsConstructorDescriptionCreate a Standard Invalidity Handler -
Method Summary
Modifier and TypeMethodDescriptionGet the value to be associated with a validation exception.Get the Saxon Configuration objectGet the constraint reference as a string for inserting into an error message.Get a string containing the message for this exception and all contained exceptionsGet a string identifying the location of an error.Get the Logger used for displaying messagesvoid
reportInvalidity
(Invalidity failure) Receive notification of a validity error.void
Set output destination for error messages (default is the Logger registered with the Configuration)void
startReporting
(String systemId) At the start of a validation episode, initialize the handlerMethods inherited from class net.sf.saxon.lib.StandardDiagnostics
abbreviateLocationURI, abbreviateLocationURIDefault, expandSpecialCharacters, formatListOfOffendingNodes, getInstructionName, getInstructionNameDefault, getLocationMessageText, logStackTrace, showOriginator, wordWrap
-
Constructor Details
-
StandardInvalidityHandler
Create a Standard Invalidity Handler- Parameters:
config
- the Saxon configuration
-
-
Method Details
-
setLogger
Set output destination for error messages (default is the Logger registered with the Configuration)- Parameters:
logger
- The Logger to use for error messages
-
getLogger
Get the Logger used for displaying messages- Returns:
- the registered Logger. This defaults to the Logger supplied by the
Configuration
-
getConfiguration
Get the Saxon Configuration object- Returns:
- the configuration
-
startReporting
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
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
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
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
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
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
-