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