xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Delmelle <andreas.delme...@telenet.be>
Subject Re: Line breaking in FOP (XSL)
Date Fri, 06 Jun 2008 15:50:30 GMT
On Jun 6, 2008, at 16:42, Browning, Jamie wrote:

> Given a source XML document the author has attempted to insert html  
> style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>

<xsl:template match="text">
   <fo:block linefeed-treatment="preserve">
     <xsl:apply-templates />
   </fo:block>
</xsl:template>

<xsl:template match="br">
   <xsl:text>&#x0A;</xsl:text>
</xsl:template>

<xsl:template match="text()">
   <xsl:value-of select="normalize-space(.)" />
</xsl:template>


will yield:

<fo:block linefeed-treatment="preserve">Line 1
Line 2
Line 3</fo:block>

For an input of:

> <text>
>   Line 1
>   <br/>
>   <br/>
>   Line 2
> </text>

You will get:

<fo:block linefeed-treatment="preserve">Line 1

Line 2</fo:block>

Which will produce one empty line in the output.

HTH!

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message