xslt - 如何使用 XSL/XSL-FO 在静态表中添加连续标签?
问题描述
我正在使用类似于下面示例的 xml 数据。有一个可能的风险列表,每个风险都可以有一个名称和描述。
<risks>
<freezeDeductible name="item1" description="desc 1"/>
<moneySecLimit name="item2" description="desc 2"/>
<unscheduledLimit name="item3" description="desc 3"/>
...
</risks>
我的模板结构如下:
<xsl:template name="displayRisks">
<fo:block>
<fo:table>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="2"/>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="3"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-weight="bold">ALL RISKS</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/freezeDeductible/@name"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/freezeDeductible/@description"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/moneySecLimit/@name"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/moneySecLimit/@description"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
根据上面的模板,我正在生成 PDF 输出。由于风险描述的大小,以及风险元素的数量是未知的,该表可以跨越多个一页或一页。
在 column1 x row1 上,第一页上显示了标题 - “所有风险”。它需要与第一个风险名称和描述在同一行,因此不能将其移动到表头。
有什么方法可以在表格到达 page2、page3 等时在新页面的第一行显示标题(ALL RISKS),并带有标签 - 例如:(继续..)?
例如: Page1:应该在第一行显示标题,如下所示:ALL RISKS
如果有 Page2:在 Pag2 的第一个表行显示标题,如下所示:ALL RISKS(continued..)
谢谢!
解决方案
在https://www.antennahouse.com/xsl-fo-samples#table-retrieve-table-marker-1fo:retrieve-table-marker
的“XSL-FO 样本集合”中有一个示例。(由于页面上的横幅,您可能需要在点击链接后向上滚动。)
在https://www.antennahouse.com/xsl-fo-samples#axf-table-cell-repeated-marker-1上还有一个axf:repeat-content-at-break
和axf:table-cell-repeated-marker
AH Formatter 扩展的示例,它演示了重复和“(续)”像你想要的那样标记。
推荐阅读
- android - 消除
清单合并 - android - 使用 Firebase 从公共存储中获取文件(由其他人运行)
- docker - Confluence docker:无法连接到mysql
- javascript - 如何检查是否在 Flask 上单击了链接?
- python - 如何将 Nonetype 转换为 int?
- javascript - 将文本插入 HTML 样式标记 - JavaScript
- typescript - 猴子补丁 react-native Text 组件与 TypeScript
- dart - Dart 的分析器和 linter 有什么区别?
- python - 查找导出的 csv 的路径
- for-loop - 简单的 JS for 循环删除 Google 表格中的表格不循环