我使用XSL-FO生成一些PDF文檔,並且有一些表可以跨越多個頁面。在這些情況下,我想要做的是在每個新頁面的開始處重複表格的標題,並在除第一頁之外的所有頁面上使用「(續)」標籤。XSL-FO繼續表頭
我的XSL代碼:
<xsl:template name="Tooling">
<fo:table xsl:use-attribute-sets="tableDefaultLayout">
<fo:table-column column-width="37mm" />
<fo:table-column column-width="37mm" />
<fo:table-column column-width="74mm" />
<fo:table-column column-width="37mm" />
<fo:table-header xsl:use-attribute-sets="categoryDefaultFont">
<fo:table-row height="7.7mm" border="0pt solid black" display-align="before" text-align="start">
<fo:table-cell number-columns-spanned="4" font-size="12pt">
<fo:block margin-top="3mm">
<fo:retrieve-table-marker retrieve-class-name="continued"
retrieve-position-within-table="first-starting"
retrieve-boundary-within-table="table-fragment"/>
 
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row xsl:use-attribute-sets="defaultBodyRow" height="4.7mm" border="0pt solid black">
<fo:table-cell>
<fo:block>
<xsl:text>Item No.</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Part No.</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Description</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Qty Reqd</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body xsl:use-attribute-sets="valueDefaultFont" font-size="8pt">
<xsl:for-each select="1 to 50">
<fo:table-row xsl:use-attribute-sets="defaultBodyRow" border="0pt solid black">
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when test="position()=1">
<fo:marker marker-class-name="continued">
<xsl:text>TOOLING:-</xsl:text>
</fo:marker>
</xsl:when>
<xsl:otherwise>
<fo:marker marker-class-name="continued">
<xsl:text>TOOLING: (continued)</xsl:text>
</fo:marker>
</xsl:otherwise>
</xsl:choose>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:template>
而且FO產生:
<fo:table border-bottom="0.5pt solid black" border-collapse="collapse" border-left="1pt solid black" border-right="1pt solid black" border-top="0.5pt solid black" margin="0mm" padding="0mm" table-layout="fixed" width="100%">
<fo:table-column column-width="37mm"/>
<fo:table-column column-width="37mm"/>
<fo:table-column column-width="74mm"/>
<fo:table-column column-width="37mm"/>
<fo:table-header font-family="sans-serif" font-size="10pt" font-weight="bold">
<fo:table-row border="0pt solid black" display-align="before" height="7.7mm" text-align="start">
<fo:table-cell font-size="12pt" number-columns-spanned="4">
<fo:block margin-top="3mm">
<fo:retrieve-table-marker retrieve-boundary-within-table="table-fragment" retrieve-class-name="continued" retrieve-position-within-table="first-starting"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="0pt solid black" display-align="center" height="4.7mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>Item No.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Part No.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Description</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Qty Reqd</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body font-family="monospace" font-size="8pt" font-weight="normal">
<fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="continued">TOOLING:-</fo:marker>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="continued">TOOLING: (continued)</fo:marker>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
</fo:table-row>
然後持續50行:正如你所看到的第一個具有標誌 「沺: - 」 和所有其他人有一個標記「工具:(續)」,這是我想要的。
我的問題是,我似乎無法使fo:retrieve-table-marker對象正常工作:我嘗試過多次組合「檢索位置」和「檢索邊界」屬性,但每次我的標題的第一行總是空白,在第一頁或其他頁面上。
如果有人能向我解釋我對這些「fo:retrieve-table-marker」和「fo:marker」對象做了什麼錯誤,那將是一個真正的幫助,我一直在努力解決這個問題現在幾天。
我前一陣子也有類似的問題(試圖之前檢索標記第一個fo:marker事件),並在我的第一個檢索標記之前放置一個額外的fo:marker實例來解決它。不過它不應該工作。 – Hobbes
你已經設置了'table-omit-header-at-break =「true」'。由於標記只能用於表頭,如果您不要求顯示錶頭,** Continued **不會出現。否則,你的其他代碼是正確的。 – potame
對不起,「table-omit-header-at-break」是一個複製/粘貼錯誤,我試圖添加這個屬性來看看它做了什麼,但它實際上與我的問題沒有關係。 @霍布斯感謝您的提示,我要試一試 – eipiplusun