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

Re: formatting problem

Subject: Re: formatting problem
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Wed, 20 Feb 2002 21:02:47 +0100
xsl printout problems
> I am trying to have whats between the tags to printout via XSL to HTML
> exactly as it is.  What keeps happening is that the white spaces get
deleted
> and it doesn't recognize the line feeds.  Any ideas what I'm doing wrong ?
> The XML snippet is below.
>
> Thank You for your help

Hello Gene,

I'm quite sure, that this isn't a XSL-problem, but normal HTML-behaviour.
Did you ever try to place more than one spaces in HTML?

Is this what you have? Many spaces and linebreaks, removed in HTML.

<xsl:template match="ARTICLE">
    <xsl:value-of select="."/>
</xsl:template>

Try the following (replacing spaces with non-breaking spaces and linebreaks
with <br/>):

<xsl:template match="ARTICLE">
    <xsl:call-template name="linebreaks">
        <xsl:with-param name="string" select="translate(., ' ', '&#160;')"/>
    </xsl:call-template>
</xsl:template>

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

This handles only linefeed, maybe you still need to handle carriage return.
we replaced &#13; with 'nothing', so you have to change the with-param in
the first template:

        <xsl:with-param name="string" select="translate(., ' &#13;',
'&#160;')"/>

This means: replace ' ' (space) with &#160; (non-breaking space) and &#13;
(carriage return) with nothing.

Does this help?

Regards,

Joerg


 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.