[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Looping over characters in a string
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|