简体   繁体   中英

XSL-FO Table with repeating headers

I'll try to explain this as best as I can...

I'm generating a PDF with XML and XSL-FO. The document has two columns with table headers. I'd like to have the table headers only repeat when a new page is reached. It currently is doing this, however the table headers are also repeating when it reaches another column. I only want it to repeat on different pages. Any help would be greatly appreciated.

Here is the XSL for the header:

<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>

Could you try it like this? If this is still not working, could you attach the data xml file as well?

  <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>

Edits: Just formatting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM