home contribute faq download

FunctX XSLT Functions

fn:count

The number of items in a sequence

Google
Webxsltfunctions.com

Description

The fn:count function returns the number of items in a sequence, as an xs:integer.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$arg item()* the sequence of items to count
return value xs:integer

Examples

<xsl:variable name="ordDoc" select="doc('http://www.functx.com/input/order.xml')"/>
XSLT ExampleResults
count( (1, 2, 3) )
3
count($ordDoc//item)
6
count(
   distinct-values($ordDoc//item/@num))
4
count( (1, 2, 3, () ) )
3
count( () )
0

See Also

fn:sumThe sum of values in a sequence

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley