API

com.ibm.xml.xapi
Interface XMessageHandler


public interface XMessageHandler

Implement this class to override the default error and message handling behaviour. The default behaviour is to print the message to System.err and to also throw an XProcessException for fatal errors.

The default behaviour can be overridden in general by setting the message handler on the XFactory instance. This will affect errors and messages that occur while processing schemas (XFactory.registerSchema), processing source files (XItemFactory.item(Source)) as well as for errors and messages that occur when preparing or executing expressions, queries or stylesheets (XFactory.prepare, XExecutable.execute). The message handling behaviour can also be overridden for individual prepare invocations by setting the message handler on the XStaticContext as well as for individual execute invocations by setting the message handler on the XDynamicContext. Message handlers set on the XStaticContext or XDynamicContext will take precedence over a message handler set on the XFactory.

See Also:
XFactory.setMessageHandler(XMessageHandler), XStaticContext.setMessageHandler(XMessageHandler), XDynamicContext.setMessageHandler(XMessageHandler)

Nested Class Summary
static class XMessageHandler.MsgType
          Enumerator of message error levels.
 
Method Summary
 void report(XMessageHandler.MsgType level, String message, XSourceLocation location, Throwable cause, XSequenceCursor errorItems)
          This method will be called when an info, warning or error condition occurs.
 

Method Detail

report

void report(XMessageHandler.MsgType level,
            String message,
            XSourceLocation location,
            Throwable cause,
            XSequenceCursor errorItems)
This method will be called when an info, warning or error condition occurs. It is also called for the XPath fn:trace and fn:error functions as well as the XSLT xsl:message instruction.

Parameters:
level - One of INFO, WARNING, ERROR, FATAL_ERROR, or TRACE.
message - The message string. For the XPath fn:trace function this is a string formed from the label and the value parameters. For the XPath fn:error function this is a string formed from the error and the description parameters.
location - The location where the error occurred. May be null if the location is not available.
cause - The error that was thrown or null. A cause will be included if a component that the processor depends on, such as the XML parser threw an error.
errorItems - The error objects specified in a call to the XPath fn:error function as an XSequenceCursor.

IBM Copyright 2004-2008