saxon:do

The saxon:do instruction is designed for use when invoking XPath expressions that have side-effects. Any result of the expression is discarded.

Category: instruction
Content: none
Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element

Attributes

action

expression

The expression to be evaluated (typically an expression with side-effects).

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.9. Available for all platforms.

Details

The instruction is designed for use when invoking XPath expressions that have side-effects. For example, <saxon:do action="$connection?close()"/> calls the function $connection?close(), while <saxon:do action="saxon:discard-document($doc)"/> calls saxon:discard-document(). Any result of the expression is discarded. The instruction is useful in preference to xsl:sequence firstly because the result of the expression is discarded, and secondly because it is recognized by the optimizer as signaling an expression that is being evaluated for its side-effects. The optimizer will attempt to avoid aggressive optimizations such as lifting the instruction out of an xsl:for-each loop. Note however that this does not propagate; just because a function F calls saxon:do, for example, does not prevent calls on F being moved out of a loop.