Saxonica: XSLT and XQuery Processing: Handling user input events

Handling user input events

A key aim of Saxon-CE is that it should be possible to implement a high quality interactive user interface without dropping down into JavaScript.

Event handlers for user input are written in the form of template rules. The match pattern of the template rule must match the element that receives the event, and the mode name reflects the type of event, for example ixsl:onclick. This causes a new transformation to take place, using the existing stylesheet, which is initiated with the target element in the HTML DOM as the initial context item.

Of course, CSS can be used in the usual way to control changes in appearance in response to mouse movement and the like. It is also possible to handle some events using JavaScript and some using XSLT. Saxon-CE sets the event listener on the document object. On receiving an event notification, the processor checks for matching template rules on the target element and then on ancestors of the target element (provision is also made for events on linked SVG elements).

While an event is being processed, the function ixsl:event() can be called to return the Event object; its properties and methods are available via the ixsl:get() and ixsl:call() functions.