Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tokenize() with multiple delimeters

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
Hi,

Does anyone know how to specifiy multiple delimeters in the XSLT 2 function tokenize() ?

This works for one delimeter :

Code:
<xsl:variable name="siteAddress" select="tokenize(., ',')"/>

But I cannot seem to get it to delimit with more than one delim ... anyone have an idea of how I can ?

Thanks for any help

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
It is my understanding that it acts like split. Take for instance and imaginary case supposedly under the context node.
[tt] <xsl:variable name="s" select="." />[/tt]
gives s something like this symbolically.
[tt] $s="10.10.200.10,20.20.100.20,30.30.210.40"[/tt]
Naturally asking for splitting "," then ".".

Suppose an xsl script block like this.
[tt]
<xsl:variable name="siteAddress" select="$s,','" />
<xsl:for-each select="$siteAddress">
<xsl:text>{</xsl:text>
<xsl:variable name="component" select="." />
<xsl:for-each select="$component">
<xsl:text>[</xsl:text>
<xsl:value-of select="." />
<xsl:text>]</xsl:text>
</xsl:for-each>
<xsl:text>}</xsl:text>
</xsl:for-each>
[/tt]
Wouldn't it result in something like this?
[tt] {[10][10][200][10]}{[20][20][100][20]}{[30][30][210][40]}[/tt]
Call each component could be done by, rather than xsl:for-each, directly referring to each sub-component by the function item-at().

I might take a look at this tutorial article.
 
Thanks for the reply tsuji.
I ended up doing the following, as it ties in a bit more easily with what I already have :

Code:
<xsl:variable name="siteAddress" select="tokenize(replace(., '\n', ','), ',')"/>

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Amendment

Forgotten to insert the tokenize function! The corresponding lines should be read like this.
[tt]
<xsl:variable name="siteAddress" select="[red]tokenize([/red]$s,','[red])[/red]" />
<xsl:variable name="component" select="[red]tokenize([/red].[red],'.')[/red]" />
[/tt]
My carelessness!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top