EXSLT - str:tokenize

Implementer Page: str.tokenize.html
Function Package: str.tokenize.zip

Function Syntax

node-set str:tokenize(string, string?)

Template Syntax

<xsl:call-template name="str:tokenize">
   <xsl:with-param name="string" select="string" />
   <xsl:with-param name="delimiters" select="string" />?

The str:tokenize function splits up a string and returns a node set of token elements, each containing one token from the string.

The first argument is the string to be tokenized. The second argument is a string consisting of a number of characters. Each character in this string is taken as a delimiting character. The string given by the first argument is split at any occurrence of any of these characters. For example:

str:tokenize('2001-06-03T11:40:23', '-T:')      

Gives the node set consisting of:


If the second argument is omitted, the default is the string '&#x9;&#xA;&#xD;&#x20;' (i.e. whitespace characters). Thus:

str:tokenize('date math str')      

Gives the node set consisting of:


If the second argument is an empty string, the function returns a set of token elements, each of which holds a single character. Thus:

str:tokenize('foo', '')          

Gives the node set consisting of:


The template version of this function returns a result tree fragment consisting of a number of token elements.


The following XSLT processors support str:tokenize:

Implementations of str:tokenize are available in the following languages:



The following example shows how to use the str:tokenize function:


   <c>Is this EXSLT? No. no</c>


<xsl:template match="a">
   <xsl:apply-templates />
<xsl:template match="*">
   <xsl:value-of select="." />
      <xsl:value-of select="str:tokenize(string(.), ' ')" />
   <xsl:value-of select="str:tokenize(string(.), '')" />
   <xsl:for-each select="str:tokenize(string(.), ' ')">
      <xsl:value-of select="." />
   <xsl:apply-templates select="*" />

http://www.exslt.org/str/functions/tokenize/index.html last modified 2002-11-12