This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Xslt string operation: Split
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Re: Xslt string operation: Split
- From: Cristobal Galiano Fernandez <c dot galiano at ua dot es>
- Date: Thu, 07 Jun 2001 13:04:45 +0200
- Organization: Universidad de Alicante
- References: <003d01c0ef3c$ea22a870$ed353c3e@PCUKMKA>
- Reply-To: xsl-list at lists dot mulberrytech dot com
XSLT split
Non tested.
Cristóbal galiano Fdez
<!-- 2000-09-19. StrSplit.XSL (*Modificar*)
2000-10-10. "Chris Bayes" <Chris@Bayes.co.uk>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-Split
.Servirá como base para realizar el template
-Parámetros
str -> Cadena de trabajo (I)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
>Given
><doc>
><elem>5,6,7</elem>
></doc>
>
>I need an output of
>
><a href="#id5">5</a> <a href="#id6">6</a> <a
>href="#id7">7</a> -->
<xsl:template name="StrSplit">
<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: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:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Michael Kay escribió:
> > is there a way in which is a string passed in as a parameter
> > to the xsl like
> > this
> >
> > "23,45,234,678"
> >
> > sliced up into
> > 23
> > 45
> > 234
> > 678
> >
> > is there any way to do this
>
> You need a recursive template; see the example under "xsl:call-template" in
> Chapter 4 of my XSLT Programmer's Reference.
>
> Mike Kay
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list