saxon:items-until

Returns the subsequence of the input ending with the first item that matches the predicate.

items-until($input as item()*, $predicate as function(item()) as xs:boolean) ➔ item()*

Arguments

 

$input

item()*

The input sequence

 

$predicate

function(item()) as xs:boolean

Function determining the end condition

Result

item()*

Namespace

http://saxon.sf.net/

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 10.

Notes on the Saxon implementation

Available from Saxon 10.

Details

This function returns a contiguous subsequence of the input sequence, starting at the first item in the input, and ending with the first item that matches the $predicate condition.

If no item in the input sequence matches the $predicate condition, the entire input sequence is returned.

If the first item in the input sequence matches the $predicate condition, the result contains that single item.

Example: saxon:items-until(1 to 20, function($x){$x mod 10 = 0}) returns the sequence 1 to 10.

In XSLT, calls on saxon:items-until are streamable provided that the function supplied as the predicate is either (a) a reference to a user-declared stylesheet function declared with streamability="inspection", or (b) an inline function whose body is grounded and motionless. More specifically, if the predicate function satisfies these conditions then the posture and sweep of the function call are the same as the posture and sweep of the first argument. Where possible, reading and parsing of the source document will be abandoned when an item matching the predicate is encountered.

See also:

saxon:items-before()

saxon:leading()

saxon:items-after()

saxon:items-from()