[65b2904] | 1 | <?xml version='1.0' encoding='ISO-8859-1'?>
|
---|
| 2 |
|
---|
| 3 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 4 | xmlns="http://www.w3.org/1999/xhtml"
|
---|
| 5 | version="1.0">
|
---|
| 6 |
|
---|
| 7 | <!-- This stylesheet controls how the TOC are generated -->
|
---|
| 8 |
|
---|
| 9 | <!-- make.toc:
|
---|
| 10 | Using h3 for TOC title.
|
---|
| 11 | Using ul for TOC list style.
|
---|
| 12 | Removed code for $manual.toc and $qanda.in.toc -->
|
---|
| 13 | <!-- The original template is in {docbook-xsl}/xhtml/autotoc.xsl -->
|
---|
| 14 | <xsl:template name="make.toc">
|
---|
| 15 | <xsl:param name="toc-context" select="."/>
|
---|
| 16 | <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
|
---|
| 17 | <xsl:if test="$nodes">
|
---|
| 18 | <div class="toc">
|
---|
| 19 | <h3>
|
---|
| 20 | <xsl:call-template name="gentext">
|
---|
| 21 | <xsl:with-param name="key">TableofContents</xsl:with-param>
|
---|
| 22 | </xsl:call-template>
|
---|
| 23 | </h3>
|
---|
| 24 | <ul>
|
---|
| 25 | <xsl:apply-templates select="$nodes" mode="toc">
|
---|
| 26 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 27 | </xsl:apply-templates>
|
---|
| 28 | </ul>
|
---|
| 29 | </div>
|
---|
| 30 | </xsl:if>
|
---|
| 31 | </xsl:template>
|
---|
| 32 |
|
---|
| 33 | <!-- subtoc:
|
---|
| 34 | Using ul for TOC list style.
|
---|
| 35 | Removed code for $qanda.in.toc
|
---|
| 36 | Removed code for sect* others than sect1 -->
|
---|
| 37 | <!-- The original template is in {docbook-xsl}/xhtml/autotoc.xsl -->
|
---|
| 38 | <xsl:template name="subtoc">
|
---|
| 39 | <xsl:param name="toc-context" select="."/>
|
---|
| 40 | <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
|
---|
| 41 | <xsl:variable name="subtoc">
|
---|
| 42 | <ul>
|
---|
| 43 | <xsl:apply-templates mode="toc" select="$nodes">
|
---|
| 44 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 45 | </xsl:apply-templates>
|
---|
| 46 | </ul>
|
---|
| 47 | </xsl:variable>
|
---|
| 48 | <xsl:variable name="depth">
|
---|
| 49 | <xsl:choose>
|
---|
| 50 | <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
|
---|
| 51 | <xsl:otherwise>0</xsl:otherwise>
|
---|
| 52 | </xsl:choose>
|
---|
| 53 | </xsl:variable>
|
---|
| 54 | <xsl:variable name="depth.from.context"
|
---|
| 55 | select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
|
---|
| 56 | <li class="{name(.)}">
|
---|
| 57 | <xsl:call-template name="toc.line">
|
---|
| 58 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 59 | </xsl:call-template>
|
---|
| 60 | <xsl:if test="$toc.section.depth > $depth and count($nodes)>0
|
---|
| 61 | and $toc.max.depth > $depth.from.context">
|
---|
| 62 | <xsl:copy-of select="$subtoc"/>
|
---|
| 63 | </xsl:if>
|
---|
| 64 | </li>
|
---|
| 65 | </xsl:template>
|
---|
| 66 |
|
---|
| 67 | <!-- toc.line:
|
---|
| 68 | Adding the h* tags and dropping unneded links.
|
---|
| 69 | This template is a full re-made version of the original one. -->
|
---|
| 70 | <!-- The original template is in {docbook-xsl}/xhtml/autotoc.xsl -->
|
---|
| 71 | <xsl:template name="toc.line">
|
---|
| 72 | <xsl:param name="toc-context" select="."/>
|
---|
| 73 | <xsl:choose>
|
---|
| 74 | <!-- For non dummy sect1 targets, create a link. -->
|
---|
| 75 | <xsl:when test="local-name(.) = 'sect1'">
|
---|
| 76 | <xsl:choose>
|
---|
| 77 | <xsl:when test="@role='dummy'">
|
---|
| 78 | <span class="dummy">
|
---|
| 79 | <xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
---|
| 80 | </span>
|
---|
| 81 | </xsl:when>
|
---|
| 82 | <xsl:otherwise>
|
---|
| 83 | <a>
|
---|
| 84 | <xsl:attribute name="href">
|
---|
| 85 | <xsl:call-template name="href.target">
|
---|
| 86 | <xsl:with-param name="context" select="$toc-context"/>
|
---|
| 87 | </xsl:call-template>
|
---|
| 88 | </xsl:attribute>
|
---|
| 89 | <xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
---|
| 90 | </a>
|
---|
| 91 | </xsl:otherwise>
|
---|
| 92 | </xsl:choose>
|
---|
| 93 | </xsl:when>
|
---|
| 94 | <!-- For part, preface, and chapter, use hX and add the label.
|
---|
| 95 | For BLFS, make it a link. -->
|
---|
| 96 | <xsl:when test="local-name(.) = 'part' or local-name(.) = 'preface'
|
---|
| 97 | or local-name(.) = 'chapter'">
|
---|
| 98 | <xsl:choose>
|
---|
| 99 | <xsl:when test="$book-type = 'blfs'">
|
---|
| 100 | <xsl:apply-templates select="." mode="add.hX">
|
---|
| 101 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 102 | <xsl:with-param name="with-link" select="1"/>
|
---|
| 103 | </xsl:apply-templates>
|
---|
| 104 | </xsl:when>
|
---|
| 105 | <xsl:otherwise>
|
---|
| 106 | <xsl:apply-templates select="." mode="add.hX">
|
---|
| 107 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 108 | <xsl:with-param name="with-link" select="0"/>
|
---|
| 109 | </xsl:apply-templates>
|
---|
| 110 | </xsl:otherwise>
|
---|
| 111 | </xsl:choose>
|
---|
| 112 | </xsl:when>
|
---|
| 113 | <!-- For appendix , create a link and add the label.
|
---|
| 114 | For BLFS, use hX. -->
|
---|
| 115 | <xsl:when test="local-name(.) = 'appendix'">
|
---|
| 116 | <xsl:choose>
|
---|
| 117 | <xsl:when test="$book-type = 'blfs'">
|
---|
| 118 | <xsl:apply-templates select="." mode="add.hX">
|
---|
| 119 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 120 | <xsl:with-param name="with-link" select="1"/>
|
---|
| 121 | </xsl:apply-templates>
|
---|
| 122 | </xsl:when>
|
---|
| 123 | <xsl:otherwise>
|
---|
| 124 | <xsl:apply-templates select="." mode="add.link">
|
---|
| 125 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 126 | </xsl:apply-templates>
|
---|
| 127 | </xsl:otherwise>
|
---|
| 128 | </xsl:choose>
|
---|
| 129 | </xsl:when>
|
---|
| 130 | <!-- For other targets like Index, use hX, create a link, and label it. -->
|
---|
| 131 | <xsl:otherwise>
|
---|
| 132 | <xsl:apply-templates select="." mode="add.hX">
|
---|
| 133 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 134 | <xsl:with-param name="with-link" select="1"/>
|
---|
| 135 | </xsl:apply-templates>
|
---|
| 136 | </xsl:otherwise>
|
---|
| 137 | </xsl:choose>
|
---|
| 138 | </xsl:template>
|
---|
| 139 |
|
---|
| 140 | <!-- Self-made template to add hX tags to toc lines. -->
|
---|
| 141 | <xsl:template match="*" mode="add.hX">
|
---|
| 142 | <xsl:param name="toc-context" select="."/>
|
---|
| 143 | <xsl:param name="with-link" select="0"/>
|
---|
| 144 | <xsl:param name="hlevel">
|
---|
| 145 | <xsl:choose>
|
---|
| 146 | <xsl:when test="local-name(.)='chapter' or local-name(.)='preface'">4</xsl:when>
|
---|
| 147 | <xsl:otherwise>3</xsl:otherwise>
|
---|
| 148 | </xsl:choose>
|
---|
| 149 | </xsl:param>
|
---|
| 150 | <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
|
---|
| 151 | <xsl:choose>
|
---|
| 152 | <xsl:when test="$with-link != 0">
|
---|
| 153 | <xsl:apply-templates select="." mode="add.link">
|
---|
| 154 | <xsl:with-param name="toc-context" select="$toc-context"/>
|
---|
| 155 | </xsl:apply-templates>
|
---|
| 156 | </xsl:when>
|
---|
| 157 | <xsl:otherwise>
|
---|
| 158 | <xsl:apply-templates select="." mode="label.and.title"/>
|
---|
| 159 | </xsl:otherwise>
|
---|
| 160 | </xsl:choose>
|
---|
| 161 | </xsl:element>
|
---|
| 162 | </xsl:template>
|
---|
| 163 |
|
---|
| 164 | <!-- Self-made template to made toc line a link. -->
|
---|
| 165 | <xsl:template match="*" mode="add.link">
|
---|
| 166 | <xsl:param name="toc-context" select="."/>
|
---|
| 167 | <a>
|
---|
| 168 | <xsl:attribute name="href">
|
---|
| 169 | <xsl:call-template name="href.target">
|
---|
| 170 | <xsl:with-param name="context" select="$toc-context"/>
|
---|
| 171 | </xsl:call-template>
|
---|
| 172 | </xsl:attribute>
|
---|
| 173 | <xsl:apply-templates select="." mode="label.and.title"/>
|
---|
| 174 | </a>
|
---|
| 175 | </xsl:template>
|
---|
| 176 |
|
---|
| 177 | <!-- Self-made template to write the target title and label it. -->
|
---|
| 178 | <xsl:template match="*" mode="label.and.title">
|
---|
| 179 | <xsl:variable name="label">
|
---|
| 180 | <xsl:apply-templates select="." mode="label.markup"/>
|
---|
| 181 | </xsl:variable>
|
---|
| 182 | <xsl:copy-of select="$label"/>
|
---|
| 183 | <xsl:if test="$label != ''">
|
---|
| 184 | <xsl:value-of select="$autotoc.label.separator"/>
|
---|
| 185 | </xsl:if>
|
---|
| 186 | <xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
---|
| 187 | </xsl:template>
|
---|
| 188 |
|
---|
| 189 | </xsl:stylesheet>
|
---|