blob: f2f6b511795489f3a4b4885005d7b213a146eb02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<!-- ********************************************************************
$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="toc">
<xsl:choose>
<xsl:when test="*">
<xsl:if test="$process.source.toc != 0">
<!-- if the toc isn't empty, process it -->
<xsl:element name="{$toc.list.type}">
<xsl:apply-templates/>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$process.empty.source.toc != 0">
<xsl:choose>
<xsl:when test="parent::section
or parent::sect1
or parent::sect2
or parent::sect3
or parent::sect4
or parent::sect5">
<xsl:apply-templates select="parent::*"
mode="toc.for.section"/>
</xsl:when>
<xsl:when test="parent::article">
<xsl:apply-templates select="parent::*"
mode="toc.for.component"/>
</xsl:when>
<xsl:when test="parent::book
or parent::part">
<xsl:apply-templates select="parent::*"
mode="toc.for.division"/>
</xsl:when>
<xsl:when test="parent::set">
<xsl:apply-templates select="parent::*"
mode="toc.for.set"/>
</xsl:when>
<!-- there aren't any other contexts that allow toc -->
<xsl:otherwise>
<xsl:message>
<xsl:text>I don't know how to make a TOC in this context!</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tocpart|tocchap
|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
<xsl:variable name="sub-toc">
<xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
<xsl:choose>
<xsl:when test="$toc.list.type = 'dl'">
<dd>
<xsl:element name="{$toc.list.type}">
<xsl:apply-templates select="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
</xsl:element>
</dd>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$toc.list.type}">
<xsl:apply-templates select="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:apply-templates select="tocentry[position() != last()]"/>
<xsl:choose>
<xsl:when test="$toc.list.type = 'dl'">
<dt>
<xsl:apply-templates select="tocentry[position() = last()]"/>
</dt>
<xsl:copy-of select="$sub-toc"/>
</xsl:when>
<xsl:otherwise>
<li>
<xsl:apply-templates select="tocentry[position() = last()]"/>
<xsl:copy-of select="$sub-toc"/>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tocentry|tocfront|tocback">
<xsl:choose>
<xsl:when test="$toc.list.type = 'dl'">
<dt>
<xsl:call-template name="tocentry-content"/>
</dt>
</xsl:when>
<xsl:otherwise>
<li>
<xsl:call-template name="tocentry-content"/>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tocentry[position() = last()]" priority="2">
<xsl:call-template name="tocentry-content"/>
</xsl:template>
<xsl:template name="tocentry-content">
<xsl:variable name="targets" select="key('id',@linkend)"/>
<xsl:variable name="target" select="$targets[1]"/>
<xsl:choose>
<xsl:when test="@linkend">
<xsl:call-template name="check.id.unique">
<xsl:with-param name="linkend" select="@linkend"/>
</xsl:call-template>
<a>
<xsl:attribute name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$target"/>
</xsl:call-template>
</xsl:attribute>
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="*" mode="toc.for.section">
<xsl:call-template name="section.toc"/>
</xsl:template>
<xsl:template match="*" mode="toc.for.component">
<xsl:call-template name="component.toc"/>
</xsl:template>
<xsl:template match="*" mode="toc.for.section">
<xsl:call-template name="section.toc"/>
</xsl:template>
<xsl:template match="*" mode="toc.for.division">
<xsl:call-template name="division.toc"/>
</xsl:template>
<xsl:template match="*" mode="toc.for.set">
<xsl:call-template name="set.toc"/>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="lot|lotentry">
</xsl:template>
</xsl:stylesheet>
|