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

Re: to access a particular token in a comma separated

Subject: Re: to access a particular token in a comma separated string by specifying a numerical value ?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Tue, 27 Jan 2004 06:44:57 +0100
access split
Use the "str-split-to-words" template from FXSL.

There are numerous examples of using this template in the archives of
xsl-list. See an early example here:

http://sources.redhat.com/ml/xsl-list/2001-11/msg00901.html

In your case this transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:ext="http://exslt.org/common"
>

   <xsl:import href="strSplit-to-Words.xsl"/>

   <xsl:output indent="yes" omit-xml-declaration="yes"/>

    <xsl:template match="/">
      <xsl:call-template name="str-split-to-words">
        <xsl:with-param name="pStr" select="/"/>
        <xsl:with-param name="pDelimiters"
                        select="', &#9;&#10;&#13;'"/>
      </xsl:call-template>
    </xsl:template>
</xsl:stylesheet>

when applied on this source.xml:

<t>10, 20,  30,40,   50</t>

produces:

<word>10</word>
<word>20</word>
<word>30</word>
<word>40</word>
<word>50</word>

Note that a delimiter may be anyone from a string of characters -- thus you
could delimit some of your yokens with a coma, with a coma and spaces, with
a semicolon or with whatever you need, and some other tokens with something
else.


Cheers,

Dimitre Novatchev.
FXSL developer,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx> wrote in message
news:24B68DDCFD49004882CD8D02D2E4338AFFC043@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How can I access a particular token in a comma separated string by
specifying a numerical value for the token number using XSL?

Assuming, my xsl:variable or xsl:parameter holds a string with
comma-separated values as shown below:

<xsl:variable name="ValuesString" select="'10,20,30,40,50'"/>

How would I go about finding a way to pick out the value specified by a
count that maps another variable/parameter.

Open to Ideas :)
Thanks,

Abhishek
____________________________________________________________

Abhishek Sanwal
HP - Houston Campus

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.