带有重复标题的XSL-FO表

时间:2012-04-16 14:04:55

标签: xml xslt pdf-generation xsl-fo

我会尽力解释这个......

我正在使用XML和XSL-FO生成PDF。该文档有两列表头。我希望只有在到达新页面时才重复表头。它目前正在执行此操作,但表标题在到达另一列时也会重复。我只希望它在不同的页面上重复。任何帮助将不胜感激。

以下是标题的XSL:

<xsl:template match="MAJOR">
    <fo:table rx:table-omit-initial-header="true" width="95%">

        <fo:table-column/>
        <fo:table-header>
            <fo:table-row keep-with-next="always">
                <fo:table-cell>
                    <fo:block font-family="Times New Roman" font-size="8pt" font-weight="bold"><xsl:value-of select="@NAME"/>--Cont'd</fo:block>
                </fo:table-cell>
                <fo:table-cell><fo:block/></fo:table-cell>
            </fo:table-row>
        </fo:table-header>

        <fo:table-body>
            <fo:table-row keep-with-next="always">
                <fo:table-cell>
                    <fo:block font-family="Times New Roman" font-size="8pt" font-weight="bold"><xsl:value-of select="@NAME"/></fo:block>
                </fo:table-cell>
                <fo:table-cell><fo:block/></fo:table-cell>
            </fo:table-row>
            <xsl:apply-templates/>
        </fo:table-body>
    </fo:table>
</xsl:template>

1 个答案:

答案 0 :(得分:0)

你可以这样试试吗?如果这仍然不起作用,您是否也可以附加数据xml文件?

  <xsl:template match="/">
        <fo:table rx:table-omit-initial-header="true" width="95%">
            <fo:table-column/>
                <fo:table-header>
                    <fo:table-row keep-with-next="always">
                        <fo:table-cell>
                            <fo:block font-family="Times New Roman" font-size="8pt" font-weight="bold"><xsl:value-of select="@NAME"/>--Cont'd</fo:block>
                        </fo:table-cell>
                        <fo:table-cell><fo:block/></fo:table-cell>
                    </fo:table-row>
                </fo:table-header>

                <fo:table-body>
                    <xsl:for-each select="MAJOR">
                    <fo:table-row keep-with-next="always">
                        <fo:table-cell>
                            <fo:block font-family="Times New Roman" font-size="8pt" font-weight="bold"><xsl:value-of select="@NAME"/></fo:block>
                        </fo:table-cell>
                        <fo:table-cell><fo:block/></fo:table-cell>
                    </fo:table-row>
                </xsl:for-each>
            </fo:table-body>
        </fo:table>
    </xsl:template>

编辑:只是格式化