gpt4 book ai didi

xml - XSL-FO 页码 2a、2b

转载 作者:数据小太阳 更新时间:2023-10-29 02:29:44 29 4
gpt4 key购买 nike

在我的 XSL-FO 中:我需要在页脚中显示页码。

  • 我的页面布局通常是:第 1、2、3、4、5 页。
  • 有时第 2 页会被 2a 和 2b 替换,因此流程应该是:1、2a、2b、3、4、5。
  • 第 2a 和 2b 页只是第 2 页的扩展页。第 2 页显示了两个表格。第 2a 页是一页上的第一个表(扩展),第 2b 页是另一页上的第二个表(扩展)。

我需要什么:
当两个表应该在不同的页面上时,将这些页码显示为 2a 和 2b,否则当两个表应该在一页上时,显示第 2 页。

我需要额外的 <fo:simple-page-master> 吗?和 <fo:conditional-page-master-reference>为了这个这个?如果是这样,我不确定如何组织它,也不知道如何获得显示为 2a 和 2b 的页码。我知道你可以用它来写字母:<fo:page-number format="a"/> .

这个 XML 标志决定了应该打印什么。如果此处为“1”,则应打印第 2a 和 2b 页,如果此处为“0”,则应打印第 2 页。

<PAGE2FLAG>1</PAGE2FLAG>

感谢您的帮助!

这是我的样式表:

<xslt:stylesheet xmlns:xslt="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslt:output method="xml" indent="yes" encoding="utf-8"/>
<xslt:param name="XFTemplateName">Document</xslt:param>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="first-page" page-width="8.5in" page-height="11in">
<fo:region-body region-name="xsl-region-body" column-count="2" margin="0.4in 0.4in 0.4in 0.4in"/>
<fo:region-before region-name="xsl-region-before" display-align="after" extent="0.7in"/>
<fo:region-after region-name="xsl-region-after" extent="0.7in"/>
<fo:region-start region-name="xsl-region-start" extent="0.7in"/>
<fo:region-end region-name="xsl-region-end" extent="0.7in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="other-page" page-width="8.5in" page-height="11in">
<fo:region-body region-name="xsl-region-body" column-count="2" margin="0.4in 0.4in 0.4in 0.4in"/>
<fo:region-before region-name="xsl-region-before" display-align="after" extent="0.7in"/>
<fo:region-after region-name="xsl-region-after-other" extent="0.7in"/>
<fo:region-start region-name="xsl-region-start" extent="0.7in"/>
<fo:region-end region-name="xsl-region-end" extent="0.7in"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="default">
<fo:repeatable-page-master-alternatives maximum-repeats="no-limit">
<fo:conditional-page-master-reference page-position="first" master-reference="first-page"/>
<fo:conditional-page-master-reference master-reference="other-page"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="default" font-family="Helvetica">
<fo:static-content flow-name="xsl-region-before">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">&#xa0;</fo:block>
</fo:static-content>
<xslt:comment> FIRST PAGE ONLY FOOTER </xslt:comment>
<fo:static-content flow-name="xsl-region-after">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">
<fo:block text-align-last="justify">
<fo:inline font-size="8pt">DOCUMENT</fo:inline>
<fo:inline font-size="14pt">
<xslt:comment> BARCODE GOES HERE </xslt:comment>
</fo:inline>
<fo:leader leader-pattern="space"/>
<fo:inline font-size="8pt">
PAGE <fo:page-number format="1"/> OF 5
· FORM ID #<xsl:value-of select="XMLDOC/FORMID"/>
</fo:inline>
</fo:block>
</fo:block>
</fo:static-content>
<xslt:comment> ALL OTHER PAGES FOOTER </xslt:comment>
<fo:static-content flow-name="xsl-region-after-other">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">
<fo:block text-align-last="justify">
<fo:inline font-size="8pt">DOCUMENT</fo:inline>
<fo:inline font-size="14pt">&#xa0;</fo:inline>
<fo:leader leader-pattern="space"/>
<fo:inline font-size="8pt">
PAGE <fo:page-number format="1"/> OF 5
· FORM ID #<xsl:value-of select="XMLDOC/FORMID"/>
</fo:inline>
</fo:block>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-start">
<fo:block> </fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-end">
<fo:block> </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xslt:comment> THIS IS PAGE 1 </xslt:comment>
</fo:block>
<fo:block break-before="page"/>

<fo:block>
<fo:table>
<xslt:comment> PAGE 2 (First Table) </xslt:comment>
</fo:table>
</fo:block>

<xsl:if test="XMLDOC/PAGE2FLAG = 1">
<xslt:comment> This IF and BREAK separates the two tables into two pages. </xslt:comment>
<xslt:comment> These are the two pages that I want Page 2a and Page 2b. </xslt:comment>
<xslt:comment> In my printout, they are being shown as Page 2 and Page 3. </xslt:comment>
<fo:block break-before="page"/>
</xsl:if>

<fo:block>
<fo:table>
<xslt:comment> PAGE 2 (Second Table) </xslt:comment>
</fo:table>
</fo:block>

<fo:block break-before="page"/>
<fo:block>
<xslt:comment> THIS IS PAGE 3 </xslt:comment>
</fo:block>

<fo:block break-before="page"/>
<fo:block>
<xslt:comment> THIS IS PAGE 4 </xslt:comment>
</fo:block>

<fo:block break-before="page"/>
<fo:block>
<xslt:comment> THIS IS PAGE 5 </xslt:comment>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

