fn:filter
Returns those items from the sequence $input for which the supplied function
$predicate returns true.
filter($input as item()*, $predicate as fn(item(), xs:integer) as xs:boolean?) ➔ item()*
Arguments | ||||
| $input | item()* | The sequence to be filtered | |
| $predicate | fn(item(), xs:integer) as xs:boolean? | The filtering function (used to test each item in the sequence) | |
Result | item()* | |||
Namespace
http://www.w3.org/2005/xpath-functions
Links to W3C specifications
XPath 3.1 Functions and Operators
XPath 4.0 Functions and Operators
Saxon availability
Available in XPath 3.0, XSLT 3.0, XQuery 3.0, and later versions. From Saxon 10, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.6. Available for all platforms.
Notes on the Saxon implementation
Available in Saxon 9.3 - 9.5 with altered argument order ($predicate,$input), and
provided XPath 3.0 is enabled.
Saxon 10, unlike the W3C XSLT 3.0 specification, makes fn:filter streamable
under appropriate circumstances. Calls on fn:filter 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.
Available in Saxon-HE from Saxon 10; in Saxon-PE/EE since 9.6.