xsl fo 永远找不到 page-position "first"
xsl fo never finds page-position "first"
我正在使用 Apache Fop (2.1) 从 XML 生成 RTF 文档。我希望第一页的标题与其他页面的标题不同。我设置了两个simple-page-masters,一个用于第一页,一个用于其他页面。我 运行 在进入页面位置 "first" 时遇到了问题。它永远不会到达那里:
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
它总是到达 page-position="rest",即使是文档的第一页。谁能告诉我为什么?我该如何解决这个问题?
Fop 确实给我这个错误:
Only simple-page-masters are supported on page-sequences. Using default simple-page-master from page-sequence-master "my-sequence"
这是我的 xslt 的其余部分:
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:static-content flow-name="firstPageBefore">
<fo:block>First page!</fo:block>
</fo:static-content>
<fo:static-content flow-name="otherPageBefore">
<fo:block>Other page!</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
我使用这个示例:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body background-color="red"/>
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:flow flow-name="xsl-region-body" >
<fo:block break-after="page">First Page</fo:block>
<fo:block break-after="page">Second Page</fo:block>
<fo:block break-after="page">Third Page</fo:block>
<fo:block>Forth Page</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
请注意,我只将第一页的背景设为红色 "region-body"。我用 Apache FOP 2.1 得到这个输出:
现在,如果我只将格式更改为 RTF 而不是 PDF,则无法获得预期的输出。如果事实上为了测试这一点,我什至将第一页的大小更改为 5inx5in。如果我检查生成的 RTF,只有最后一个页面布局。
为了证明这一点,我将第一页更改为 5x5,将其余页面更改为 11x8.5 横向,原始 RTF 显示如下:
{*\generator Apache XML 图形 RTF 库;}
\fet0 \ftnbj \paperw15840 \paperh12240 \landscape \margt720 \margb720 \margl1440 \margr1440 \headery720 \footery720 \itap0
这只是一个页面模板,不是第一个模板。见下图,所有页面都是横向的,根本没有应用任何颜色。
这似乎是 Apache FOP RTF 输出的错误或不受支持的功能。
我正在使用 Apache Fop (2.1) 从 XML 生成 RTF 文档。我希望第一页的标题与其他页面的标题不同。我设置了两个simple-page-masters,一个用于第一页,一个用于其他页面。我 运行 在进入页面位置 "first" 时遇到了问题。它永远不会到达那里:
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
它总是到达 page-position="rest",即使是文档的第一页。谁能告诉我为什么?我该如何解决这个问题?
Fop 确实给我这个错误:
Only simple-page-masters are supported on page-sequences. Using default simple-page-master from page-sequence-master "my-sequence"
这是我的 xslt 的其余部分:
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:static-content flow-name="firstPageBefore">
<fo:block>First page!</fo:block>
</fo:static-content>
<fo:static-content flow-name="otherPageBefore">
<fo:block>Other page!</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
我使用这个示例:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body background-color="red"/>
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:flow flow-name="xsl-region-body" >
<fo:block break-after="page">First Page</fo:block>
<fo:block break-after="page">Second Page</fo:block>
<fo:block break-after="page">Third Page</fo:block>
<fo:block>Forth Page</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
请注意,我只将第一页的背景设为红色 "region-body"。我用 Apache FOP 2.1 得到这个输出:
现在,如果我只将格式更改为 RTF 而不是 PDF,则无法获得预期的输出。如果事实上为了测试这一点,我什至将第一页的大小更改为 5inx5in。如果我检查生成的 RTF,只有最后一个页面布局。
为了证明这一点,我将第一页更改为 5x5,将其余页面更改为 11x8.5 横向,原始 RTF 显示如下:
{*\generator Apache XML 图形 RTF 库;} \fet0 \ftnbj \paperw15840 \paperh12240 \landscape \margt720 \margb720 \margl1440 \margr1440 \headery720 \footery720 \itap0
这只是一个页面模板,不是第一个模板。见下图,所有页面都是横向的,根本没有应用任何颜色。
这似乎是 Apache FOP RTF 输出的错误或不受支持的功能。