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 input sequence provided that it consists of at least one item.
An input sequence of, in principle, any number of items. However, the sequence is rejected by the function if it does not contain at least one item. Therefore, in the case of the empty sequence an error is reported. This corresponds to the testing of the input sequence for cardinality »+«, which means »one or more« items.
Purpose of use:
The function enforces the output of a sequence of at least one item by rejecting the empty sequence. In this case the output is aborted with the error message »fn:one-or-more called with a sequence containing no items« (err:FORG0004). Whereas sequences of one or more items are passed on unchanged (transparently) by the function.
The function should be used wherever the empty sequence must be prevented as input value and the abort of the processing is required in case this condition is not met.
Example 1 – call with more than one item in the input sequence:
fn:one-or-more((1, 2, 3))
returns the sequence passed on (1, 2, 3).
Example 2 – call with exactly one item in the input sequence:
fn: one-or-more ((1))
returns the sequence passed on (1).
Example 3 – call with the empty sequence:
fn: one-or-more (())
aborts with an error message according to err:FORG0004.
The function is not available.
fn:one-or-more($arg as item()*) 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