2
我正在使用Saxon(9.1)和FOP(0.95)創建目錄和書籤樹。一切工作正常,除了以下FOP輸出:鏈接目標無法解析
WARNING: 1 link target could not be resolved and now point to the top of the page or is dysfunctional.
在生成的PDF,所有鏈接(來自TOC和書籤樹)指向的第一章。這是爲什麼?感謝您的任何幫助。
XML輸入的文件:
<?xml version="1.0"?>
<document>
<header>
<title>This is the title of the document</title>
<author>Mathias Mueller</author>
<date>29/10/2013</date>
</header>
<body>
<chapter level="1">
<chaptitle>This is the title of the first chapter.</chaptitle>
<p>All Saints Day (also known as All Hallows, Solemnity of All Saints...</p>
</chapter>
<chapter level="2">
<chaptitle>This is the title of the second chapter.</chaptitle>
<p>In Western Christian theology, the day commemorates ...</p>
</chapter>
<chapter level="2">
<chaptitle>This is the title of the third chapter.</chaptitle>
<p>The feast of All Saints achieved great prominence in the ninth century, in the reign of the Byzantine Emperor, Leo VI the Wise...</p>
</chapter>
</body>
<documentProperties>
<orientation>portrait</orientation>
<format>A4</format>
</documentProperties>
</document>
XSLT 2.0樣式表(僅定義塊的屬性的屬性集被省去)
<xsl:template match="node()|@*">
<xsl:apply-templates select="node()|@*"/>
</xsl:template>
<xsl:template match="document">
<xsl:element name="fo:root" xmlns="http://www.w3.org/1999/XSL/Format">
<xsl:call-template name="docPr"/>
<xsl:call-template name="bmt"/>
<!--page sequence for TOC-->
<xsl:element name="fo:page-sequence">
<xsl:attribute name="master-reference">A4portrait</xsl:attribute>
<xsl:element name="fo:flow">
<xsl:attribute name="flow-name">xsl-region-body</xsl:attribute>
<xsl:call-template name="toc"/>
</xsl:element>
</xsl:element>
<!--rest-->
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template name="docPr">
<xsl:element name="fo:layout-master-set">
<xsl:if test="documentProperties/orientation eq 'portrait' and documentProperties/format eq 'A4'">
<xsl:element name="fo:simple-page-master" use-attribute-sets="A4portrait">
<xsl:element name="fo:region-body">
<xsl:attribute name="margin-top">25mm</xsl:attribute>
<xsl:attribute name="margin-bottom">20mm</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template name="bmt">
<xsl:element name="fo:bookmark-tree">
<xsl:for-each select="body/chapter">
<xsl:element name="fo:bookmark">
<xsl:attribute name="internal-destination">{generate-id()}</xsl:attribute>
<xsl:element name="fo:bookmark-title">
<xsl:value-of select="chaptitle"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="toc">
<xsl:element name="fo:block">
<xsl:attribute name="break-before">page</xsl:attribute>
<xsl:element name="fo:block" use-attribute-sets="title2-block">
<xsl:text>Table of Contents</xsl:text>
</xsl:element>
<xsl:for-each select="body/chapter">
<xsl:element name="fo:block">
<xsl:attribute name="text-align-last">justify</xsl:attribute>
<xsl:element name="fo:basic-link">
<xsl:attribute name="internal-destination">{generate-id()}</xsl:attribute>
<xsl:value-of select="count(preceding::chapter) + 1"/>
<xsl:text> </xsl:text>
<xsl:value-of select="chaptitle"/>
<xsl:element name="fo:leader">
<xsl:attribute name="leader-pattern">dots</xsl:attribute>
</xsl:element>
<xsl:element name="fo:page-number-citation">
<xsl:attribute name="ref-id">{generate-id()}</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="chapter">
<xsl:element name="fo:page-sequence">
<xsl:attribute name="master-reference">A4portrait</xsl:attribute>
<xsl:attribute name="id">{generate-id()}</xsl:attribute>
<xsl:element name="fo:flow">
<xsl:attribute name="flow-name">xsl-region-body</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="chaptitle">
<xsl:element name="fo:block" use-attribute-sets="title1-block">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="p">
<xsl:element name="fo:block" use-attribute-sets="normal-block">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
謝謝。我嘗試了沒有括號,無濟於事。 –
我的評論中有一個錯誤。你能再檢查一次嗎? –
現在它工作順利,鏈接正確。丹科! –