This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Xslt string operation: Split



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>&nbsp;<a href="#id6">6</a>&nbsp;<a
>href="#id7">7</a>&nbsp;-->


 <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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]