<xsl:call-template name="setup.pagemasters"/>
- <xsl:if test="$fop.extensions != 0">
- <xsl:apply-templates select="$document.element" mode="fop.outline"/>
- </xsl:if>
-
<xsl:if test="$fop1.extensions != 0">
<xsl:call-template name="fop1-document-information"/>
+ <xsl:apply-templates select="$document.element" mode="fop1.foxdest"/>
+ </xsl:if>
+
+ <!-- generate bookmark tree -->
+ <xsl:call-template name="generate.bookmarks"/>
+
+ <xsl:apply-templates select="$document.element"/>
+ </fo:root>
+</xsl:template>
+
+<xsl:template name="generate.bookmarks">
+ <xsl:choose>
+ <!-- use standard bookmark elements? -->
+ <xsl:when test="$xsl1.1.bookmarks != 0">
<xsl:variable name="bookmarks">
<xsl:apply-templates select="$document.element"
- mode="fop1.outline"/>
+ mode="bookmark"/>
</xsl:variable>
<xsl:if test="string($bookmarks) != ''">
<fo:bookmark-tree>
<xsl:copy-of select="$bookmarks"/>
</fo:bookmark-tree>
</xsl:if>
- <xsl:apply-templates select="$document.element"
- mode="fop1.foxdest"/>
- </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <!-- pre FOP 1.0 -->
+ <xsl:when test="$fop.extensions != 0">
+ <xsl:apply-templates select="$document.element" mode="fop.outline"/>
+ </xsl:when>
+
+ <!-- FOP 1.0 -->
+ <xsl:when test="$fop1.extensions != 0">
+ <xsl:variable name="bookmarks">
+ <xsl:apply-templates select="$document.element"
+ mode="fop1.outline"/>
+ </xsl:variable>
+ <xsl:if test="string($bookmarks) != ''">
+ <fo:bookmark-tree>
+ <xsl:copy-of select="$bookmarks"/>
+ </fo:bookmark-tree>
+ </xsl:if>
+ </xsl:when>
+
+ <!-- RenderX XEP 4.6 and earlier -->
+ <xsl:when test="$xep.extensions != 0">
+ <xsl:variable name="bookmarks">
+ <xsl:apply-templates select="$document.element" mode="xep.outline"/>
+ </xsl:variable>
+ <xsl:if test="string($bookmarks) != ''">
+ <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
+ <xsl:copy-of select="$bookmarks"/>
+ </rx:outline>
+ </xsl:if>
+ </xsl:when>
+
+ <!-- PTC Arbortext -->
+ <xsl:when test="$arbortext.extensions != 0">
+ <xsl:variable name="bookmarks">
+ <xsl:apply-templates select="$document.element"
+ mode="ati.xsl11.bookmarks"/>
+ </xsl:variable>
+ <xsl:if test="string($bookmarks) != ''">
+ <fo:bookmark-tree>
+ <xsl:copy-of select="$bookmarks"/>
+ </fo:bookmark-tree>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
- <xsl:if test="$xep.extensions != 0">
- <xsl:variable name="bookmarks">
- <xsl:apply-templates select="$document.element" mode="xep.outline"/>
- </xsl:variable>
- <xsl:if test="string($bookmarks) != ''">
- <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
- <xsl:copy-of select="$bookmarks"/>
- </rx:outline>
- </xsl:if>
- </xsl:if>
+<xsl:template match="*" mode="bookmark">
+ <xsl:apply-templates select="*" mode="bookmark"/>
+</xsl:template>
- <xsl:if test="$arbortext.extensions != 0 and $ati.xsl11.bookmarks != 0">
- <xsl:variable name="bookmarks">
- <xsl:apply-templates select="$document.element"
- mode="ati.xsl11.bookmarks"/>
+<xsl:template match="set|book|part|reference|
+ preface|chapter|appendix|article|topic
+ |glossary|bibliography|index|setindex
+ |refentry
+ |sect1|sect2|sect3|sect4|sect5|section"
+ mode="bookmark">
+
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+ <xsl:variable name="bookmark-label">
+ <xsl:apply-templates select="." mode="object.title.markup"/>
+ </xsl:variable>
+
+ <!-- Put the root element bookmark at the same level as its children -->
+ <!-- If the object is a set or book, generate a bookmark for the toc -->
+
+ <xsl:choose>
+ <xsl:when test="self::index and $generate.index = 0"/>
+ <xsl:when test="parent::*">
+ <fo:bookmark internal-destination="{$id}">
+ <xsl:attribute name="starting-state">
+ <xsl:value-of select="$bookmarks.state"/>
+ </xsl:attribute>
+ <fo:bookmark-title>
+ <xsl:value-of select="normalize-space($bookmark-label)"/>
+ </fo:bookmark-title>
+ <xsl:apply-templates select="*" mode="bookmark"/>
+ </fo:bookmark>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:bookmark internal-destination="{$id}">
+ <xsl:attribute name="starting-state">
+ <xsl:value-of select="$bookmarks.state"/>
+ </xsl:attribute>
+ <fo:bookmark-title>
+ <xsl:value-of select="normalize-space($bookmark-label)"/>
+ </fo:bookmark-title>
+ </fo:bookmark>
+
+ <xsl:variable name="toc.params">
+ <xsl:call-template name="find.path.params">
+ <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
+ </xsl:call-template>
</xsl:variable>
- <xsl:if test="string($bookmarks) != ''">
- <fo:bookmark-tree>
- <xsl:copy-of select="$bookmarks"/>
- </fo:bookmark-tree>
- </xsl:if>
- </xsl:if>
- <xsl:apply-templates select="$document.element"/>
- </fo:root>
+ <xsl:if test="contains($toc.params, 'toc')
+ and (book|part|reference|preface|chapter|appendix|article|topic
+ |glossary|bibliography|index|setindex
+ |refentry
+ |sect1|sect2|sect3|sect4|sect5|section)">
+ <fo:bookmark internal-destination="toc...{$id}">
+ <fo:bookmark-title>
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'TableofContents'"/>
+ </xsl:call-template>
+ </fo:bookmark-title>
+ </fo:bookmark>
+ </xsl:if>
+ <xsl:apply-templates select="*" mode="bookmark"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template name="root.messages">