[xep-support] How to preserve a preformatted block of text in the FO table
Tang Hong - Developer
Hong.Tang at Sun.COM
Wed May 8 07:17:43 PDT 2002
We are trying to generate a FO table with a preformatted block of text in one
cell. We can generate the preformatted text in a FO block. But when we put the
block in a table cell we lose the preformatting.
Incoming text has preformatted blocks enclosed between "/<PRE/>" and "/</PRE/>".
They will be replaced with genuine <PRE> and </PRE> tags later. We generate
preformatted text by putting everything between "/<PRE/>" and "/</PRE/>" in a FO
block. The block is set in Courier font with whitespace and linefeeds preserved.
Here is the xsl code we use. It works when we generate a FO block that is not in
a FO cell. It does not preserve whitespace and linefeeds when the block is in a
FO cell. Is there some way we can preserve whitespace and linefeeds in a table
cell?
======================================================================
<xsl:param name="analysis"><xsl:value-of select="@analysis" /></xsl:param>
<xsl:choose>
<xsl:when test="substring($analysis, 1, 7)='/<PRE/>'">
<fo:block space-after.optimum="1pt" space-before.optimum="2pt"
font-family="Courier" font-size="9pt" font-weight="normal"
linefeed-treatment="preserve" space-treatment="preserve"
white-space-collapse="false">
<xsl:value-of select="substring-before(substring($analysis, 8),
'/</PRE/>')" />
</fo:block>
<fo:block font-family="Helvetica" space-after.optimum="6pt"
space-before.optimum="0pt"
font-size="11pt" font-weight="normal"
linefeed-treatment="preserve" space-treatment="preserve">
<xsl:value-of
select="substring(substring-after(substring($analysis, 10), '/</PRE/>
'), 2)" />
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block font-family="Helvetica" space-after.optimum="6pt"
space-before.optimum="2pt"
font-size="11pt" font-weight="normal"
linefeed-treatment="preserve" space-treatment="preserve">
<xsl:value-of select="$analysis" />
</fo:block>
</xsl:otherwise>
</xsl:choose>
======================================================================
Hong
-------------------
By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
More information about the Xep-support
mailing list