最佳答案

根据 @Jean-François Savard建议,我已经添加了<fo:retrieve-marker><fo:marker>进入我的代码。

请注意,在生成的 FO 文件中,每个 <fo:marker>必须是 <fo:block>第一个 child ,否则您将收到错误 "fo:marker" must be declared before "(%block;)" .

我的问题已经解决:它按照我想要的方式工作,页面 2 或页面 2a2b 正常显示。

<xslt:stylesheet xmlns:xslt="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslt:output method="xml" indent="yes" encoding="utf-8"/>
<xslt:param name="XFTemplateName">Document</xslt:param>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="first-page" page-width="8.5in" page-height="11in">
<fo:region-body region-name="xsl-region-body" column-count="2" margin="0.4in 0.4in 0.4in 0.4in"/>
<fo:region-before region-name="xsl-region-before" display-align="after" extent="0.7in"/>
<fo:region-after region-name="xsl-region-after" extent="0.7in"/>
<fo:region-start region-name="xsl-region-start" extent="0.7in"/>
<fo:region-end region-name="xsl-region-end" extent="0.7in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="other-page" page-width="8.5in" page-height="11in">
<fo:region-body region-name="xsl-region-body" column-count="2" margin="0.4in 0.4in 0.4in 0.4in"/>
<fo:region-before region-name="xsl-region-before" display-align="after" extent="0.7in"/>
<fo:region-after region-name="xsl-region-after-other" extent="0.7in"/>
<fo:region-start region-name="xsl-region-start" extent="0.7in"/>
<fo:region-end region-name="xsl-region-end" extent="0.7in"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="default">
<fo:repeatable-page-master-alternatives maximum-repeats="no-limit">
<fo:conditional-page-master-reference page-position="first" master-reference="first-page"/>
<fo:conditional-page-master-reference master-reference="other-page"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="default" font-family="Helvetica">
<fo:static-content flow-name="xsl-region-before">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">&#xa0;</fo:block>
</fo:static-content>
<xslt:comment> FIRST PAGE ONLY FOOTER </xslt:comment>
<fo:static-content flow-name="xsl-region-after">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">
<fo:block text-align-last="justify">
<fo:inline font-size="8pt">DOCUMENT</fo:inline>
<fo:inline font-size="14pt">
<xslt:comment> BARCODE GOES HERE </xslt:comment>
</fo:inline>
<fo:leader leader-pattern="space"/>
<fo:inline font-size="8pt">
PAGE <fo:retrieve-marker retrieve-class-name="page_number"/> OF 5
</fo:inline>
</fo:block>
</fo:block>
</fo:static-content>
<xslt:comment> ALL OTHER PAGES FOOTER </xslt:comment>
<fo:static-content flow-name="xsl-region-after-other">
<fo:block start-indent="-20.000pt" end-indent="-20.000pt">
<fo:block text-align-last="justify">
<fo:inline font-size="8pt">DOCUMENT</fo:inline>
<fo:inline font-size="14pt">&#xa0;</fo:inline>
<fo:leader leader-pattern="space"/>
<fo:inline font-size="8pt">
PAGE <fo:retrieve-marker retrieve-class-name="page_number"/> OF 5
</fo:inline>
</fo:block>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-start">
<fo:block> </fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-end">
<fo:block> </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:marker marker-class-name="page_number">1</fo:marker>
<fo:block>
<xslt:comment> THIS IS PAGE 1 </xslt:comment>
</fo:block>
<fo:block break-before="page"/>

<fo:block>
<xsl:if test="XMLDOC/PAGE2FLAG = 0">
<fo:marker marker-class-name="page_number">2</fo:marker>
</xsl:if>
<xsl:if test="XMLDOC/PAGE2FLAG = 1">
<fo:marker marker-class-name="page_number">2a</fo:marker>
</xsl:if>
<fo:table>
<xslt:comment> PAGE 2 (First Table) </xslt:comment>
</fo:table>
</fo:block>

<xsl:if test="XMLDOC/PAGE2FLAG = 1">
<xslt:comment> This IF and BREAK separates the two tables into two pages. </xslt:comment>
<xslt:comment> These are the two pages that I want Page 2a and Page 2b. </xslt:comment>
<xslt:comment> In my printout, they are being shown as Page 2 and Page 3. </xslt:comment>
<fo:block break-before="page"/>
</xsl:if>

<fo:block>
<xsl:if test="XMLDOC/PAGE2FLAG = 0">
<fo:marker marker-class-name="page_number">2</fo:marker>
</xsl:if>
<xsl:if test="XMLDOC/PAGE2FLAG = 1">
<fo:marker marker-class-name="page_number">2b</fo:marker>
</xsl:if>
<fo:table>
<xslt:comment> PAGE 2 (Second Table) </xslt:comment>
</fo:table>
</fo:block>

<fo:block break-before="page"/>
<fo:block>
<fo:marker marker-class-name="page_number">3</fo:marker>
<xslt:comment> THIS IS PAGE 3 </xslt:comment>
</fo:block>

<fo:block break-before="page"/>
<fo:marker marker-class-name="page_number">4</fo:marker>
<xslt:comment> THIS IS PAGE 4 </xslt:comment>
</fo:block>

<fo:block break-before="page"/>
<fo:marker marker-class-name="page_number">5</fo:marker>
<xslt:comment> THIS IS PAGE 5 </xslt:comment>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

关于xml - XSL-FO 页码 2a、2b,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29129098/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com