Imported Upstream version 1.79.2
[platform/upstream/docbook-xsl-stylesheets.git] / xhtml / maketoc.xsl
1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="doc d">
2
3 <!-- ********************************************************************
4
5      This file is part of the XSL DocBook Stylesheet distribution.
6      See ../README or http://cdn.docbook.org/release/xsl/current/ for
7      copyright and other information.
8
9      ******************************************************************** -->
10
11 <!-- ==================================================================== -->
12
13 <xsl:import href="docbook-no-doctype.xsl"/>
14 <xsl:import href="chunk.xsl"/>
15
16 <xsl:output method="xml" indent="no" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
17
18 <xsl:param name="toc.list.type" select="'tocentry'"/>
19
20 <!-- refentry in autotoc.xsl does not use subtoc, so must
21      handle it explicitly here. -->
22 <xsl:template match="d:refentry" mode="toc">
23   <xsl:param name="toc-context" select="."/>
24
25   <xsl:call-template name="subtoc">
26     <xsl:with-param name="toc-context" select="$toc-context"/>
27   </xsl:call-template>
28 </xsl:template>
29
30
31 <xsl:template name="subtoc">
32   <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
33   <xsl:variable name="filename">
34     <xsl:apply-templates select="." mode="chunk-filename"/>
35   </xsl:variable>
36
37   <xsl:variable name="chunk">
38     <xsl:call-template name="chunk"/>
39   </xsl:variable>
40
41   <xsl:if test="$chunk != 0">
42     <xsl:call-template name="indent-spaces"/>
43     <xsl:variable name="id">
44       <xsl:call-template name="object.id"/>
45     </xsl:variable>
46     <d:tocentry linkend="{$id}">
47       <xsl:processing-instruction name="dbhtml">
48         <xsl:text>filename="</xsl:text>
49         <xsl:value-of select="$filename"/>
50         <xsl:text>"</xsl:text>
51       </xsl:processing-instruction>
52       <xsl:text>
53 </xsl:text>
54       <xsl:apply-templates mode="toc" select="$nodes"/>
55       <xsl:call-template name="indent-spaces"/>
56     </d:tocentry>
57     <xsl:text>
58 </xsl:text>
59   </xsl:if>
60 </xsl:template>
61
62 <xsl:template name="indent-spaces">
63   <xsl:param name="node" select="."/>
64   <xsl:text>  </xsl:text>
65   <xsl:if test="$node/parent::*">
66     <xsl:call-template name="indent-spaces">
67       <xsl:with-param name="node" select="$node/parent::*"/>
68     </xsl:call-template>
69   </xsl:if>
70 </xsl:template>
71
72 <!-- ==================================================================== -->
73
74 <xsl:template match="/" priority="-1">
75   <xsl:text>
76 </xsl:text>
77   <toc role="chunk-toc">
78     <xsl:text>
79 </xsl:text>
80     <xsl:apply-templates select="/" mode="toc"/>
81   </toc>
82   <xsl:text>
83 </xsl:text>
84 </xsl:template>
85
86 </xsl:stylesheet>