RE: string split

Subject: RE: string split
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Tue, 19 Sep 2000 14:52:25 +0100
> bash$ sed -e "s@\\([0-9]\\)\\,*@<a 
> href='#id\\1'>\\1</a>\\&nspb;@g" dp5.xml 
> <doc>
> <elem><a href='#id5'>5</a>&nspb;<a href='#id6'>6</a>&nspb;<a 
> href='#id7'>7</a>&nspb;</elem>
> </doc>

I've never seen modem noise on email before!


Jarno Elovirta and Don Bruey both provided an answer off-list,
which had a far better signal to noise ratio.

I had 'forgotten' that I can output content from the named
template :-| I was trying to collect it into a variable in
the calling template. Live and learn.

DaveP

Jarno's solution:

<xsl:template match="doc/elem">
<body>
  <xsl:call-template name="links">
    <xsl:with-param name="str" select="."/>
  </xsl:call-template>
  </body>
</xsl:template>

<xsl:template name="links">
  <xsl:param name="str"/>
  <xsl:choose>
    <xsl:when test="contains($str,',')">
      <a href="#id{substring-before($str,',')}"><xsl:value-of
select="substring-before($str,',')"/></a>
      <xsl:text>&#xA0;</xsl:text>
      <xsl:call-template name="links">
        <xsl:with-param name="str" select="substring-after($str,',')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <a href="#id{$str}"><xsl:value-of select="$str"/></a>
      <xsl:text>&#xA0;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


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


Current Thread