[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: String Tokenizer in XSLT

Subject: Re: String Tokenizer in XSLT
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Thu, 07 Dec 2006 08:40:29 +1100
tokenize xslt
Depending on your processor, you can use EXSLT. This has this functionality already.

*http://www.exslt.org/str/functions/tokenize/index.html

Xalan and (I think) Saxon both supports tokenize.

eg:

<xsl:for-each select="str:tokenize('1,2,3', ',')">
 <xsl:value-of select="."/><xsl:text>|</xsl:text>
</xsl:for-each>

will give 1|2|3

Don't forget the namespace:

"http://exslt.org/strings"
*
Senthilkumaravelan Krishnanatham wrote:
Hi Vikram,
Thanks for the help. I was struggling about the recursive calling in XSLT.It is real quick eye opener :)



Regards, Senthil On Dec 6, 2006, at 9:25 AM, Dhunta, Vikram (GE, Corporate) wrote:



You could use a tempate defined to split by , and return the elements-

    <xsl:template name="splitByComma">
    <xsl:param name="str"/>
        <xsl:choose>
        <xsl:when test="contains($str,',')">
        'DO SOMETHING WITH THE VALUE IN
{substring-before($str,',')}
            <xsl:value-of
select="substring-before($str,',')"/></option>
        <xsl:call-template name="splitByComma">
        <xsl:with-param name="str"
select="substring-after($str,',')"/>
        </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
        'DO SOMETHING WITH THE VALUE IN {$str}
        </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

You call this by
        <xsl:call-template name="splitByComma">
            <xsl:with-param name="str" select="SM"/>
        </xsl:call-template>

-----Original Message-----
From: Senthilkumaravelan Krishnanatham [mailto:senthil@xxxxxxxxx]
Sent: Wednesday, December 06, 2006 12:19 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  String Tokenizer in XSLT

Hi All,
Is there any function available in XSL to tokenize the string with the
Delimiter?

My XML node looks like
<SM>1,2,3</SM>
I want to split  the text value by delimiting , and process the same.

Thanks,
Senthil




--
Kamal Bhatt

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.