xsl-list
[Top] [All Lists]

Linefeed-treatment in fop 0.20.4

2002-11-19 14:12:04
Can anyone tell me if there is an easier way to do this? My NOTE_TEXT node
is returned from an Oracle blob object which contains line-feed characters
and is multi-line. When rendering the linefeed '\n' was ignored and
everything ended up on one line. I tried to use linefeed-treatment and
white-space-treatment = "preserve", but these are not yet implemented in
fop 0.20.4
Here is the xslt workaround I came up with to get the multiline results I
was looking for, but there has got to be an easier way.

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:fo="http://www.w3.org/1999/XSL/Format";
     xmlns:Date="xalan://java.util.Date"
     xmlns:Token="xalan://java.util.StringTokenizer">

--- trimmed header / fo:table nodes ---

              <fo:table-cell>
                <xsl:apply-templates select="NOTE_TEXT">
                  <xsl:with-param name="noteToken" select
="Token:new(NOTE_TEXT,'&#10;')"/>
                </xsl:apply-templates>
              </fo:table-cell>

<xsl:template match="NOTE_TEXT">
  <xsl:param name="noteToken"/>
  <xsl:call-template name="note.loop">
    <xsl:with-param name="i" select="1"/>
    <xsl:with-param name="noteMax" select="Token:countTokens($noteToken)"/>
    <xsl:with-param name="noteToken" select="$noteToken"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="note.loop">
  <xsl:param name="i"/>
  <xsl:param name="noteMax"/>
  <xsl:param name="noteToken"/>
  <xsl:if test="$i &lt;= $noteMax">
    <fo:block>
      <xsl:value-of select="Token:nextToken($noteToken)"/>
    </fo:block>
    <xsl:if test="$i &lt; $noteMax">
      <xsl:call-template name="note.loop">
        <xsl:with-param name="i" select="$i + 1"/>
        <xsl:with-param name="noteMax" select="$noteMax"/>
        <xsl:with-param name="noteToken" select="$noteToken"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:if>
</xsl:template>

Thanks in advance,
Richard Shonk
Flowserve Corp.
Programmer / Analyst
Parts Distribution Center
Moosic, Pa.
(570) 451-2225


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>