Description
The functx:word-count function returns the number of words in a string (or node that is atomized). Word boundaries are determined by the definition of "word characters" in Unicode. If $arg is the empty sequence, it returns zero.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the string to measure |
| return value |
xs:integer |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:word-count" as="xs:integer"
xmlns:functx="http://www.functx.com" >
<xsl:param name="arg" as="xs:string?"/>
<xsl:sequence select="
count(tokenize($arg, '\W+')[. != ''])
"/>
</xsl:function>
|
Examples| XSLT Example | Results |
|---|
functx:word-count('hello there world')
|
3
|
functx:word-count(' hello world ')
|
2
|
functx:word-count('a.b.c')
|
3
|
See AlsoHistory |
|