setErrorHandler
setErrorHandler($handler as Function) →
Sets a callback function to allow your own code to manage events and errors occurring in the XSLT20Processor object.
Arguments |
|||
|
$handler |
Function |
The function to which callbacks will be made on events or errors |
Result |
Details
The error and event handling capability this callback provides is for use with the Debug variant of Saxon only. The threshold for this callback is controlled by the Logging setLogLevel method, or a URI argument - see the Logging section for further details.
The $handler
function argument signature should hava a
single error
argument. The error
object which is
passed in the callback can then be used to get details on the error or
event. It has 3 properties: message
, level
and
time
. If no error handler is set, any JavaScript or XSLT
exceptions are thrown so that your code can manage them.
Sample JavaScript code:
var errors = new Array(); function doPageUpdate() { errors = new Array(); // ------ SET ERROR HANDLER -------- Saxon.setErrorHandler(handler); Saxon.setLogLevel("FINE"); (...) // update the HTML page var result = proc.updateHTMLDocument(xml); // show a window alert listing any compile-time or run-time errors if (errors.length > 0) { window.alert(errors.toString()); } } // ------ DECLARE ERROR HANDLER -------- function handler(saxonError) { errors.push(saxonError.message + " " + saxonError.level + " " + saxonError.time); }