xf:count

Counts the number items in the sequence.

Signatures

xf:count(item* $item-var) —> xs:unsignedInt

Arguments

Data Type
Argument
Description

item*

$item-var

Represents the sequence to be counted.

Returns

Returns the number of items in a sequence passed into $item-var as an unsignedInt value.

Returns 0 if $item-var is the empty sequence. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Examples

Simple

Invoking count(("a","b","c")) returns the unsigned integer value of 3, as shown in the following example query:

<result>{xf:count(("a","b","c"))}</result> 

The preceding query generates the following result:

<result>3</result> 

Empty Sequence

Invoking count(()) returns the unsigned integer value of 0 because () is an empty sequence (contains no elements), as shown in the following example query:

<result>{xf:count(())}</result> 

The preceding query generates the following result:

<result>0</result> 

Related Topics

W3C count function description.