External

Certain types of application, such as XML editors, use the approach of embedding a web-browser within a host application implemented in a non-JavaScript language.

In such cases, the host application uses a bridge to allow a two-way interface between the JavaScript language and the host-application's own language and object model. The standard method to make calls to the host applicaton from the browser is through the window.external object. If the external object exists, Saxon-CE checks for the existence of the saxonErrorHandler function. If found, all 'publish' calls by the Saxon-CE logger are directed to this function, overriding any JavaScript errorhandlers set via the API.

The signature for the external function is:

saxonErrorHandler($message, $level)

The message argument is the log text, whilst the level argument holds the level at which the message was logged, for example, SEVERE is used for all unrecoverable errors.

Saxon-CE exstablishes whether this external function exists by calling it directly, the 'bridge' therefore does not need to provide a standard JavaScript object stack (such as implementing apply and call) to support the function - just the function itself.

This first 'test call' includes the Saxon-CE version details in the message argument. The level INIT is used to distinguish this from following messages.

Output logged via this function might be exploited in a number of ways; typical usage would be for an XSLT editor with a built-in browser to host Saxon-CE so that external output is exploited for interactive use (e.g. selecting a logged compile-error will highlight the relevant XSLT part). An early example of this can be found in a version of Qutoric's XMLQuire editor that was extended for Saxon-CE.

For further details, see the Logging and Tracing sections