1 | <?xml version='1.0'?>
|
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
3 | version='1.0'>
|
---|
4 |
|
---|
5 | <!-- ********************************************************************
|
---|
6 | $Id: autotoc.xsl 9692 2012-12-16 02:31:34Z dcramer $
|
---|
7 | ********************************************************************
|
---|
8 |
|
---|
9 | This file is part of the XSL DocBook Stylesheet distribution.
|
---|
10 | See ../README or http://docbook.sf.net/release/xsl/current/ for
|
---|
11 | copyright and other information.
|
---|
12 |
|
---|
13 | ******************************************************************** -->
|
---|
14 |
|
---|
15 | <xsl:variable name="toc.listitem.type">
|
---|
16 | <xsl:choose>
|
---|
17 | <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when>
|
---|
18 | <xsl:otherwise>li</xsl:otherwise>
|
---|
19 | </xsl:choose>
|
---|
20 | </xsl:variable>
|
---|
21 |
|
---|
22 | <!-- this is just hack because dl and ul aren't completely isomorphic -->
|
---|
23 | <xsl:variable name="toc.dd.type">
|
---|
24 | <xsl:choose>
|
---|
25 | <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when>
|
---|
26 | <xsl:otherwise></xsl:otherwise>
|
---|
27 | </xsl:choose>
|
---|
28 | </xsl:variable>
|
---|
29 |
|
---|
30 | <xsl:template name="make.toc">
|
---|
31 | <xsl:param name="toc-context" select="."/>
|
---|
32 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
33 | <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
|
---|
34 |
|
---|
35 | <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
|
---|
36 |
|
---|
37 | <xsl:variable name="toc.title">
|
---|
38 | <xsl:if test="$toc.title.p">
|
---|
39 | <xsl:choose>
|
---|
40 | <xsl:when test="$make.clean.html != 0">
|
---|
41 | <div class="toc-title">
|
---|
42 | <xsl:call-template name="gentext">
|
---|
43 | <xsl:with-param name="key">TableofContents</xsl:with-param>
|
---|
44 | </xsl:call-template>
|
---|
45 | </div>
|
---|
46 | </xsl:when>
|
---|
47 | <xsl:otherwise>
|
---|
48 | <p>
|
---|
49 | <b>
|
---|
50 | <xsl:call-template name="gentext">
|
---|
51 | <xsl:with-param name="key">TableofContents</xsl:with-param>
|
---|
52 | </xsl:call-template>
|
---|
53 | </b>
|
---|
54 | </p>
|
---|
55 | </xsl:otherwise>
|
---|
56 | </xsl:choose>
|
---|
57 | </xsl:if>
|
---|
58 | </xsl:variable>
|
---|
59 |
|
---|
60 | <xsl:choose>
|
---|
61 | <xsl:when test="$manual.toc != ''">
|
---|
62 | <xsl:variable name="id">
|
---|
63 | <xsl:call-template name="object.id"/>
|
---|
64 | </xsl:variable>
|
---|
65 | <xsl:variable name="toc" select="document($manual.toc, .)"/>
|
---|
66 | <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
|
---|
67 | <xsl:if test="$tocentry and $tocentry/*">
|
---|
68 | <div class="toc">
|
---|
69 | <xsl:copy-of select="$toc.title"/>
|
---|
70 | <xsl:element name="{$toc.list.type}">
|
---|
71 | <xsl:call-template name="toc.list.attributes">
|
---|
72 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
73 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
74 | <xsl:with-param name="nodes" select="$nodes"/>
|
---|
75 | </xsl:call-template>
|
---|
76 | <xsl:call-template name="manual-toc">
|
---|
77 | <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
|
---|
78 | </xsl:call-template>
|
---|
79 | </xsl:element>
|
---|
80 | </div>
|
---|
81 | </xsl:if>
|
---|
82 | </xsl:when>
|
---|
83 | <xsl:otherwise>
|
---|
84 | <xsl:choose>
|
---|
85 | <xsl:when test="$qanda.in.toc != 0">
|
---|
86 | <xsl:if test="$nodes.plus">
|
---|
87 | <div class="toc">
|
---|
88 | <xsl:copy-of select="$toc.title"/>
|
---|
89 | <xsl:element name="{$toc.list.type}">
|
---|
90 | <xsl:call-template name="toc.list.attributes">
|
---|
91 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
92 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
93 | <xsl:with-param name="nodes" select="$nodes"/>
|
---|
94 | </xsl:call-template>
|
---|
95 | <xsl:apply-templates select="$nodes.plus" mode="toc">
|
---|
96 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
97 | </xsl:apply-templates>
|
---|
98 | </xsl:element>
|
---|
99 | </div>
|
---|
100 | </xsl:if>
|
---|
101 | </xsl:when>
|
---|
102 | <xsl:otherwise>
|
---|
103 | <xsl:if test="$nodes">
|
---|
104 | <div class="toc">
|
---|
105 | <xsl:copy-of select="$toc.title"/>
|
---|
106 | <xsl:element name="{$toc.list.type}">
|
---|
107 | <xsl:call-template name="toc.list.attributes">
|
---|
108 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
109 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
110 | <xsl:with-param name="nodes" select="$nodes"/>
|
---|
111 | </xsl:call-template>
|
---|
112 | <xsl:apply-templates select="$nodes" mode="toc">
|
---|
113 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
114 | </xsl:apply-templates>
|
---|
115 | </xsl:element>
|
---|
116 | </div>
|
---|
117 | </xsl:if>
|
---|
118 | </xsl:otherwise>
|
---|
119 | </xsl:choose>
|
---|
120 |
|
---|
121 | </xsl:otherwise>
|
---|
122 | </xsl:choose>
|
---|
123 | </xsl:template>
|
---|
124 |
|
---|
125 | <xsl:template name="toc.list.attributes">
|
---|
126 | <xsl:param name="toc-context" select="."/>
|
---|
127 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
128 | <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
|
---|
129 |
|
---|
130 | <xsl:attribute name="class">toc</xsl:attribute>
|
---|
131 | </xsl:template>
|
---|
132 |
|
---|
133 | <xsl:template name="make.lots">
|
---|
134 | <xsl:param name="toc.params" select="''"/>
|
---|
135 | <xsl:param name="toc"/>
|
---|
136 |
|
---|
137 | <xsl:if test="contains($toc.params, 'toc')">
|
---|
138 | <xsl:copy-of select="$toc"/>
|
---|
139 | </xsl:if>
|
---|
140 |
|
---|
141 | <xsl:if test="contains($toc.params, 'figure')">
|
---|
142 | <xsl:call-template name="list.of.titles">
|
---|
143 | <xsl:with-param name="titles" select="'figure'"/>
|
---|
144 | <xsl:with-param name="nodes" select=".//figure"/>
|
---|
145 | </xsl:call-template>
|
---|
146 | </xsl:if>
|
---|
147 |
|
---|
148 | <xsl:if test="contains($toc.params, 'table')">
|
---|
149 | <xsl:call-template name="list.of.titles">
|
---|
150 | <xsl:with-param name="titles" select="'table'"/>
|
---|
151 | <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
|
---|
152 | </xsl:call-template>
|
---|
153 | </xsl:if>
|
---|
154 |
|
---|
155 | <xsl:if test="contains($toc.params, 'example')">
|
---|
156 | <xsl:call-template name="list.of.titles">
|
---|
157 | <xsl:with-param name="titles" select="'example'"/>
|
---|
158 | <xsl:with-param name="nodes" select=".//example"/>
|
---|
159 | </xsl:call-template>
|
---|
160 | </xsl:if>
|
---|
161 |
|
---|
162 | <xsl:if test="contains($toc.params, 'equation')">
|
---|
163 | <xsl:call-template name="list.of.titles">
|
---|
164 | <xsl:with-param name="titles" select="'equation'"/>
|
---|
165 | <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
|
---|
166 | </xsl:call-template>
|
---|
167 | </xsl:if>
|
---|
168 |
|
---|
169 | <xsl:if test="contains($toc.params, 'procedure')">
|
---|
170 | <xsl:call-template name="list.of.titles">
|
---|
171 | <xsl:with-param name="titles" select="'procedure'"/>
|
---|
172 | <xsl:with-param name="nodes" select=".//procedure[title]"/>
|
---|
173 | </xsl:call-template>
|
---|
174 | </xsl:if>
|
---|
175 | </xsl:template>
|
---|
176 |
|
---|
177 | <!-- ====================================================================== -->
|
---|
178 |
|
---|
179 | <xsl:template name="set.toc">
|
---|
180 | <xsl:param name="toc-context" select="."/>
|
---|
181 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
182 |
|
---|
183 | <xsl:call-template name="make.toc">
|
---|
184 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
185 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
186 | <xsl:with-param name="nodes" select="book|setindex|set"/>
|
---|
187 | </xsl:call-template>
|
---|
188 | </xsl:template>
|
---|
189 |
|
---|
190 | <xsl:template name="division.toc">
|
---|
191 | <xsl:param name="toc-context" select="."/>
|
---|
192 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
193 |
|
---|
194 | <xsl:call-template name="make.toc">
|
---|
195 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
196 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
197 | <xsl:with-param name="nodes" select="part|reference
|
---|
198 | |preface|chapter|appendix
|
---|
199 | |article
|
---|
200 | |topic
|
---|
201 | |bibliography|glossary|index
|
---|
202 | |refentry
|
---|
203 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
204 |
|
---|
205 | </xsl:call-template>
|
---|
206 | </xsl:template>
|
---|
207 |
|
---|
208 | <xsl:template name="component.toc">
|
---|
209 | <xsl:param name="toc-context" select="."/>
|
---|
210 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
211 |
|
---|
212 | <xsl:call-template name="make.toc">
|
---|
213 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
214 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
215 | <xsl:with-param name="nodes" select="section|sect1
|
---|
216 | |simplesect[$simplesect.in.toc != 0]
|
---|
217 | |topic
|
---|
218 | |refentry
|
---|
219 | |article|bibliography|glossary
|
---|
220 | |appendix|index
|
---|
221 | |bridgehead[not(@renderas)
|
---|
222 | and $bridgehead.in.toc != 0]
|
---|
223 | |.//bridgehead[@renderas='sect1'
|
---|
224 | and $bridgehead.in.toc != 0]"/>
|
---|
225 | </xsl:call-template>
|
---|
226 | </xsl:template>
|
---|
227 |
|
---|
228 | <xsl:template name="component.toc.separator">
|
---|
229 | <!-- Customize to output something between
|
---|
230 | component.toc and first output -->
|
---|
231 | </xsl:template>
|
---|
232 |
|
---|
233 | <xsl:template name="section.toc">
|
---|
234 | <xsl:param name="toc-context" select="."/>
|
---|
235 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
236 |
|
---|
237 | <xsl:call-template name="make.toc">
|
---|
238 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
239 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
240 | <xsl:with-param name="nodes"
|
---|
241 | select="section|sect1|sect2|sect3|sect4|sect5|refentry
|
---|
242 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
243 |
|
---|
244 | </xsl:call-template>
|
---|
245 | </xsl:template>
|
---|
246 |
|
---|
247 | <xsl:template name="section.toc.separator">
|
---|
248 | <!-- Customize to output something between
|
---|
249 | section.toc and first output -->
|
---|
250 | </xsl:template>
|
---|
251 | <!-- ==================================================================== -->
|
---|
252 |
|
---|
253 | <xsl:template name="subtoc">
|
---|
254 | <xsl:param name="toc-context" select="."/>
|
---|
255 | <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
|
---|
256 |
|
---|
257 | <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
|
---|
258 |
|
---|
259 | <xsl:variable name="subtoc">
|
---|
260 | <xsl:element name="{$toc.list.type}">
|
---|
261 | <xsl:choose>
|
---|
262 | <xsl:when test="$qanda.in.toc != 0">
|
---|
263 | <xsl:apply-templates mode="toc" select="$nodes.plus">
|
---|
264 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
265 | </xsl:apply-templates>
|
---|
266 | </xsl:when>
|
---|
267 | <xsl:otherwise>
|
---|
268 | <xsl:apply-templates mode="toc" select="$nodes">
|
---|
269 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
270 | </xsl:apply-templates>
|
---|
271 | </xsl:otherwise>
|
---|
272 | </xsl:choose>
|
---|
273 | </xsl:element>
|
---|
274 | </xsl:variable>
|
---|
275 |
|
---|
276 | <xsl:variable name="depth">
|
---|
277 | <xsl:choose>
|
---|
278 | <xsl:when test="local-name(.) = 'section'">
|
---|
279 | <xsl:value-of select="count(ancestor::section) + 1"/>
|
---|
280 | </xsl:when>
|
---|
281 | <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
|
---|
282 | <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
|
---|
283 | <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
|
---|
284 | <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
|
---|
285 | <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
|
---|
286 | <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
|
---|
287 | <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
|
---|
288 | <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
|
---|
289 | <xsl:when test="local-name(.) = 'topic'">1</xsl:when>
|
---|
290 | <xsl:when test="local-name(.) = 'simplesect'">
|
---|
291 | <!-- sigh... -->
|
---|
292 | <xsl:choose>
|
---|
293 | <xsl:when test="local-name(..) = 'section'">
|
---|
294 | <xsl:value-of select="count(ancestor::section)"/>
|
---|
295 | </xsl:when>
|
---|
296 | <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
|
---|
297 | <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
|
---|
298 | <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
|
---|
299 | <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
|
---|
300 | <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
|
---|
301 | <xsl:when test="local-name(..) = 'topic'">2</xsl:when>
|
---|
302 | <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
|
---|
303 | <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
|
---|
304 | <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
|
---|
305 | <xsl:otherwise>1</xsl:otherwise>
|
---|
306 | </xsl:choose>
|
---|
307 | </xsl:when>
|
---|
308 | <xsl:otherwise>0</xsl:otherwise>
|
---|
309 | </xsl:choose>
|
---|
310 | </xsl:variable>
|
---|
311 |
|
---|
312 | <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
|
---|
313 |
|
---|
314 | <xsl:variable name="subtoc.list">
|
---|
315 | <xsl:choose>
|
---|
316 | <xsl:when test="$toc.dd.type = ''">
|
---|
317 | <xsl:copy-of select="$subtoc"/>
|
---|
318 | </xsl:when>
|
---|
319 | <xsl:otherwise>
|
---|
320 | <xsl:element name="{$toc.dd.type}">
|
---|
321 | <xsl:copy-of select="$subtoc"/>
|
---|
322 | </xsl:element>
|
---|
323 | </xsl:otherwise>
|
---|
324 | </xsl:choose>
|
---|
325 | </xsl:variable>
|
---|
326 |
|
---|
327 | <xsl:element name="{$toc.listitem.type}">
|
---|
328 | <xsl:call-template name="toc.line">
|
---|
329 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
330 | </xsl:call-template>
|
---|
331 | <xsl:if test="$toc.listitem.type = 'li' and
|
---|
332 | ( (self::set or self::book or self::part) or
|
---|
333 | $toc.section.depth > $depth) and
|
---|
334 | ( ($qanda.in.toc = 0 and count($nodes)>0) or
|
---|
335 | ($qanda.in.toc != 0 and count($nodes.plus)>0) )
|
---|
336 | and $toc.max.depth > $depth.from.context">
|
---|
337 | <xsl:copy-of select="$subtoc.list"/>
|
---|
338 | </xsl:if>
|
---|
339 | </xsl:element>
|
---|
340 | <xsl:if test="$toc.listitem.type != 'li' and
|
---|
341 | ( (self::set or self::book or self::part) or
|
---|
342 | $toc.section.depth > $depth) and
|
---|
343 | ( ($qanda.in.toc = 0 and count($nodes)>0) or
|
---|
344 | ($qanda.in.toc != 0 and count($nodes.plus)>0) )
|
---|
345 | and $toc.max.depth > $depth.from.context">
|
---|
346 | <xsl:copy-of select="$subtoc.list"/>
|
---|
347 | </xsl:if>
|
---|
348 | </xsl:template>
|
---|
349 |
|
---|
350 | <xsl:template name="toc.line">
|
---|
351 | <xsl:param name="toc-context" select="."/>
|
---|
352 | <xsl:param name="depth" select="1"/>
|
---|
353 | <xsl:param name="depth.from.context" select="8"/>
|
---|
354 |
|
---|
355 | <span>
|
---|
356 | <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
|
---|
357 |
|
---|
358 | <!-- * if $autotoc.label.in.hyperlink is zero, then output the label -->
|
---|
359 | <!-- * before the hyperlinked title (as the DSSSL stylesheet does) -->
|
---|
360 | <xsl:if test="$autotoc.label.in.hyperlink = 0">
|
---|
361 | <xsl:variable name="label">
|
---|
362 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
363 | </xsl:variable>
|
---|
364 | <xsl:copy-of select="$label"/>
|
---|
365 | <xsl:if test="$label != ''">
|
---|
366 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
367 | </xsl:if>
|
---|
368 | </xsl:if>
|
---|
369 |
|
---|
370 | <a>
|
---|
371 | <xsl:attribute name="href">
|
---|
372 | <xsl:call-template name="href.target">
|
---|
373 | <xsl:with-param name="context" select="$toc-context"/>
|
---|
374 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
375 | </xsl:call-template>
|
---|
376 | </xsl:attribute>
|
---|
377 |
|
---|
378 | <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
|
---|
379 | <!-- * as part of the hyperlinked title -->
|
---|
380 | <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
|
---|
381 | <xsl:variable name="label">
|
---|
382 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
383 | </xsl:variable>
|
---|
384 | <xsl:copy-of select="$label"/>
|
---|
385 | <xsl:if test="$label != ''">
|
---|
386 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
387 | </xsl:if>
|
---|
388 | </xsl:if>
|
---|
389 |
|
---|
390 | <xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
---|
391 | </a>
|
---|
392 | </span>
|
---|
393 | </xsl:template>
|
---|
394 |
|
---|
395 | <xsl:template match="book" mode="toc">
|
---|
396 | <xsl:param name="toc-context" select="."/>
|
---|
397 |
|
---|
398 | <xsl:call-template name="subtoc">
|
---|
399 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
400 | <xsl:with-param name="nodes" select="part|reference
|
---|
401 | |preface|chapter|appendix
|
---|
402 | |article
|
---|
403 | |topic
|
---|
404 | |bibliography|glossary|index
|
---|
405 | |refentry
|
---|
406 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
407 | </xsl:call-template>
|
---|
408 | </xsl:template>
|
---|
409 |
|
---|
410 | <xsl:template match="setindex" mode="toc">
|
---|
411 | <xsl:param name="toc-context" select="."/>
|
---|
412 |
|
---|
413 | <!-- If the setindex tag is not empty, it should be it in the TOC -->
|
---|
414 | <xsl:if test="* or $generate.index != 0">
|
---|
415 | <xsl:call-template name="subtoc">
|
---|
416 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
417 | </xsl:call-template>
|
---|
418 | </xsl:if>
|
---|
419 | </xsl:template>
|
---|
420 |
|
---|
421 | <xsl:template match="part|reference" mode="toc">
|
---|
422 | <xsl:param name="toc-context" select="."/>
|
---|
423 |
|
---|
424 | <xsl:call-template name="subtoc">
|
---|
425 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
426 | <xsl:with-param name="nodes" select="appendix|chapter|article|topic
|
---|
427 | |index|glossary|bibliography
|
---|
428 | |preface|reference|refentry
|
---|
429 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
430 | </xsl:call-template>
|
---|
431 | </xsl:template>
|
---|
432 |
|
---|
433 | <xsl:template match="preface|chapter|appendix|article|topic" mode="toc">
|
---|
434 | <xsl:param name="toc-context" select="."/>
|
---|
435 |
|
---|
436 | <xsl:call-template name="subtoc">
|
---|
437 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
438 | <xsl:with-param name="nodes" select="section|sect1
|
---|
439 | |simplesect[$simplesect.in.toc != 0]
|
---|
440 | |topic
|
---|
441 | |refentry
|
---|
442 | |glossary|bibliography|index
|
---|
443 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
444 | </xsl:call-template>
|
---|
445 | </xsl:template>
|
---|
446 |
|
---|
447 | <xsl:template match="sect1" mode="toc">
|
---|
448 | <xsl:param name="toc-context" select="."/>
|
---|
449 | <xsl:call-template name="subtoc">
|
---|
450 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
451 | <xsl:with-param name="nodes" select="sect2
|
---|
452 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
453 | </xsl:call-template>
|
---|
454 | </xsl:template>
|
---|
455 |
|
---|
456 | <xsl:template match="sect2" mode="toc">
|
---|
457 | <xsl:param name="toc-context" select="."/>
|
---|
458 |
|
---|
459 | <xsl:call-template name="subtoc">
|
---|
460 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
461 | <xsl:with-param name="nodes" select="sect3
|
---|
462 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
463 | </xsl:call-template>
|
---|
464 | </xsl:template>
|
---|
465 |
|
---|
466 | <xsl:template match="sect3" mode="toc">
|
---|
467 | <xsl:param name="toc-context" select="."/>
|
---|
468 |
|
---|
469 | <xsl:call-template name="subtoc">
|
---|
470 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
471 | <xsl:with-param name="nodes" select="sect4
|
---|
472 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
473 | </xsl:call-template>
|
---|
474 | </xsl:template>
|
---|
475 |
|
---|
476 | <xsl:template match="sect4" mode="toc">
|
---|
477 | <xsl:param name="toc-context" select="."/>
|
---|
478 |
|
---|
479 | <xsl:call-template name="subtoc">
|
---|
480 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
481 | <xsl:with-param name="nodes" select="sect5
|
---|
482 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
483 | </xsl:call-template>
|
---|
484 | </xsl:template>
|
---|
485 |
|
---|
486 | <xsl:template match="sect5" mode="toc">
|
---|
487 | <xsl:param name="toc-context" select="."/>
|
---|
488 |
|
---|
489 | <xsl:call-template name="subtoc">
|
---|
490 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
491 | </xsl:call-template>
|
---|
492 | </xsl:template>
|
---|
493 |
|
---|
494 | <xsl:template match="simplesect" mode="toc">
|
---|
495 | <xsl:param name="toc-context" select="."/>
|
---|
496 |
|
---|
497 | <xsl:call-template name="subtoc">
|
---|
498 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
499 | </xsl:call-template>
|
---|
500 | </xsl:template>
|
---|
501 |
|
---|
502 | <xsl:template match="section" mode="toc">
|
---|
503 | <xsl:param name="toc-context" select="."/>
|
---|
504 |
|
---|
505 | <xsl:call-template name="subtoc">
|
---|
506 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
507 | <xsl:with-param name="nodes" select="section|refentry
|
---|
508 | |simplesect[$simplesect.in.toc != 0]
|
---|
509 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
510 | </xsl:call-template>
|
---|
511 | </xsl:template>
|
---|
512 |
|
---|
513 | <xsl:template match="topic" mode="toc">
|
---|
514 | <xsl:param name="toc-context" select="."/>
|
---|
515 |
|
---|
516 | <xsl:call-template name="subtoc">
|
---|
517 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
518 | <xsl:with-param name="nodes" select="section|refentry
|
---|
519 | |simplesect[$simplesect.in.toc != 0]
|
---|
520 | |bridgehead[$bridgehead.in.toc != 0]"/>
|
---|
521 | </xsl:call-template>
|
---|
522 | </xsl:template>
|
---|
523 |
|
---|
524 | <xsl:template match="bridgehead" mode="toc">
|
---|
525 | <xsl:param name="toc-context" select="."/>
|
---|
526 |
|
---|
527 | <xsl:if test="$bridgehead.in.toc != 0">
|
---|
528 | <xsl:call-template name="subtoc">
|
---|
529 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
530 | </xsl:call-template>
|
---|
531 | </xsl:if>
|
---|
532 | </xsl:template>
|
---|
533 |
|
---|
534 | <xsl:template match="bibliography|glossary" mode="toc">
|
---|
535 | <xsl:param name="toc-context" select="."/>
|
---|
536 |
|
---|
537 | <xsl:call-template name="subtoc">
|
---|
538 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
539 | </xsl:call-template>
|
---|
540 | </xsl:template>
|
---|
541 |
|
---|
542 | <xsl:template match="index" mode="toc">
|
---|
543 | <xsl:param name="toc-context" select="."/>
|
---|
544 |
|
---|
545 | <!-- If the index tag is not empty, it should be it in the TOC -->
|
---|
546 | <xsl:if test="* or $generate.index != 0">
|
---|
547 | <xsl:call-template name="subtoc">
|
---|
548 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
549 | </xsl:call-template>
|
---|
550 | </xsl:if>
|
---|
551 | </xsl:template>
|
---|
552 |
|
---|
553 | <xsl:template match="refentry" mode="toc">
|
---|
554 | <xsl:param name="toc-context" select="."/>
|
---|
555 |
|
---|
556 | <xsl:variable name="refmeta" select=".//refmeta"/>
|
---|
557 | <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
|
---|
558 | <xsl:variable name="refnamediv" select=".//refnamediv"/>
|
---|
559 | <xsl:variable name="refname" select="$refnamediv//refname"/>
|
---|
560 | <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
|
---|
561 | <xsl:variable name="title">
|
---|
562 | <xsl:choose>
|
---|
563 | <xsl:when test="$refentrytitle">
|
---|
564 | <xsl:apply-templates select="$refentrytitle[1]"
|
---|
565 | mode="titleabbrev.markup"/>
|
---|
566 | </xsl:when>
|
---|
567 | <xsl:when test="$refdesc">
|
---|
568 | <xsl:apply-templates select="$refdesc"
|
---|
569 | mode="titleabbrev.markup"/>
|
---|
570 | </xsl:when>
|
---|
571 | <xsl:when test="$refname">
|
---|
572 | <xsl:apply-templates select="$refname[1]"
|
---|
573 | mode="titleabbrev.markup"/>
|
---|
574 | </xsl:when>
|
---|
575 | </xsl:choose>
|
---|
576 | </xsl:variable>
|
---|
577 |
|
---|
578 | <xsl:element name="{$toc.listitem.type}">
|
---|
579 | <span class='refentrytitle'>
|
---|
580 | <a>
|
---|
581 | <xsl:attribute name="href">
|
---|
582 | <xsl:call-template name="href.target">
|
---|
583 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
584 | </xsl:call-template>
|
---|
585 | </xsl:attribute>
|
---|
586 | <xsl:copy-of select="$title"/>
|
---|
587 | </a>
|
---|
588 | </span>
|
---|
589 | <span class='refpurpose'>
|
---|
590 | <xsl:if test="$annotate.toc != 0">
|
---|
591 | <!-- * DocBook 5 says inlinemediaobject (among other things) -->
|
---|
592 | <!-- * is allowed in refpurpose; so we need to run -->
|
---|
593 | <!-- * apply-templates on refpurpose here, instead of value-of -->
|
---|
594 | <xsl:apply-templates select="refnamediv/refpurpose" mode="no.anchor.mode"/>
|
---|
595 | </xsl:if>
|
---|
596 | </span>
|
---|
597 | </xsl:element>
|
---|
598 | </xsl:template>
|
---|
599 |
|
---|
600 | <xsl:template match="title" mode="toc">
|
---|
601 | <xsl:param name="toc-context" select="."/>
|
---|
602 |
|
---|
603 | <a>
|
---|
604 | <xsl:attribute name="href">
|
---|
605 | <xsl:call-template name="href.target">
|
---|
606 | <xsl:with-param name="object" select=".."/>
|
---|
607 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
608 | </xsl:call-template>
|
---|
609 | </xsl:attribute>
|
---|
610 | <xsl:apply-templates/>
|
---|
611 | </a>
|
---|
612 | </xsl:template>
|
---|
613 |
|
---|
614 | <xsl:template name="manual-toc">
|
---|
615 | <xsl:param name="toc-context" select="."/>
|
---|
616 | <xsl:param name="tocentry"/>
|
---|
617 | <xsl:param name="toc.title.p" select="true()"/>
|
---|
618 | <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
|
---|
619 |
|
---|
620 | <!-- be careful, we don't want to change the current document to the other tree! -->
|
---|
621 |
|
---|
622 | <xsl:if test="$tocentry">
|
---|
623 | <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
|
---|
624 |
|
---|
625 | <xsl:element name="{$toc.listitem.type}">
|
---|
626 | <xsl:variable name="label">
|
---|
627 | <xsl:apply-templates select="$node" mode="label.markup"/>
|
---|
628 | </xsl:variable>
|
---|
629 | <xsl:copy-of select="$label"/>
|
---|
630 | <xsl:if test="$label != ''">
|
---|
631 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
632 | </xsl:if>
|
---|
633 | <a>
|
---|
634 | <xsl:attribute name="href">
|
---|
635 | <xsl:call-template name="href.target">
|
---|
636 | <xsl:with-param name="object" select="$node"/>
|
---|
637 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
638 | </xsl:call-template>
|
---|
639 | </xsl:attribute>
|
---|
640 | <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
|
---|
641 | </a>
|
---|
642 | </xsl:element>
|
---|
643 |
|
---|
644 | <xsl:if test="$tocentry/*">
|
---|
645 | <xsl:element name="{$toc.list.type}">
|
---|
646 | <xsl:call-template name="toc.list.attributes">
|
---|
647 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
648 | <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
|
---|
649 | <xsl:with-param name="nodes" select="$nodes"/>
|
---|
650 | </xsl:call-template>
|
---|
651 | <xsl:call-template name="manual-toc">
|
---|
652 | <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
|
---|
653 | </xsl:call-template>
|
---|
654 | </xsl:element>
|
---|
655 | </xsl:if>
|
---|
656 |
|
---|
657 | <xsl:if test="$tocentry/following-sibling::*">
|
---|
658 | <xsl:call-template name="manual-toc">
|
---|
659 | <xsl:with-param name="tocentry" select="$tocentry/following-sibling::*[1]"/>
|
---|
660 | </xsl:call-template>
|
---|
661 | </xsl:if>
|
---|
662 | </xsl:if>
|
---|
663 | </xsl:template>
|
---|
664 |
|
---|
665 | <!-- ==================================================================== -->
|
---|
666 |
|
---|
667 | <xsl:template name="list.of.titles">
|
---|
668 | <xsl:param name="toc-context" select="."/>
|
---|
669 | <xsl:param name="titles" select="'table'"/>
|
---|
670 | <xsl:param name="nodes" select=".//table"/>
|
---|
671 |
|
---|
672 | <xsl:if test="$nodes">
|
---|
673 | <div class="list-of-{$titles}s">
|
---|
674 | <xsl:choose>
|
---|
675 | <xsl:when test="$make.clean.html != 0">
|
---|
676 | <div class="toc-title">
|
---|
677 | <xsl:call-template name="gentext">
|
---|
678 | <xsl:with-param name="key">
|
---|
679 | <xsl:choose>
|
---|
680 | <xsl:when test="$titles='table'">ListofTables</xsl:when>
|
---|
681 | <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
|
---|
682 | <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
|
---|
683 | <xsl:when test="$titles='example'">ListofExamples</xsl:when>
|
---|
684 | <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
|
---|
685 | <xsl:otherwise>ListofUnknown</xsl:otherwise>
|
---|
686 | </xsl:choose>
|
---|
687 | </xsl:with-param>
|
---|
688 | </xsl:call-template>
|
---|
689 | </div>
|
---|
690 | </xsl:when>
|
---|
691 | <xsl:otherwise>
|
---|
692 | <p>
|
---|
693 | <b>
|
---|
694 | <xsl:call-template name="gentext">
|
---|
695 | <xsl:with-param name="key">
|
---|
696 | <xsl:choose>
|
---|
697 | <xsl:when test="$titles='table'">ListofTables</xsl:when>
|
---|
698 | <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
|
---|
699 | <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
|
---|
700 | <xsl:when test="$titles='example'">ListofExamples</xsl:when>
|
---|
701 | <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
|
---|
702 | <xsl:otherwise>ListofUnknown</xsl:otherwise>
|
---|
703 | </xsl:choose>
|
---|
704 | </xsl:with-param>
|
---|
705 | </xsl:call-template>
|
---|
706 | </b>
|
---|
707 | </p>
|
---|
708 | </xsl:otherwise>
|
---|
709 | </xsl:choose>
|
---|
710 |
|
---|
711 | <xsl:element name="{$toc.list.type}">
|
---|
712 | <xsl:apply-templates select="$nodes" mode="toc">
|
---|
713 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
714 | </xsl:apply-templates>
|
---|
715 | </xsl:element>
|
---|
716 | </div>
|
---|
717 | </xsl:if>
|
---|
718 | </xsl:template>
|
---|
719 |
|
---|
720 | <xsl:template match="figure|table|example|equation|procedure" mode="toc">
|
---|
721 | <xsl:param name="toc-context" select="."/>
|
---|
722 |
|
---|
723 | <xsl:element name="{$toc.listitem.type}">
|
---|
724 | <xsl:variable name="label">
|
---|
725 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
726 | </xsl:variable>
|
---|
727 | <xsl:copy-of select="$label"/>
|
---|
728 | <xsl:if test="$label != ''">
|
---|
729 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
730 | </xsl:if>
|
---|
731 | <a>
|
---|
732 | <xsl:attribute name="href">
|
---|
733 | <xsl:call-template name="href.target">
|
---|
734 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
735 | </xsl:call-template>
|
---|
736 | </xsl:attribute>
|
---|
737 | <xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
---|
738 | </a>
|
---|
739 | </xsl:element>
|
---|
740 | </xsl:template>
|
---|
741 |
|
---|
742 | <!-- Used only if qanda.in.toc parameter is non-zero -->
|
---|
743 | <xsl:template match="qandaset" mode="toc">
|
---|
744 | <xsl:param name="toc-context" select="."/>
|
---|
745 | <xsl:call-template name="subtoc">
|
---|
746 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
747 | <xsl:with-param name="nodes" select="qandadiv | qandaentry"/>
|
---|
748 | </xsl:call-template>
|
---|
749 | </xsl:template>
|
---|
750 |
|
---|
751 | <xsl:template match="qandadiv|qandaentry" mode="toc">
|
---|
752 | <xsl:apply-templates select="." mode="qandatoc.mode"/>
|
---|
753 | </xsl:template>
|
---|
754 |
|
---|
755 | </xsl:stylesheet>
|
---|
756 |
|
---|