Subject: Re: [xsl] Looping over characters in a string From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 10 May 2001 09:14:24 +0100 |
Hi Theodore, > Is it possible to loop over characters in a string? Jarno's shown you two ways of doing it using an increasing index. The third way is to use a recursive template that walks over the string, removing the first character from the string with each recursion. For example: <xsl:template name="add-X"> <xsl:param name="string" select="." /> <xsl:if test="$string"> <xsl:text>X</xsl:text> <xsl:call-template name="add-X"> <xsl:with-param name="string" select="substring($string, 2)" /> </xsl:call-template> </xsl:if> </xsl:template> How exactly you use this template depends on where you are to start with. For example, you could use it in the template matching the tag element (the advantage of this is that it means you don't have to pass a parameter to the template, as I've set the default for the $string parameter to be the string value of the current node). <xsl:template match="tag"> <xsl:call-template name="add-X" /> <xsl:value-of select="." /> </xsl:template> No ASCII art I'm afraid. Hope that helps anyway, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Looping over characters i, Jarno Elovirta | Thread | RE: [xsl] Looping over characters i, Michael Kay |
Re: [xsl] RE: parameter entity in D, Ingo Schildmann | Date | Re: [xsl] XSLT Generators / xsl:for, Jeni Tennison |
Month |