块中的大量数据

Large amount of data in a block

XSL-FO 文档使用 XML 数据源。一个标签中包含大量数据(10k+ 个字符,200+ 行)。需要跨多个页面打破它。

我试过 keep-together.within-page="auto" 但效果不佳,因为它是一个块。

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.1" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon" xmlns:fox="http://xml.apache.org/fop/extensions"
    xmlns="http://www.w3.org/2000/svg">
<xsl:template match="*|@*">
    <xsl:apply-templates select="*|@*"/>
</xsl:template>
<xsl:template match="YY">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Courier">
        <fo:layout-master-set>
            <!--Page 1 Pagemaster -->
            <fo:simple-page-master master-name="pagemaster1" page-height="792pt" page-width="612pt">
                <fo:region-body margin-left="15pt" margin-top="10pt" margin-bottom="20pt" margin-right="15pt"/>
                <fo:region-before extent="20pt"/>
                <fo:region-after extent="20pt"/>
                <fo:region-start extent="15pt"/>
                <fo:region-end extent="15pt"/>
            </fo:simple-page-master>
        </fo:layout-master-set>
        <!-- Page 1 Setup -->
        <fo:page-sequence master-reference="pagemaster1">
            <fo:static-content flow-name="xsl-region-before">
                <fo:table>
                    <fo:table-column column-width="582pt"/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell column-number="1" text-align="left" padding-left="2pt" padding-top="2pt" padding-right="2pt" padding-bottom="2pt">
                                <fo:block  linefeed-treatment="preserve" font-size="9pt">
                                    <xsl:value-of select="//YY/FIELD"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:static-content>
        </fo:page-sequence>
    </fo:root>
</xsl:template>
</xsl:stylesheet>
<!-- End of Stylesheet -->

输出pdf停在一页,切断平衡。只需要该块在必要的页面上继续显示全部内容即可。

您没有理解 XSL FO 的结构。您将静态内容放入页面的静态区域(想想页眉和页脚)。你把流动的内容放在一个流动中。

当您展示 XSL 而我们不知道 returns 是什么时,请使用以下内容作为灵感。你会看到它跨页流动,因为内容在流动区域内:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Courier">
<fo:layout-master-set>
    <!--Page 1 Pagemaster -->
    <fo:simple-page-master master-name="pagemaster1" page-height="792pt" page-width="612pt">
        <fo:region-body margin-left="15pt" margin-top="10pt" margin-bottom="20pt" margin-right="15pt"/>
        <fo:region-before extent="20pt"/>
        <fo:region-after extent="20pt"/>
        <fo:region-start extent="15pt"/>
        <fo:region-end extent="15pt"/>
    </fo:simple-page-master>
</fo:layout-master-set>
<!-- Page 1 Setup -->
<fo:page-sequence master-reference="pagemaster1">
    <fo:static-content flow-name="xsl-region-before">
        <fo:table>
            <fo:table-column column-width="582pt"/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell column-number="1" text-align="left" padding-left="2pt" padding-top="2pt" padding-right="2pt" padding-bottom="2pt">
                        <fo:block linefeed-treatment="preserve" font-size="9pt"> I am the header </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
        <fo:block linefeed-treatment="preserve" font-size="20pt"> Heading level 2 Laoreet imperdiet veniam diam stet eirmod diam diam consectetuer tempor rebum sit amet. Odio exerci takimata labore hendrerit tincidunt dolores vulputate dolores duo kasd consequat commodo veniam. Takimata odio dolor te wisi sit clita no ipsum. Takimata aliquyam sed est et lorem nonummy nisl in. Elitr ipsum erat ipsum. Heading level 3 Ut eu ea voluptua dolor sea lobortis dolor euismod illum clita clita. At feugait duo no in ut amet laoreet justo. Eum minim consetetur gubergren consequat illum no ipsum et accusam invidunt et nobis ad accusam eu. Iusto accumsan nulla. Dolore consetetur sea no ut sea eirmod voluptua labore consetetur lorem elit aliquyam blandit et. Lorem tempor lorem et consectetuer aliquyam aliquyam augue no sadipscing invidunt ullamcorper stet invidunt takimata et velit. Sanctus voluptua invidunt. Ipsum vero lorem voluptua duis dolor magna. Est consetetur elitr et blandit labore ut dolore blandit dolor stet stet accusam. Heading Level 4 Sit delenit ipsum tempor tempor amet dolor minim vero dolores wisi justo erat stet sanctus magna labore eos ut. Erat rebum accusam vel iusto et. Lorem eu elitr placerat quod vel diam ipsum duis amet sadipscing feugiat sanctus sea amet. Voluptua lorem molestie laoreet clita magna rebum sed magna minim est magna eirmod sadipscing magna labore nibh eirmod. Et dolore in. At diam consetetur gubergren rebum ullamcorper lorem est delenit sed sit iriure consectetuer nonumy velit et duo et. Kasd magna nonumy labore ea ex dolor gubergren sit volutpat gubergren duo invidunt ex. Nulla sit diam magna lorem justo. Sea placerat te at ipsum sed clita invidunt dolores aliquyam dolores et et amet volutpat. Feugiat sed tation duis dolor tempor esse facilisis no no diam. Lorem consetetur et et clita amet eos ad dolore diam. Heading Level 5 Ipsum et consequat erat amet lorem et nulla tempor amet praesent nonumy sea nonumy sea lorem dolor. Molestie dolores ea adipiscing et eos autem sit hendrerit et accusam lorem amet vulputate ex ut luptatum tempor. Ullamcorper erat sanctus sit dolor exerci vero amet tempor hendrerit vero voluptua assum nulla feugait tincidunt. Tincidunt invidunt dolore ut dolore option. Ut id et amet aliquyam ullamcorper est laoreet et ipsum. Invidunt erat accusam ullamcorper justo vero eum dolore no kasd sed commodo ut takimata clita. Diam lorem est ad feugiat. Heading Level 6 Iriure odio in et magna amet. Volutpat vero diam vulputate. Sit dolore justo ut nibh magna lobortis dolor. Consetetur elitr dolor invidunt duo gubergren sed eos wisi ex et vero aliquyam voluptua ut. Elitr et duo et nulla et sit et dignissim dolor et no dolore dolor consequat eos takimata placerat. Euismod labore dolor rebum vel no. Sea consequat ex amet takimata sanctus et diam ea dolore et. </fo:block>
    </fo:flow>
</fo:page-sequence>
</fo:root>

分两页显示内容的结果(抱歉,只显示了您想要的内容):