W3C home > Mailing lists > Public > www-xsl-fo@w3.org > December 2007

XSL help - converting newlines into HTML </br>

From: Patryn999 <Patryn999@gmail.com>
Date: Sun, 16 Dec 2007 13:10:11 -0800 (PST)
Message-ID: <14366327.post@talk.nabble.com>
To: www-xsl-fo@w3.org

Hi,
   I'm not very experienced in XML/XSL at all (only started looking at it a
couple of days ago) anyway I'm calling this stylesheet to output an XML file
with <BuildLog> stuff here with newlines in it </BuildLog> to HTML and
conserve the newlines so the formatting remains.

I've hacked together some code from other files I've read but I get an
error, and I've spent a while on it and I'm completely stumped. Cheers for
any help:

Here's the code:
<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:lxslt="http://xml.apache.org/xslt">
    <xsl:output method="html"/>

    <xsl:template match="BuildLog" mode="buildlog">
                    <xsl:call-template name="newlineToHTML">
                        <xsl:with-param name="line" select="text()"/>
                    </xsl:call-template>
    </xsl:template>



    <xsl:template name="newlineToHTML">
        <xsl:param name="line"/>
        <xsl:choose>
            <xsl:when test="contains($line, '&#10;')">
                <xsl:value-of select="sul:stylesheetstring-before($line,
'&#10;')"/>
                <br/>
                <xsl:call-template name="newlineToHTML">
                    <xsl:with-param name="line">
                        <xsl:value-of select="substring-after($line,
'&#10;')"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$line"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>

Thanks in advance
Carl
-- 
View this message in context: http://www.nabble.com/XSL-help---converting-newlines-into-HTML-%3C-br%3E-tp14366327p14366327.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.
Received on Monday, 17 December 2007 13:19:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 17 December 2007 13:19:20 GMT