Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] spliting a string

From: 04083259@-------------
To:
Date: 4/1/2005 11:33:00 AM
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>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent