Extension functions

Saxon-CE defines a number of functions in the namespace http://saxonica.com/ns/interactiveXSLT, conventional prefix ixsl.




Returns the document node of the HTML DOM document. The result is both a node and a JavaScript object. So, for example, the title of the current document is accessible as ixsl:page()/html/head/title. Similarly, the contents of an element with id="title" can be retrieved as string(id('title', ixsl:page())). All HTML elements and attributes are considered to have lower-case names as far as XPath is concerned. The names will be in no namespace.


Returns the document node of the source XML document. Useful for retrieving the source document from within a user-event template as the context item wll be that of the host HTML page.


Returns the Window object. This is a JavaScript object: it is possible to get its properties using ixsl:get and to call its methods using ixsl:call.


Returns the current Event object while processing a user input event (or the empty sequence otherwise). This is a JavaScript object: it is possible to get its properties using ixsl:get and to call its methods using ixsl:call.

ixsl:get( $object, $property )

Gets a property of a JavaScript object (which may be an object returned by another extension function, or a node in the HTML DOM). The $object argument identifies the object, the $property is the name of the required property as a string. Note that properties of element nodes may also be obtained as pseudo-attributes, for example $checkbox/@prop:checked returns the value of the checked property, where prop is bound to the namespace http://saxonica.com/ns/html-property. The value of a nested property can be obtained by using dot separator characters within name - for example, location.hash to get the hash property of the location property of the window object.

ixsl:call( $object, $method, $arguments... )

Calls a JavaScript function. The first argument is the object on which the function is defined (use ixsl:window() to call a global function). The second argument is the function name. The third and subsequent arguments are the actual arguments to the function. The result of calling the function is returned as the result of ixsl:call().


Executes Javascript code, supplied as a string. The supplied script is injected into the DOM as a function which is evaluated immediately to return a result. This ensures access to the global scope. Repeated evaluations can be acheived more efficiently by calling ixsl:eval once to create a function, and then using ixsl:call subsequently to call that function as often as required.

Global JavaScript functions (those belonging to the global Window object) can also be called directly. For example if a function has been declared as <script type="text/javascript" language="javascript"> function square(x) { return String(x*x) }</script> then it can be called from within an XPath expression as js:square('5') where js is bound to the namespace http://saxonica.com/ns/globalJS.