source: BOOK/stylesheets/lfs-xsl/xhtml/lfs-toc.xsl@ 4e02ed8

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 4e02ed8 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

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