XPath/XQuery remove function

Summary

Returns a new sequence containing all the items of $target except the item at position $position.

Signature

fn:remove(
$target as item()*,
$position as xs:integer
) as item()*

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

The function returns a sequence consisting of all items of $target whose index is less than $position, followed by all items of $target whose index is greater than $position.

Examples

let $abc := ("a", "b", "c")

The expression fn:remove($abc, 0) returns ("a", "b", "c").

The expression fn:remove($abc, 1) returns ("b", "c").

The expression fn:remove($abc, 6) returns ("a", "b", "c").

The expression fn:remove((), 3) returns ().

Notes

If $position is less than 1 or greater than the number of items in $target, $target is returned.

If $target is the empty sequence, the empty sequence is returned.