saxon:items-before
Returns the subsequence of the input ending with the item before the first item that matches the predicate.
items-before($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 item immediately before the first one 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 is an empty sequence.
Example: saxon:items-before(1 to 20, function($x){$x mod 10 = 0})
returns the sequence 1 to 9
.
In XSLT, calls on saxon:items-before
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.
Example: /*/emp => saxon:items-from(function($e){$e/@dept='sales'} =>
saxon:items-before(function($e){$e/@dept='QA'}