Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSL-FO - Empty block elements

Tags:

xsl-fo

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.

like image 714
Jan Avatar asked Jul 04 '09 17:07

Jan


2 Answers

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.

like image 176
chiborg Avatar answered Sep 23 '22 16:09

chiborg


Or

<xsl:template match="p">
    <fo:block>
            <xsl:apply-templates/>
            &#x00A0;
    </fo:block>

&#x00A0; is the equivalent of &nbsp; in HTML (actually &nbsp; is a XML entity that is defined as A0 which is the Unicode character for Non Breaking Space).

like image 23
XMLDUDE Avatar answered Sep 20 '22 16:09

XMLDUDE