我正在使用FOP(最新开发版本 - 2.2)从XML生成PDF。 xml由大型复杂结构组成,我无法控制格式或模式。基本上我的问题是,当我在表中有一个长tfoot部分时,表不会创建分页符。当行在tbody部分内时,它会很好地完成,并且我已经开始工作并添加一个"继续"到表头中的表标题。我希望能够做同样的事情,但在表格页脚部分。 我已经在Stackoverflow和网络上研究了大量的帖子,并尝试了很多不同的场景,但没有一个适合我。我查看过:possible stackoverflow solution和retrieve-table-marker example但它并没有影响我的布局。我已尝试过在各种构造中使用保持在一起的属性的许多其他组合,但没有成功。这是一个小编辑的示例xml文件我测试时删除了很多内容,因此它不是实际文件:
<?xml version="1.0" encoding="UTF-8"?>
<table frame="all" id="t3" tocentry="1">
<title>Test table retrieve markers and tfoot page break.</title>
<tgroup align="left" cols="6">
<colspec colname="col1" colwidth="1.17in"/>
<colspec colname="col2" colwidth="1.17in"/>
<colspec colname="col3" colwidth="1.19in"/>
<colspec colname="col4" colwidth="1.17in"/>
<colspec colname="col5" colwidth="1.17in"/>
<colspec colname="col6" colwidth="1.17in"/>
<thead valign="bottom">
<row>
<entry align="center" morerows="0" rotate="0" valign="top">Column 1</entry>
<entry align="center" morerows="0" rotate="0" valign="top">Column 2</entry>
<entry align="center" morerows="0" rotate="0" valign="top">Column 3</entry>
<entry align="center" morerows="0" rotate="0" valign="top">Column 4</entry>
<entry align="center" morerows="0" rotate="0" valign="top">Column 5</entry>
<entry align="center" morerows="0" rotate="0" valign="top">Column 6</entry>
</row>
</thead>
<tbody valign="top">
<row>
<entry morerows="0" rotate="0" rowsep="0" valign="top">This table has 10 footnotes in it and: <para> multiple paras, this is 1.</para><para> This is 2.</para><para> And this is 3.</para></entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Flanges, Caps</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Ultrasonic.</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">dia 1 inch, see Note </entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">dia > 1 inch</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">=</entry>
</row>
<!-- Add more rows here -->
<row>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Test more rows with footnotes<ftnote id="ftn9">
<para>Lots of paras here, with lots of text to make the table big. <seqlist>
<item><para>seqlist item 1 para 1</para><para>seqlist item 1 para 2</para><para>seqlist item 1 para 3</para></item>
<item><para>seqlist item 2 para 1</para><para>seqlist item 2 para 2</para><para>seqlist item 2 para 3</para></item>
<item><para>Here's a sublist:</para><randlist>
<item><para>sub-seqlist item 1 para 1</para><para>sub-seqlist item 1 para 2</para><para>sub-seqlist item 1 para 3</para></item>
<item><para>sub-seqlist item 2 para 1</para><para>sub-seqlist item 2 para 2</para><para>sub-seqlist item 2 para 3</para></item>
</randlist></item>
</seqlist></para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<!-- Add more para's here -->
</ftnote></entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Flanges, Caps<ftnref xrefid="ftn9"/></entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Ultrasonic.</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">Footnote in a para but with cdata prior to para <para> now a para followed by a footnote <ftnote id="ftn10">
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
</ftnote></para>
</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top"><para> Footnote in para following entry footnote <ftnote id="ftn11">
<para>Footnote 8: <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
<para>The item could have up to <emphasis>1.00</emphasis> inch diameter disbond or delamination in the bondline in the middle of skin.</para>
</ftnote></para>
</entry>
<entry morerows="0" rotate="0" rowsep="0" valign="top">=</entry>
</row>
</tbody>
</tgroup>
</table>
以下是我使用的样式表的缩写版本:
<fo:flow flow-name="xsl-region-body">
<xsl:variable name="tableId">
<xsl:value-of select="generate-id()"/>
</xsl:variable>
<xsl:variable name="tableTitle">
<xsl:value-of select="child::title"/>
</xsl:variable>
<xsl:for-each select="child::tgroup">
<xsl:variable name="numColumns" select="@cols"/>
<fo:table id="{$tableId}" table-layout="fixed" inline-progression-dimension="100%" margin-bottom="2mm" margin-top="2mm" table-omit-footer-at-break="true" fox:orphan-content-limit="2 * 1.2em"
fox:widow-content-limit="2 * 1.2em" keep-together.within-column="1">
<!-- Set up the table columns -->
<xsl:for-each select="colspec">
<!-- can be used if table layout has a fixed property... column-width="proportional-column-width(1)" -->
<fo:table-column column-width="proportional-column-width(1)">
<xsl:attribute name="column-number">
<xsl:number count="colspec"/>
</xsl:attribute>
</fo:table-column>
</xsl:for-each>
<xsl:for-each select=".">
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<xsl:if test="$numColumns > '1'">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="$numColumns"/>
</xsl:attribute>
</xsl:if>
<fo:block font-size="10pt" font-style="italic" text-indent="2mm" text-align="center" keep-with-next="always" margin-top="12pt" margin-bottom="2pt">
<xsl:if test="ancestor::isolatep">
<xsl:attribute name="margin-top">1mm</xsl:attribute>
<xsl:attribute name="margin-bottom">1mm</xsl:attribute>
</xsl:if>
<xsl:value-of select="$tableTitle"/>
<fo:retrieve-table-marker retrieve-class-name="table-title" retrieve-position-within-table="first-including-carryover"/>
</fo:block>
<xsl:if test="string-length($tableTitle) > 75">
<fo:block>
<xsl:text>   </xsl:text>
</fo:block>
</xsl:if>
</fo:table-cell>
</fo:table-row>
<xsl:choose>
<xsl:when test="child::thead">
<xsl:for-each select="child::thead">
<xsl:for-each select="child::row">
<xsl:apply-templates select="self::row"/>
</xsl:for-each>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</fo:table-header>
<fo:table-footer keep-together.within-column="1">
<fo:table-row background-color="blue" keep-with-next="always">
<fo:table-cell>
<xsl:if test="$numColumns > '1'">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="$numColumns"/>
</xsl:attribute>
</xsl:if>
<fo:block font-size="9pt" font-style="italic" text-indent="2mm" text-align="center" keep-with-next="always" margin-top="0mm" margin-bottom="0mm">
<fo:retrieve-table-marker retrieve-class-name="footer-continued" retrieve-position="last-starting-within-page"/>
</fo:block>
<fo:block/>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="child::tfoot/row">
<xsl:apply-templates select="self::row"/>
</xsl:for-each>
<xsl:if test="count(ancestor::table//ftnote) > 0">
<xsl:for-each select="ancestor::table//ftnote">
<xsl:if test="not(ancestor::tfoot)">
<fo:table-row>
<fo:table-cell keep-with-next="always">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="$numColumns"/>
</xsl:attribute>
<xsl:attribute name="border-left">solid</xsl:attribute>
<xsl:attribute name="border-right">solid</xsl:attribute>
<xsl:attribute name="border-bottom">solid</xsl:attribute>
<xsl:attribute name="border-width">.2mm</xsl:attribute>
<fo:block>
<fo:marker marker-class-name="footer-continued"/>
</fo:block>
<fo:block margin="0mm" padding="0mm">
<fo:marker marker-class-name="footer-continued"> (Continued)</fo:marker>
</fo:block>
<fo:block-container orphans="2" widows="2" margin-left=".7mm">
<fo:block font-size="8pt" margin-top=".7mm" margin-bottom=".7mm">
<fo:inline vertical-align="super" font-size="6pt">
<xsl:number count="ftnote" from="table" level="any" format="1"/> </fo:inline>
<xsl:for-each select="child::para">
<xsl:choose>
<xsl:when test="position() = 1">
<fo:inline padding-left="7.76mm" font-size="8pt">
<xsl:apply-templates select="self::para"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:block font-size="8pt" margin-left="8.40mm">
<xsl:apply-templates select="self::para"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</xsl:for-each>
</xsl:if>
</fo:table-footer>
<xsl:for-each select="child::tbody">
<fo:table-body>
<xsl:for-each select="child::row">
<xsl:apply-templates select="self::row"/>
</xsl:for-each>
</fo:table-body>
</xsl:for-each>
</xsl:for-each>
</fo:table>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- table row template -->
<xsl:template name="tableRow" match="row">
<fo:table-row keep-together.within-page="always">
<xsl:for-each select="entry">
<xsl:apply-templates select="self::entry"/>
</xsl:for-each>
</fo:table-row>
</xsl:template>
<!-- template for table cells -->
<xsl:template name="tableCell" match="entry">
<fo:table-cell text-align="left" padding-before="1mm" padding-left="1mm" language="en" country="US">
<xsl:variable name="name_start" select="@namest"/>
<xsl:variable name="name_end" select="@nameend"/>
<xsl:variable name="colst">
<xsl:choose>
<xsl:when test="$name_start">
<xsl:for-each select="ancestor-or-self::tgroup/colspec">
<xsl:if test="@colname = $name_start">
<xsl:number count="colspec" from="tgroup"/>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:number value="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="colend">
<xsl:choose>
<xsl:when test="string-length($name_end) > 0">
<xsl:for-each select="ancestor-or-self::tgroup/colspec">
<xsl:if test="@colname = $name_end">
<xsl:number count="colspec" from="tgroup"/>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:number value="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="colspan">
<xsl:choose>
<xsl:when test="$colst and $colend">
<xsl:value-of select="number($colend) - number($colst) + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:number value="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowspan">
<xsl:if test="@morerows > '0'">
<xsl:choose>
<xsl:when test="not(ancestor::tgroup/thead) and (ancestor::tbody/row/entry/@morerows)">
<xsl:value-of select="@morerows + 1"/>
</xsl:when>
<xsl:when test="ancestor::tgroup/thead">
<xsl:value-of select="@morerows + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@morerows + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<!-- Decide which attributes to set for spanning -->
<xsl:if test="$colspan and $rowspan">
<xsl:choose>
<xsl:when test="number($colspan) > 1 and number($rowspan) > 0">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="$colspan"/>
</xsl:attribute>
<xsl:attribute name="number-rows-spanned">
<xsl:value-of select="$rowspan"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="$colspan">
<xsl:choose>
<xsl:when test="number($colspan) > 1">
<!-- just COLSPAN -->
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="$colspan"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="$rowspan > '0'">
<!-- just rowspan -->
<xsl:attribute name="number-rows-spanned">
<xsl:value-of select="$rowspan"/>
</xsl:attribute>
<xsl:if test="ancestor::tgroup/thead">
<xsl:attribute name="overflow">visible</xsl:attribute>
</xsl:if>
</xsl:when>
</xsl:choose>
<!-- Set up cell borders -->
<xsl:attribute name="border">solid</xsl:attribute>
<xsl:attribute name="border-width">.2mm</xsl:attribute>
<!-- Set appropriate attributes based on table section -->
<xsl:if test="ancestor::tbody">
<xsl:attribute name="display-align">auto</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::thead">
<xsl:attribute name="display-align">center</xsl:attribute>
<fo:block>
<fo:marker marker-class-name="table-title"/>
</fo:block>
</xsl:if>
<xsl:if test="ancestor::tfoot">
<fo:block>
<fo:marker marker-class-name="footer-continued"/>
</fo:block>
<fo:block margin="0mm" padding="0mm">
<fo:marker marker-class-name="footer-continued"> (Continued)</fo:marker>
</fo:block>
</xsl:if>
<fo:block>
<fo:marker marker-class-name="table-title"> (Continued) </fo:marker>
</fo:block>
<fo:block-container orphans="2" widows="2">
<fo:block language="en" country="US" font-size="10pt" wrap-option="wrap">
<xsl:if test="ancestor::thead">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::tfoot or count(ancestor::table//ftnote) > 0">
<xsl:attribute name="font-size">9pt</xsl:attribute>
</xsl:if>
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="self::para">
<fo:block font-size="10pt" text-align="left" wrap-option="wrap" orphans="2" widows="2">
<xsl:if test="ancestor::tfoot or count(ancestor::table//ftnote) > 0">
<xsl:attribute name="font-size">9pt</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="self::para"/>
</fo:block>
</xsl:when>
<xsl:when test="self::text() and not(../para)">
<xsl:if test="string-length(self::text()) > 0">
<xsl:value-of select="self::text()"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- This is dangerous, is there a better way?? -->
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:template>
<xsl:template name="footnote" match="ftnote">
<xsl:choose>
<xsl:when test="ancestor::entry and not(ancestor::tfoot)">
<!--just put supscript number in for tables unless it is already in the tfoot section -->
<fo:inline vertical-align="super" font-size="6pt" padding-left=".5mm" margin-left=".7mm">
<xsl:number count="ftnote" from="table" level="any" format="1"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::tfoot">
<fo:block orphans="2" widows="2" keep-together.within-page="always" padding-bottom="1mm">
<fo:inline vertical-align="super" margin-left=".7mm" font-size="6pt">
<xsl:number count="ftnote" from="table" level="any" format="1"/> </fo:inline>
<xsl:for-each select="child::para">
<xsl:choose>
<xsl:when test="position() = 1">
<fo:inline padding-left="7.76mm" font-size="8pt">
<xsl:apply-templates select="self::para"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:block font-size="8pt" margin-left="8.40mm">
<xsl:apply-templates select="self::para"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:footnote keep-together.within-page="always">
<fo:inline vertical-align="super" font-size="9pt" margin-right="6mm">  <xsl:number count="ftnote" level="any" format="1"/>  </fo:inline>
<fo:footnote-body>
<fo:block font-size="9pt">
<fo:inline vertical-align="super" margin-right="2mm">
<xsl:number count="ftnote" level="any" format="1"/>  </fo:inline>
<xsl:for-each select="para">
<xsl:choose>
<xsl:when test="preceding-sibling::para">
<fo:block font-size="9pt" text-align="left">
<xsl:call-template name="para"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="self::para"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:block>
</fo:footnote-body>
</fo:footnote>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我试图在fo:table-footer部分中使用retrieve-table-marker来在页脚中断时检索表标题,但页面永远不会中断。我已经在标记上尝试了检索位置的所有组合而没有任何更改。我还尝试了check-position-table-table属性的所有组合,我不相信它是在最新版本的FOP中实现的,根据:Apache FOP compliance doc
我不明白为什么FOP会破坏tbody部分的表而不是tfoot部分?任何建议或意见将不胜感激。提前谢谢。
我正在编辑这个问题,询问是否有什么东西我在这里不清楚,或者缺少可以让某人回答这个问题的信息或指向我的方向。我已经尝试将overflow属性设置为在表中的各种构造上可见,但没有效果。我还添加了一个屏幕截图,显示了pdf中的问题。