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
.
XFactory.setMessageHandler(XMessageHandler)
,
XStaticContext.setMessageHandler(XMessageHandler)
,
XDynamicContext.setMessageHandler(XMessageHandler)
Nested Class Summary
Modifier and Type | Interface and Description |
---|---|
|
XMessageHandler.MsgType
Enumerator of message error levels.
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
report(XMessageHandler.MsgType level,java.lang.String message,XSourceLocation location,java.lang.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,
- java.lang.String message,
- XSourceLocation location,
- java.lang.Throwable cause,
- XSequenceCursor errorItems)
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
.
fn:trace
andfn:error
functions as well as the XSLTxsl:message
instruction.