XML technologies / XSLT / XSLT and XPath functions / Alphabetical XSLT and XPath reference / exists

(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:exists

Category:

Functions for sequences

Origin:

XPath 2.0

Return value:

A Boolean value false, in case the input sequence is empty, otherwise always true.

Call/Arguments:

fn:exists($sequence)

$sequence:

Any input sequence. If the sequence is empty, the function returns the value false, otherwise true.

Purpose of use:

As long as the input sequence passed on is a non-empty sequence, the fn:exists() function always returns true. If the sequence is empty, thus there is no item (the sequence »itself« or an expression generating the sequence indeed exists!), the value false is returned. In principle, fn:exists($value) is equivalent to fn:count($value) = 0 or (provided that $value is not of all things the Boolean value false) also to fn:not($value).

Example 1 – testing a non-empty sequence:

fn:exists((1, 2, 3)) results in true.

Example 2 – testing an empty sequence:

fn:exists(()) results in false.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:exists($arg as item()*) as xs:boolean

   

 

 

 

back to top