|
Subject: Re: [xsl] Fwd: xml/xslt line break From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Sun, 20 Jul 2008 13:32:59 +0200 |
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
<root> <foo>Line 1 Line 2 Line 3</foo> </root>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <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><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/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Fwd: xml/xslt line break, Taly | Thread | Re: [xsl] Fwd: xml/xslt line break, Taly |
| Re: [xsl] Fwd: xml/xslt line break, Taly | Date | Re: [xsl] Fwd: xml/xslt line break, Taly |
| Month |