Search code examples
xsl-fo

XSL-FO - Empty block elements


I have a quite simple template:

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

How do I tell FO to keep empty lines even if the block is empty.


Solution

  • Just add a <fo:leader/> element at the end of your <fo:block>. Like this:

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

    The leader will do nothing for lines with content, and will create an empty line for lines without content.

    Tested with Apache FOP and XEP.