fo:inline-容器元素的 XSL-FO 溢出处理

XSL-FO Overflow Handling for fo:inline-container Elements

fo:inline-容器元素的 XSL-FO 溢出处理

我的问题是:如何破坏 fo:inline-container[ 中的内容(例如 fo:block 元素) 如果继承的内容对于当前页面来说太长,则跳转到新页面?

使用的格式化程序:AHF 6.2、Apache FOP 2.1

这是一段简短的代码摘录:

<xsl:template match="myElement">
    <fo:block>
        <fo:inline-container inline-progression-dimension="33.333%">
            <fo:block>
                Marginalia Headline
            </fo:block>
        </fo:inline-container>

        <fo:inline-container inline-progression-dimension="66.666%">
            <fo:block>
                Imagine this is a very long text ...
            </fo:block>
            <fo:block>
                Imagine this is a very long text ...
            </fo:block>
            <fo:block>
                Imagine this is a very long text ...
            </fo:block>
            <!-- MANY MORE fo:blocks -->
        </fo:inline-container>
    </fo:block>
</xsl:template>

问题是,内容溢出了 fo:inline-容器,但没有进入新页面。我认为这与 周围的 fo:block 元素有关,该元素将所有内容都放在一个页面上。

这里的任何建议都会有所帮助。提前致谢!

什么有效

使用fo:list-块

(好吧,你说过你不想使用这个技巧......无论如何这有效并且可以作为最后的手段使用)

您可以在 fo:list-item-label 中添加旁注,在 fo:list-item-body 中添加 "normal" 文本:

        <fo:list-block provisional-distance-between-starts="33.333%">
            <fo:list-item>
                <fo:list-item-label end-indent="label-end()">
                    <fo:block>
                        Marginalia Headline
                    </fo:block>
                </fo:list-item-label>
                <fo:list-item-body start-indent="body-start()">
                    <fo:block>
                        Lorem ipsum dolor ...
                    </fo:block>
                    <!-- other blocks ... -->
                </fo:list-item-body>
            </fo:list-item>
        </fo:list-block>

使用溢出fo:block-容器

或者,您可以使用更扁平的格式对象序列,将旁注放入 零高度块容器 ,这样接下来的普通文本块将从相同高度:

        <fo:block-container height="0pt" overflow="visible" keep-with-next.within-page="always">
            <fo:block end-indent="66.666%">
                Marginalia Headline
            </fo:block>
        </fo:block-container>
        <fo:block start-indent="33.333%">
            Lorem ipsum dolor ...
        </fo:block>
        <!-- other blocks ... -->

请注意,如果此解决方案产生超过 X 行,则此解决方案可能会导致旁注溢出到页面底部边距或与下一个旁注重叠,其中 X 是其对应的 orphans 属性普通文本(例如,旁注为三行,而普通文本有 orphans="2")。

什么不起作用

使用fo:float

即使 FOP 支持侧向浮动,我也不认为使用它们会获得所需的输出,因为文本会围绕它流动,尽快返回使用所有可用的水平方向 space :

        <fo:block>
            <fo:float float="left">
                <fo:block width="33.333%" background-color="#AAFFFF">Marginalia Headline</fo:block>
            </fo:float>
            <fo:block background-color="#FFAAFF">
                Lorem ipsum dolor ...
            </fo:block>
            <!-- other blocks ... -->
        </fo:block>

使用 fo:inline-容器

我认为问题中的代码没有按预期工作,不是因为外部 fo:block 中缺少某些内容,而是因为包含长文本的 fo:inline-container 中缺少某些内容:overflow属性。

如果未指定,其默认值为"auto",这意味着格式化对象处理器可以为所欲为(即使溢出也可能显示内容)。对于 overflow="repeat",处理器应在需要时创建其他区域,以便将内容拆分为页面:

        <fo:block>
            <fo:inline-container inline-progression-dimension="33.333%">
                <fo:block>
                    Marginalia Headline
                </fo:block>
            </fo:inline-container><fo:inline-container inline-progression-dimension="66.666%" overflow="repeat">
                <fo:block>
                    Lorem ipsum dolor ...
                </fo:block>
                <!-- other blocks ... -->
            </fo:inline-container>
        </fo:block>
但是,

FOP 支持 overflow="repeat"(我无法使用 Antenna House XslFormatter 进行测试,但 conformance page 表示它受支持)。

(披露:我是一个不活跃的 FOP 开发者)