块中的大量数据

时间:2019-09-05 20:20:16

标签: xsl-fo

使用XML数据源的XSL-FO文档。一个标签中包含大量数据(超过10万个字符,超过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停止在一页上,从而切断余额。只需要该块在需要的页面上继续显示所有内容即可。

1 个答案:

答案 0 :(得分:0)

您不了解XSL FO的结构。您将静态内容放入页面上的静态区域(请考虑页眉和页脚)。您将流内容放入流中。

虽然您正在显示XSL,但我们不知道返回的是什么,但请参考以下内容。您会看到它跨页面流动,因为内容在流动区域之内:

<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>

在两页中显示内容的结果(抱歉,不仅仅是显示您想要的内容):

enter image description here