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

Re: string split

Subject: Re: string split
From: Mike Berrow <mberrow@xxxxxxxxxx>
Date: Tue, 19 Sep 2000 08:06:32 -0700
michael berrow
For
<doc>
<elem>5,6,7</elem>
</doc>

I have the following
=======================
  <xsl:template match="/">
    <xsl:apply-templates select="/doc/elem"/>
  </xsl:template>

  <xsl:template match="elem">
    <xsl:param name="csv" select="."/>
    <xsl:variable name="wlist"
select="concat(normalize-space(translate($csv,',',' ')),' ')"/>
    <xsl:variable name="first">
      <xsl:if test="$csv!=' '">
        <xsl:value-of select="substring-before($wlist, ' ')"/>
      </xsl:if>
    </xsl:variable>
    <a>
      <xsl:attribute name="href">
        <xsl:value-of select="concat('#id',$first)" />
      </xsl:attribute>
      <xsl:value-of select="$first" />
    </a>
    <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
    <xsl:variable name="rest" select="substring-after($wlist, ' ')"/>
    <xsl:if test="$rest">
      <xsl:apply-templates select=".">
        <xsl:with-param name="csv" select="$rest"/>
      </xsl:apply-templates>
    </xsl:if>
  </xsl:template>
=======================

Producing
<a href="#id5">5</a>&nbsp;<a href="#id6">6</a>&nbsp;<a
href="#id7">7</a>&nbsp;

There is probably a leaner way. Anyone?

-- Mike Berrow
-- Lexica




 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.