This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: String Manipulation in XSL
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] String Manipulation in XSL
- From: "Chris Bayes" <chris at bayes dot co dot uk>
- Date: Fri, 26 Oct 2001 18:07:25 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
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