Subject: RE: [xsl] String Manipulation in XSL From: "Chris Bayes" <chris@xxxxxxxxxxx> Date: Fri, 26 Oct 2001 18:07:25 +0100 |
Using this xml <?xml version="1.0" ?> <test>http://www.dpawson.co.uk/xsl/sect2/N7240.html#d201e246 </test> And this stylesheet <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/test"> <html> <head></head> <body> <xsl:call-template name="chop"> <xsl:with-param name="txt" select="." /> </xsl:call-template> </body> </html> </xsl:template> <xsl:template name="chop"> <xsl:param name="txt" /> <xsl:choose> <xsl:when test="string-length($txt) > 20"> <xsl:text /><xsl:value-of select="substring($txt, 1, 20)" /><xsl:text> </xsl:text> <xsl:call-template name="chop"> <xsl:with-param name="txt" select="substring($txt, 20)" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text /><xsl:value-of select="$txt" /> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> You should get what you need. Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] String Manipulation in XS, David Carlisle | Thread | [xsl] Re: Dynamic Filter Menus, Dimitre Novatchev |
Re: [xsl] rendering marginal XML, Jay Kline | Date | RE: [xsl] escaping from CDATA, Chris Bayes |
Month |