XSL-FO adds a new line after each node

I have an XML file with a structure like this:

<parent>
    <node>Text 1</node>
    <node>Text 2</node>
    <node>Text 3</node>
    <node>Text 4</node>
    <node>Text 5</node>
</parent>

      

I want to process this XML with XSL-FO to output a PDF file. I have an XSL-FO template:

<fo:block>
    <xsl:for-each select="node[position() &lt; last()]">
        <xsl:value-of select="."/>
        <xsl:if test="position() != last()">
            <xsl:text>&#xA;</xsl:text>
        </xsl:if>
    </xsl:for-each>
</fo:block>

      

This seems to work poorly. I am getting inline output, not each node on its own line. How can I solve this problem?

Thank!

0


source to share


2 answers


using



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

      

+1


source


You would have better control over things if you matched the node element and created fo: block for them. The solution you have is to set them in line, another answer will work but won't give them less control.

If you want each of them to be on a new line (which means you want to create a new block region) then put each one in its own block.

Meaning, you would do somewhere in your XSL:



 <xsl:template match="node">
     <fo:block>
         <xsl:apply-templates/>
     </fo:block>
 </xsl:template>

      

There should be no reason to use value-of select = ".". The above will do it for you, and if you ever expand to something inside a node element then you are still configured.

+1


source







All Articles