XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:empty

Category:

Functions for sequences

Origin:

XPath 2.0

Return value:

A Boolean value, true or false.

Call/Arguments:

fn:empty($sequence)

$sequence:

An input sequence which is tested in order to determine whether it is the empty sequence.

Purpose of use:

If the input sequence of the function is empty, which means it contains no items, the function returns the Boolean value true. In all other cases, the function returns false.

Alternatives to fn:empty():
The behaviour of fn:empty($sequence) corresponds, as long as the sequence is empty, to the behaviour of fn:not($sequence). In this case, both functions return the value true. However, if the tested sequence consists of a single item which is of xs:boolean type and has the value false, fn:empty($sequence) returns the value false (since the sequence is not empty), whereas fn:not($sequence) returns the value true (as negation to false). Therefore, the use of fn:empty() is the save method in order to reliably test for the empty sequence. An actually working synonym would be fn:count($sequence)=0.

Example 1 – testing a non-empty sequence:

fn:empty(('bla')) returns false.

Example 2 – testing an empty sequence:

fn:empty(()) returns true.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:empty($srcval as item()*) as xs:boolean

   

<< 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