Description
The fn:subsequence function returns a sequence of $length items of $sourceSeq, starting at the position $startingLoc. The first item in the sequence is considered to be at position 1, not 0. If no $length is passed, or if $length is greater than the number of items that can be returned, the function includes items to the end of the sequence. An alternative to calling the fn:subsequence function is using a predicate. For example, fn:subsequence($a,3,4) is equivalent to $a[position() = (3 to 7)].
This description is © Copyright 2007, O'Reilly Media. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return Type| Name | Type | Description |
$sourceSeq |
item()* |
the entire sequence |
$startingLoc |
xs:double |
the starting item position (1-based) |
$length |
xs:double |
the number of items to include |
| return value |
item()* |
Examples| XSLT Example | Results |
|---|
subsequence(
('a', 'b', 'c', 'd', 'e'), 3)
|
('c', 'd', 'e')
|
subsequence(
('a', 'b', 'c', 'd', 'e'), 3, 2)
|
('c', 'd')
|
subsequence(
('a', 'b', 'c', 'd', 'e'), 3, 10)
|
('c', 'd', 'e')
|
subsequence(
('a', 'b', 'c', 'd', 'e'), 10)
|
()
|
subsequence(
('a', 'b', 'c', 'd', 'e'), -2, 5)
|
('a', 'b')
|
subsequence( (), 3)
|
()
|
History |
|