|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: formatting problem
Subject: Re: formatting problem
From: Markus Spath <mspath@xxxxxxxx>
Date: Wed, 20 Feb 2002 21:18:04 +0100
|
Joerg Heinicke wrote:
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(., ' ', ' ')"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="linebreaks">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, ' ')">
<xsl:value-of select="substring-before($string, ' ')"/>
<br/>
<xsl:call-template name="linebreaks">
<xsl:with-param name="string"
select="substring-after($string, ' ')"/>
</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 with 'nothing', so you have to change the with-param in
the first template:
<xsl:with-param name="string" select="translate(., ' ',
' ')"/>
This means: replace ' ' (space) with   (non-breaking space) and
(carriage return) with nothing.
or (less sophisticated ;) ):
...
<xsl:template match="ARTICLE">
<pre>
<xsl:value-of select="."/>
</pre>
</xsl:template>
...
Markus
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|