[Home] [By Thread] [By Date] [Recent Entries]
Taly wrote:
I am using version 1.0 thats the problem.I saw a samplw in the web but didn't work for me: http://www.dpawson.co.uk/xsl/sect2/break.html#d3080e76 perhaps I donno ow to use call-template the way I should It is not possible to guess where your attempts failed. You will need to show us your XML input and your stylesheet trying to process that. Perhaps this example helps, the XML is <root> <foo>Line 1 Line 2 Line 3</foo> </root> the stylesheet, incorporating the template from the FAQ looks as follows: <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output method="html" indent="yes"/> <xsl:template match="/root">
<html>
<head>
<title>Example</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template><xsl:template name="substitute">
<xsl:param name="string" />
<xsl:param name="from" select="'
'" />
<xsl:param name="to">
<br />
</xsl:param>
<xsl:choose>
<xsl:when test="contains($string, $from)">
<xsl:value-of select="substring-before($string, $from)" />
<xsl:copy-of select="$to" />
<xsl:call-template name="substitute">
<xsl:with-param name="string"
select="substring-after($string, $from)" />
<xsl:with-param name="from" select="$from" />
<xsl:with-param name="to" select="$to" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template> <xsl:template match="foo">
<div>
<xsl:call-template name="substitute">
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</div>
</xsl:template></xsl:stylesheet> the result then is <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Example</title> </head> <body> <div>Line 1<br>Line 2<br>Line 3
</div></body> </html> -- Martin Honnen http://JavaScript.FAQTs.com/
|

Cart



