com.saxonica.extra
Class XQueryErrorListener

java.lang.Object
  extended by net.sf.saxon.StandardErrorListener
      extended by com.saxonica.extra.XQueryErrorListener
All Implemented Interfaces:
Serializable, ErrorListener

public class XQueryErrorListener
extends StandardErrorListener

An ErrorListener for use when running schema-aware XQuery. It differs from the standard error listener in that it can produce a stack trace when a run-time error occurs.

See Also:
Serialized Form

Constructor Summary
XQueryErrorListener()
           
 
Method Summary
 void error(TransformerException exception)
          Receive notification of a recoverable error.
 void fatalError(TransformerException exception)
          Receive notification of a non-recoverable error.
 StandardErrorListener makeAnother(int hostLanguage)
          Make a clean ErrorListener.
static void printStackTrace(PrintStream out, XPathContext context)
          Print a stack trace to a specified output destination
 void setProduceStackTrace(boolean doIt)
          Set an option to control whether or not this error listener will produce a stack trace when a run-time error occurs.
 void warning(TransformerException exception)
          Receive notification of a warning.
 
Methods inherited from class net.sf.saxon.StandardErrorListener
getErrorOutput, getExpandedMessage, getLocationMessage, getRecoveryPolicy, setErrorOutput, setRecoveryPolicy
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQueryErrorListener

public XQueryErrorListener()
Method Detail

setProduceStackTrace

public void setProduceStackTrace(boolean doIt)
Set an option to control whether or not this error listener will produce a stack trace when a run-time error occurs. By default, it will produce a stack trace.

Parameters:
doIt - true if a stack trace is to be produced when an error occurs; false if the stack trace is to be suppressed.

warning

public void warning(TransformerException exception)
             throws TransformerException
Receive notification of a warning.

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.

Specified by:
warning in interface ErrorListener
Overrides:
warning in class StandardErrorListener
Parameters:
exception - The warning information encapsulated in a transformer exception.
Throws:
TransformerException - if the application chooses to discontinue the transformation.
See Also:
TransformerException

error

public void error(TransformerException exception)
           throws TransformerException
Receive notification of a recoverable error.

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

Specified by:
error in interface ErrorListener
Overrides:
error in class StandardErrorListener
Parameters:
exception - The error information encapsulated in a transformer exception.
Throws:
TransformerException - if the application chooses to discontinue the transformation.
See Also:
TransformerException

fatalError

public void fatalError(TransformerException exception)
                throws TransformerException
Receive notification of a non-recoverable error.

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.

Specified by:
fatalError in interface ErrorListener
Overrides:
fatalError in class StandardErrorListener
Parameters:
exception - The error information encapsulated in a transformer exception.
Throws:
TransformerException - if the application chooses to discontinue the transformation.
See Also:
TransformerException

printStackTrace

public static void printStackTrace(PrintStream out,
                                   XPathContext context)
Print a stack trace to a specified output destination


makeAnother

public StandardErrorListener makeAnother(int hostLanguage)
Make a clean ErrorListener. This is necessary because the standard error listener is stateful (it remembers how many errors there have been)

Overrides:
makeAnother in class StandardErrorListener
Parameters:
hostLanguage - the host language (not used by this implementation)
Returns:
a copy of this error listener


Copyright (C) Michael H. Kay. All rights reserved.