XSL-FO - 空块元素

发布于 2024-07-25 23:10:08 字数 208 浏览 2 评论 0原文

我有一个非常简单的模板:

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

即使块是空的,我如何告诉 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

转身以后 2024-08-01 23:10:08

只需在 末尾添加一个 元素即可。 像这样:

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

领导者不会对有内容的行执行任何操作,并为没有内容的行创建一个空行。

使用 Apache FOP 和 XEP 进行了测试。

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.

客…行舟 2024-08-01 23:10:08

或者

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

  相当于 HTML 中的  (实际上   是一个 XML 实体,定义为A0 是不间断空格的 Unicode 字符)。

Or

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

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

看轻我的陪伴 2024-08-01 23:10:08

或者,

<fo:block white-space-treatment="preserve"> </fo:block>

Alternatively,

<fo:block white-space-treatment="preserve"> </fo:block>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文