saxon:leading

Returns the items in a sequence up to a selected item.

leading($input as item()*) ➔ item()

Arguments

 

$input

item()*

The input sequence

Result

item()

leading($input as item()*, $test as function(*)) ➔ item()

Arguments

 

$input

item()*

The input sequence

 

$test

function(*)

Function determining where the sequence should terminate

Result

item()

Namespace

http://saxon.sf.net/

Notes on the Saxon implementation

Available since before Saxon 8.0. Changed in Saxon 9.5 to take a function rather than an expression as the second argument.

Details

This function returns a sequence containing all those nodes from $input up to and excluding the first one (in order of the input sequence) for which $test has an effective boolean value of false.

The $test argument defaults to the function fn:data#1, that is, it atomizes the item.

The $test function is evaluated for each item in $input in turn, with that item supplied as the argument to the function. The result consists of that leading sequence of items for which the effective boolean value of the function is true.

For example:

saxon:leading(following-sibling::*, function($x){$x/self::para})

where the supplied function tests whether the supplied item is a <para> element.

This will return the <para> elements following the current node, stopping at the first element that is not a <para>.

Note: this function is quite different from the EXSLT leading() function, though both fulfil a similar purpose.