我正在尝试使用 Apache FOP 在我的 pdf 中创建动态表。 我已经实现了大部分目标,还需要一些微调。 我在表头中使用了 fo:retrieve-table-marker 并且它工作得很好。 但我确实希望表体的第一行有相同的连续文本。 当我在表体中使用 fo:retrieve-table-marker 时,出现以下错误:
(错误位置未知)org.apache.fop.fo.ValidationException:“fo:fo:retrieve-table-marker”不是“fo:block”的有效子级! fo:retrieve-table-marker 只允许作为 fo:table-header 或 fo:table-footer 的后代。 (没有可用的上下文信息)
我该如何实现这一目标?
这是我的示例 xsl :
<fo:table>
<fo:table-header>
<fo:table-row keep-with-next.within-page="always">
<fo:table-cell>
<fo:block>
<fo:retrieve-table-marker retrieve-class-name="fortsSectionTitle" retrieve-position- within-table="first-starting"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row keep-with-next.within-page="always">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="fortsSectionTitle"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row keep-with-next.within-page="always">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="fortsSectionTitle">
<xsl:text> forts.</xsl:text>
</fo:marker>
</fo:block>
</fo:table-cell>
</fo:table-row>
<!--this is my first row of table body -->
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:retrieve-table-marker retrieve-class-name="fortsSectionTitle" retrieve-
position-within-table="1"/>
</fo:block>
</fo:table-cell>
<fo:table-row>
<!-- rest of my table rows with details -->
...
</fo:table-body>
</fo:table>
所需输出:
PAGE 1:
HEADER
1ST ROW OF TABLE BODY
.
.
.
PAGE 2:
HEADER cont.
1ST ROW OF TABLE BODY cont.
.
.
.
XSL 1.1 规范不支持检索
fo:table-body
内的标记。
规范规定,
fo:retrieve-table-marker
可以用来代替fo:table-header
或fo:table-footer
或在fo:table-header
或fo:table-footer
内部使用。 (参见https://www.w3.org/TR/xsl11/#fo_retrieve-table-marker)
FWIW,Antenna House Formatter 有一个
axf:table-cell-repeated-marker
扩展,可以做你想做的事情。 (参见https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#table)