fn:count function

The fn:count function returns the number of values in a sequence.

Syntax

Read syntax diagramSkip visual syntax diagramfn:count( sequence-expression)
sequence-expression
A sequence that contains items of any atomic type, or an empty sequence.

Returned value

If sequence-expression is not the empty sequence, an xs:integer value that is the number of values in sequence-expression is returned. If sequence-expression is the empty sequence, 0 is returned.

Example

The following function returns 1:
fn:count(5) 
The following function returns the number of employees with a department ID of K55:
fn:count(//company/emp[dept/@id="K55"])