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

spliting a string

Subject: spliting a string
From: 04083259@xxxxxxxxxxxxx
Date: Fri, 1 Apr 2005 12:32:07 +0100 (BST)
xsl string tokenizer
hi

i have the following template which splits a string to tokens elements
when ever a delimiter occurs  :

<xsl:template name="tokenizer">
  <xsl:param name="string" />
  <xsl:param name="delimiter" select="' '" />
  <xsl:choose>
   <xsl:when test="$delimiter and contains($string, $delimiter)">
           <token>  <xsl:value-of
select="substring-before($string,$delimiter)" /> </token>
           <xsl:call-template name="tokenizer">
           <xsl:with-param name="string"
select="substring-after($string,$delimiter)" />
           <xsl:with-param name="delimiter"     select="$delimiter" />
           </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <token>  <xsl:value-of select="$string" /></token>
    </xsl:otherwise>
 </xsl:choose>
 </xsl:template>



if we run the above template over the following string :

i have 22xxxxx+10  elements in my database+10yyyyyy  attribute for each

 we get the following result:

<token>i</token>
<token>have</token>
<token>22xxxxx+10</token>
<token>elements</token>
<token>in</token>
<token>my</token>
<token>database+10yyyyyy</token>
<token>attribute</token>
<token>for</token>
<token>each</token>

i am trying to  split the string further   where it finds the ( +) and
where it finds (xxxxx) and where it finds (yyyyy)

so a substring which has a (+)  has to return with the substring just
after it as one token element
so the result that i am struggling to achieve is the following  :

<token>i</token>
<token>have</token>
<token>22</token>

<token>xxxxx</token>
<token>+10</token>

<token>elements</token>
<token>in</token>
<token>my</token>
<token>database+10</token>

<token>+10</token>
<token>yyyyyy</token>

<token>attribute</token>
<token>for</token>
<token>each</token>

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.