[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

linefeed to <br/> template

Subject: linefeed to <br/> template
From: Flemming Jønsson <flj@xxxxxxxxxxxxx>
Date: Tue, 7 Oct 2003 17:10:00 +0200
xsl linefeed
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,'&#10;')">
      <xsl:value-of select="substring-before($StringToTransform,'&#10;')"/>
       <br/>
      <xsl:call-template name="lf2br">
        <xsl:with-param name="StringToTransform" select="substring-after($StringToTransform,'&#10;')"/>
      </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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.