0
我正在嘗試渲染帶有課程信息的pdf。我需要一個內容表,在製作內容之前打破新頁面。在目錄之後,我需要同時製作內容,這意味着每個課程都沒有分頁。但是,我的代碼正確地生成了toc,但每個課程都在單獨的頁面上。我需要所有課程列出沒有分頁符。請幫忙。帶分頁符的XSL-FO問題
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:attribute-set name="normal">
<xsl:attribute name="font-family">'Times New Roman', Times, serif</xsl:attribute>
<xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="line-height">16pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="header">
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="text-align">end</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="footer">
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="text-align">end</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="toc">
<xsl:attribute name="font-family">'Times New Roman', Times, serif</xsl:attribute>
<xsl:attribute name="font-size">12pt</xsl:attribute>
<xsl:attribute name="line-height">12pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="bold">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="title">
<xsl:attribute name="font-family">'Times New Roman', Times, serif</xsl:attribute>
<xsl:attribute name="font-size">28pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
<xsl:attribute name="padding">0.25em</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="subtitle">
<xsl:attribute name="font-family">'Times New Roman', Times, serif</xsl:attribute>
<xsl:attribute name="font-size">24pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
<xsl:attribute name="padding">0.25em</xsl:attribute>
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:attribute-set>
<xsl:variable name="title" select="'Courses'"/>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="main" page-height="11in" page-width="8.5in" margin-top="0.5in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
<fo:region-body margin-top="0.5in" margin-bottom="0.5in"/>
<fo:region-before extent="0.5in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="main"><!-- fo:static-content for header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block xsl:use-attribute-sets="normal header">
<xsl:text>Courses, Page </xsl:text>
<fo:page-number/>
<xsl:text> of </xsl:text>
<fo:page-number-citation ref-id="EndOfDoc"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body"><!-- This is the "main" content --><!-- title -->
<fo:block>
<fo:block xsl:use-attribute-sets="title">
<xsl:value-of select="$title"/>
</fo:block><!-- main content through apply-templates -->
<xsl:apply-templates/>
</fo:block><!-- give empty block at end a known id
go get total page numbers -->
<fo:block id="EndOfDoc"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template><!-- "courses" is root element -->
<xsl:template match="courses">
<xsl:apply-templates select="course" mode="toc"/>
<xsl:apply-templates select="course"/>
</xsl:template>
<xsl:template match="course">
<fo:block id="{generate-id()}" xsl:use-attribute-sets="subtitle">
<xsl:value-of select="catalog_info/title/@short_title"/>
</fo:block>
</xsl:template>
<xsl:template match="course" mode="toc"><!-- Table of Contents -->
<fo:block text-align-last="justify" xsl:use-attribute-sets="toc">
<fo:basic-link internal-destination="{generate-id()}">
<xsl:value-of select="catalog_info/title/@short_title"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="catalog_info/title"/>
</fo:basic-link>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation>
<xsl:attribute name="ref-id">
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
</fo:page-number-citation>
</fo:block>
</xsl:template>