XSLT and XPath function reference in alphabetical order
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)
Functions for sequences
A sequence; the copy of the input sequence from which the item indicated by the index position passed on was removed.
A sequence of any number of items of any type which shall be copied and from which the item indicated shall be removed for the output sequence. The input sequence may be empty.
Obligatory. A xs:integer integer which indicates the index position of that item of the input sequence which shall be removed by the function. If the value passed on is less than 1 or greater than the number of items in the input sequence, the input sequence is returned unchanged.
Purpose of use:
The fn:remove() function copies an input sequence and returns it after an item indicated by the index position passed on was removed from it. If the empty sequence is passed on to the function, it returns the empty sequence.
The function accepts any (in principle also absurd) xs:integer integers as index indication for the item to be removed. Therefore, an item does not necessarily have to exist at the index position passed on. An error message does not occur because of an unusable index argument.
If an item exists in the input sequence at the indicated index position, it will be removed. If this is not the case, because the position indication passed on is less than 1 or greater than the length of the input sequence, the input sequence is copied unchanged and returned.
Example 1 – removing one item from a sequence:
fn:remove(('a', 'b', 'c', 'd', 'e'), 3)
results in ('a', 'b', 'd', 'e'). The third item 'c' is removed from the input sequence, the remaining items are returned as output sequence.
Example 2 – passing on a too high index indication:
fn:remove(('a', 'b', 'c', 'd'), 5)
results in ('a', 'b', 'c', 'd'). Because no fifth item exists, the sequence is only copied and returned unchanged. No error message is outputted.
Example 3 – passing on index 0:
fn:remove(('a', 'b', 'c', 'd'), 0)
results in ('a', 'b', 'c', 'd'). Because the index indication is less than 1, the input sequence again remains unchanged. No error message occurs.
The function is not available.
fn:remove($target as item()*,
$position as xs:integer) as item()*
|<< back||next >>|
Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany