fn:slice

Returns a sequence containing selected items from a supplied input sequence based on their position.

slice($input as item()*, $start as xs:integer?:=0, $end as xs:integer?:=0, $step as xs:integer?:=0) ➔ item()*

Arguments

 

$input

item()*

The input sequence

 

$start

xs:integer?

:= 0

The position of the first item from the input sequence to be included in the result

 

$end

xs:integer?

:= 0

The position of the last item from the input sequence to be included in the result

 

$step

xs:integer?

:= 0

Step between positions to include in the result

Result

item()*

Namespace

http://www.w3.org/2005/xpath-functions

Links to W3C specifications

XPath 4.0 Functions and Operators

Saxon availability

Available in XPath 4.0, XSLT 4.0, and XQuery 4.0. Requires Saxon-PE or Saxon-EE. Implemented since Saxon 11. Available for all platforms.

Notes on the Saxon implementation

Available since Saxon 13 in XPath 4.0. Available since Saxon 11 provided that syntax extensions are enabled.

Details

Selects items from a sequence. $start and $end can be positive integers for 1-based positions counting from the start of the sequence, or negative integers to count from the end; $step can be a positive integer to select every Nth item, or a negative integer to count backwards.