xf:string-length

Counts the length of $string-var.

If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:string-length(xs:string? $string-var) —> xs:integer?

Arguments

Data Type
Argument
Description

xs:string?

$string-var

Represents the string to count.

Returns

Returns an integer equal to the length of the $string-var.

Examples

Simple

Invoking string-length("moo cow") returns the integer 7, as shown in the following example query:

<result>{xf:string-length("moo cow")}</result> 

The preceding query generates the following result:

<result>7</result> 

Pass in Null

Invoking string-length(()) returns the null string as shown in the following example query:

<result>{xf:string-length(())}</result> 

Note: The string: () is the empty sequence (similar to a SQL null) which is a sequence containing zero items.

The preceding query generates the following result:

<result/> 

Related Topics

W3C string-length function description.