--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:import href="../html/chunk.xsl"/>
+
+<!-- ********************************************************************
+ $Id$
+ ********************************************************************
+
+ This file is part of the XSL DocBook Stylesheet distribution.
+ See ../README or http://nwalsh.com/docbook/xsl/ for copyright
+ and other information.
+
+ ******************************************************************** -->
+
+<xsl:template match="/">
+ <xsl:choose>
+ <xsl:when test="$rootid != ''">
+ <xsl:choose>
+ <xsl:when test="count(key('id',$rootid)) = 0">
+ <xsl:message terminate="yes">
+ <xsl:text>ID '</xsl:text>
+ <xsl:value-of select="$rootid"/>
+ <xsl:text>' not found in document.</xsl:text>
+ </xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>Formatting from <xsl:value-of select="$rootid"/></xsl:message>
+ <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="/" mode="process.root"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="etoc"/>
+ <xsl:call-template name="plugin.xml"/>
+
+</xsl:template>
+
+<xsl:template name="etoc">
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename" select="'toc.xml'"/>
+ <xsl:with-param name="method" select="'xml'"/>
+ <xsl:with-param name="encoding" select="'utf-8'"/>
+ <xsl:with-param name="indent" select="'yes'"/>
+ <xsl:with-param name="content">
+ <xsl:choose>
+
+ <xsl:when test="$rootid != ''">
+ <xsl:variable name="title">
+ <xsl:if test="$eclipse.autolabel=1">
+ <xsl:variable name="label.markup">
+ <xsl:apply-templates select="key('id',$rootid)" mode="label.markup"/>
+ </xsl:variable>
+ <xsl:if test="normalize-space($label.markup)">
+ <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:apply-templates select="key('id',$rootid)" mode="title.markup"/>
+ </xsl:variable>
+ <xsl:variable name="href">
+ <xsl:call-template name="href.target.with.base.dir">
+ <xsl:with-param name="object" select="key('id',$rootid)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <toc label="{$title}" topic="{$href}">
+ <xsl:apply-templates select="key('id',$rootid)/*" mode="etoc"/>
+ </toc>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:variable name="title">
+ <xsl:if test="$eclipse.autolabel=1">
+ <xsl:variable name="label.markup">
+ <xsl:apply-templates select="/*" mode="label.markup"/>
+ </xsl:variable>
+ <xsl:if test="normalize-space($label.markup)">
+ <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:apply-templates select="/*" mode="title.markup"/>
+ </xsl:variable>
+ <xsl:variable name="href">
+ <xsl:call-template name="href.target.with.base.dir">
+ <xsl:with-param name="object" select="/"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <toc label="{$title}" topic="{$href}">
+ <xsl:apply-templates select="/*/*" mode="etoc"/>
+ </toc>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc">
+ <xsl:variable name="title">
+ <xsl:if test="$eclipse.autolabel=1">
+ <xsl:variable name="label.markup">
+ <xsl:apply-templates select="." mode="label.markup"/>
+ </xsl:variable>
+ <xsl:if test="normalize-space($label.markup)">
+ <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:apply-templates select="." mode="title.markup"/>
+ </xsl:variable>
+
+ <xsl:variable name="href">
+ <xsl:call-template name="href.target.with.base.dir"/>
+ </xsl:variable>
+
+ <topic label="{$title}" href="{$href}">
+ <xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc"/>
+ </topic>
+
+</xsl:template>
+
+<xsl:template match="text()" mode="etoc"/>
+
+<xsl:template name="plugin.xml">
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename" select="'plugin.xml'"/>
+ <xsl:with-param name="method" select="'xml'"/>
+ <xsl:with-param name="encoding" select="'utf-8'"/>
+ <xsl:with-param name="indent" select="'yes'"/>
+ <xsl:with-param name="content">
+ <plugin name="{$eclipse.plugin.name}"
+ id="{$eclipse.plugin.id}"
+ version="1.0"
+ provider-name="{$eclipse.plugin.provider}">
+
+ <extension point="org.eclipse.help.toc">
+ <toc file="toc.xml" primary="true"/>
+ </extension>
+
+ </plugin>
+ </xsl:with-param>
+ </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>