public class StandardErrorListener extends java.lang.Object implements UnfailingErrorListener
Constructor and Description |
---|
StandardErrorListener()
Create a Standard Error Listener
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
abbreviatePath(java.lang.String uri)
Abbreviate a URI (if requested)
|
void |
error(javax.xml.transform.TransformerException exception)
Receive notification of a recoverable error.
|
void |
fatalError(javax.xml.transform.TransformerException exception)
Receive notification of a non-recoverable error.
|
java.lang.String |
getErrorObjectString(Sequence errorObject)
Get a string representation of the error object associated with the exception (this represents
the final argument to fn:error, in the case of error triggered by calls on the fn:error function).
|
java.lang.String |
getExpandedMessage(javax.xml.transform.TransformerException err)
Get a string containing the message for this exception and all contained exceptions
|
static java.lang.String |
getInstructionName(Instruction inst)
Extract a name identifying the instruction at which an error occurred
|
java.lang.String |
getLocationMessage(javax.xml.transform.TransformerException err)
Get a string identifying the location of an error.
|
static java.lang.String |
getLocationMessageText(javax.xml.transform.SourceLocator loc) |
Logger |
getLogger()
Get the error output stream
|
int |
getMaximumNumberOfWarnings()
Get the maximum number of warnings that are reported; further warnings after this limit
are silently ignored
|
static java.lang.String |
getOffenderListText(ValidationFailure failure) |
int |
getRecoveryPolicy()
Get the recovery policy
|
StandardErrorListener |
makeAnother(int hostLanguage)
Make a clean copy of this ErrorListener.
|
protected void |
outputStackTrace(Logger out,
XPathContext context)
Generate a stack trace.
|
static void |
printStackTrace(Logger out,
XPathContext context)
Print a stack trace to a specified output destination
|
void |
setLogger(Logger logger)
Set output destination for error messages (default is System.err)
|
void |
setMaximumNumberOfWarnings(int max)
Set the maximum number of warnings that are reported; further warnings after this limit
are silently ignored
|
void |
setRecoveryPolicy(int policy)
Set the recovery policy
|
void |
warning(javax.xml.transform.TransformerException exception)
Receive notification of a warning.
|
static java.lang.String |
wordWrap(java.lang.String message)
Wordwrap an error message into lines of 72 characters or less (if possible)
|
protected transient Logger logger
public StandardErrorListener()
public StandardErrorListener makeAnother(int hostLanguage)
hostLanguage
- the host language (not used by this implementation)public void setLogger(Logger logger)
logger
- The Logger to use for error messagespublic Logger getLogger()
public void setRecoveryPolicy(int policy)
policy
- the recovery policy for XSLT recoverable errors. One of
Configuration.RECOVER_SILENTLY
,
Configuration.RECOVER_WITH_WARNINGS
,
Configuration.DO_NOT_RECOVER
.public int getRecoveryPolicy()
Configuration.RECOVER_SILENTLY
,
Configuration.RECOVER_WITH_WARNINGS
,
Configuration.DO_NOT_RECOVER
.public void setMaximumNumberOfWarnings(int max)
max
- the maximum number of warnings outputpublic int getMaximumNumberOfWarnings()
public void warning(javax.xml.transform.TransformerException exception)
Transformers can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action.
After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.
warning
in interface javax.xml.transform.ErrorListener
warning
in interface UnfailingErrorListener
exception
- The warning information encapsulated in a
transformer exception.TransformerException
public void error(javax.xml.transform.TransformerException exception)
The transformer must continue to provide normal parsing events after invoking this method. It should still be possible for the application to process the document through to the end.
The action of the standard error listener depends on the recovery policy that has been set, which may be one of RECOVER_SILENTLY, RECOVER_WITH_WARNING, or DO_NOT_RECOVER
error
in interface javax.xml.transform.ErrorListener
error
in interface UnfailingErrorListener
exception
- The error information encapsulated in a
transformer exception.TransformerException
public void fatalError(javax.xml.transform.TransformerException exception)
The application must assume that the transformation cannot continue after the Transformer has invoked this method, and should continue (if at all) only to collect addition error messages. In fact, Transformers are free to stop reporting events once this method has been invoked.
fatalError
in interface javax.xml.transform.ErrorListener
fatalError
in interface UnfailingErrorListener
exception
- The error information encapsulated in a
transformer exception.public static java.lang.String getOffenderListText(ValidationFailure failure)
protected void outputStackTrace(Logger out, XPathContext context)
out
- the destination for the stack tracecontext
- the context (which holds the information to be output)public java.lang.String getLocationMessage(javax.xml.transform.TransformerException err)
err
- the exception containing the location informationpublic static java.lang.String getLocationMessageText(javax.xml.transform.SourceLocator loc)
public static java.lang.String abbreviatePath(java.lang.String uri)
uri
- the URI to be abbreviatedpublic java.lang.String getExpandedMessage(javax.xml.transform.TransformerException err)
err
- the exception containing the required informationpublic java.lang.String getErrorObjectString(Sequence errorObject)
errorObject
- the error object passed as the last argument to fn:error. Note: this method is
not called if the error object is absent/nullpublic static java.lang.String getInstructionName(Instruction inst)
inst
- the provider of informationpublic static java.lang.String wordWrap(java.lang.String message)
message
- the message to be word-wrappedpublic static void printStackTrace(Logger out, XPathContext context)
out
- the print stream to which the stack trace will be outputcontext
- the XPath dynamic execution context (which holds the head of a linked
list of context objects, representing the execution stack)Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.