Subject: [xsl] linefeed to <br/> template From: Flemming Jønsson <flj@xxxxxxxxxxxxx> Date: Tue, 7 Oct 2003 17:10:00 +0200 |
Hi!, I have som XML files from which I need to generate som HTML. Part of my XML is source code (or rather named queries in SQL) and I need to pretty-print these in some HTML tables. I want to replace newlines with a <br/> - I found a template to do just that at www.skew.org/xml (Thanks Mark :)- but I have som problems I hope you can help me weed out. I use Xalan as XSLT processor, in case that changes anything. Here is the template: <xsl:template name="lf2br"> <xsl:param name="StringToTransform"/> <xsl:choose> <xsl:when test="contains($StringToTransform,' ')"> <xsl:value-of select="substring-before($StringToTransform,' ')"/> <br/> <xsl:call-template name="lf2br"> <xsl:with-param name="StringToTransform" select="substring-after($StringToTransform,' ')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$StringToTransform"/> </xsl:otherwise> </xsl:choose> </xsl:template> I want to use this call to remove newlines in a string - and store the result in a variable named sqlExample <xsl:variable name="sqlExample"> <xsl:call-template name="lf2br"> <xsl:with-param name="StringToTransform" select="SQL/text()" /> </xsl:call-template> </xsl:variable> This does not work, however. $sqlExample contains the text, but there are no <br> in it? If I remove the <xsl:variable> surrounding the call-template part, it works just fine - the <br> tags are in the printed output as expected. How come, it works when I print the output, but not when I store it in a variable? I really would like to put the results in a variable, since I need to do some further processing on it - but is this not possible, without loosing the formatting? Thank you for your help. Regards, Flemming Joensson XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] looping problem, <xsl: fo, Mukul Gandhi | Thread | Re: [xsl] linefeed to <br/> templat, David Carlisle |
RE: [xsl] gain data from multiple x, Passin, Tom | Date | Re: [xsl] xsl:value-of select : how, Mukul Gandhi |
Month |