Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Table of Contents

Search

  1. Preface
  2. Understanding Data Types and Field Properties
  3. Designing Processes
  4. Using and Displaying Data
  5. Designing Guides
  6. Designing Process Objects
  7. Designing Service Connectors
  8. Using App Connections
  9. System Services, Listeners and Connectors
  10. Designing Human Tasks

Design

Design

count

count

The count function in XQuery is used to determine the number of items in a sequence.

Syntax

fn:count(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The sequence of items to count.

Return Value

  • The function returns an
    xs:integer
    representing the number of items in the sequence.
  • The
    count()
    function operates on sequences, including numbers, strings, and XML nodes.
  • If the input sequence is empty, it returns
    0
    .
  • If all values passed to this function are NULL, it returns 0.
  • It does not count individual characters within a string, only top-level sequence items.

Examples

If you have an XML document containing a list of books and you want to count how many books are listed:
<library> <book>Book A</book> <book>Book B</book> <book>Book C</book> </library>
Use the following XQuery:
let $books := doc("library.xml")/library/book return fn:count($books)
The output is
3
.
The following table lists some additional sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:count( (1, 2, 3) )
3
fn:count( (1, 2, 3, () ) )
3
fn:count( (1, 2, 3, 1, 2 ) )
5
fn:count( () )
0

0 COMMENTS

We’d like to hear from you!