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

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since b05a965 was 3f8be484, checked in by Jim Gifford <clfs@…>, 19 years ago

r627@server (orig r625): jim | 2005-10-31 12:59:34 -0800
Import of Cross-LFS Book

  • Property mode set to 100644
File size: 5.2 KB
Line 
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 <!-- General settings -->
8 <xsl:param name="generate.toc">
9 appendix nop
10 book toc,title
11 chapter nop
12 part toc
13 preface nop
14 qandadiv nop
15 qandaset nop
16 reference nop
17 sect1 nop
18 sect2 nop
19 sect3 nop
20 sect4 nop
21 sect5 nop
22 section nop
23 set nop
24 </xsl:param>
25
26 <xsl:param name="toc.section.depth">1</xsl:param>
27
28 <xsl:param name="toc.max.depth">3</xsl:param>
29
30 <!-- Making the TOC -->
31 <xsl:template name="make.toc">
32 <xsl:param name="toc-context" select="."/>
33 <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
34 <xsl:if test="$nodes">
35 <div class="toc">
36 <h3>
37 <xsl:call-template name="gentext">
38 <xsl:with-param name="key">TableofContents</xsl:with-param>
39 </xsl:call-template>
40 </h3>
41 <ul>
42 <xsl:apply-templates select="$nodes" mode="toc">
43 <xsl:with-param name="toc-context" select="$toc-context"/>
44 </xsl:apply-templates>
45 </ul>
46 </div>
47 </xsl:if>
48 </xsl:template>
49
50 <!-- Making the subtocs -->
51 <xsl:template name="subtoc">
52 <xsl:param name="toc-context" select="."/>
53 <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
54 <xsl:variable name="subtoc">
55 <ul>
56 <xsl:apply-templates mode="toc" select="$nodes">
57 <xsl:with-param name="toc-context" select="$toc-context"/>
58 </xsl:apply-templates>
59 </ul>
60 </xsl:variable>
61 <xsl:variable name="depth">
62 <xsl:choose>
63 <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
64 <xsl:otherwise>0</xsl:otherwise>
65 </xsl:choose>
66 </xsl:variable>
67 <xsl:variable name="depth.from.context"
68 select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
69 <li class="{name(.)}">
70 <xsl:call-template name="toc.line">
71 <xsl:with-param name="toc-context" select="$toc-context"/>
72 </xsl:call-template>
73 <xsl:if test="$toc.section.depth &gt; $depth and count($nodes)&gt;0
74 and $toc.max.depth &gt; $depth.from.context">
75 <xsl:copy-of select="$subtoc"/>
76 </xsl:if>
77 </li>
78 </xsl:template>
79
80 <!--Adding the h* tags and dropping redundats links-->
81 <xsl:template name="toc.line">
82 <xsl:param name="toc-context" select="."/>
83 <xsl:param name="depth" select="1"/>
84 <xsl:param name="depth.from.context" select="8"/>
85 <xsl:choose>
86 <xsl:when test="local-name(.) = 'sect1'">
87 <a>
88 <xsl:attribute name="href">
89 <xsl:call-template name="href.target">
90 <xsl:with-param name="context" select="$toc-context"/>
91 </xsl:call-template>
92 </xsl:attribute>
93 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
94 </a>
95 </xsl:when>
96 <xsl:when test="local-name(.) = 'appendix'">
97 <a>
98 <xsl:attribute name="href">
99 <xsl:call-template name="href.target">
100 <xsl:with-param name="context" select="$toc-context"/>
101 </xsl:call-template>
102 </xsl:attribute>
103 <xsl:variable name="label">
104 <xsl:apply-templates select="." mode="label.markup"/>
105 </xsl:variable>
106 <xsl:copy-of select="$label"/>
107 <xsl:if test="$label != ''">
108 <xsl:value-of select="$autotoc.label.separator"/>
109 </xsl:if>
110 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
111 </a>
112 </xsl:when>
113 <xsl:when test="local-name(.) = 'chapter' or local-name(.) = 'preface'">
114 <h4>
115 <xsl:variable name="label">
116 <xsl:apply-templates select="." mode="label.markup"/>
117 </xsl:variable>
118 <xsl:copy-of select="$label"/>
119 <xsl:if test="$label != ''">
120 <xsl:value-of select="$autotoc.label.separator"/>
121 </xsl:if>
122 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
123 </h4>
124 </xsl:when>
125 <xsl:when test="local-name(.) = 'part'">
126 <h3>
127 <xsl:variable name="label">
128 <xsl:apply-templates select="." mode="label.markup"/>
129 </xsl:variable>
130 <xsl:copy-of select="$label"/>
131 <xsl:if test="$label != ''">
132 <xsl:value-of select="$autotoc.label.separator"/>
133 </xsl:if>
134 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
135 </h3>
136 </xsl:when>
137 <xsl:otherwise>
138 <h3>
139 <a>
140 <xsl:attribute name="href">
141 <xsl:call-template name="href.target">
142 <xsl:with-param name="context" select="$toc-context"/>
143 </xsl:call-template>
144 </xsl:attribute>
145 <xsl:variable name="label">
146 <xsl:apply-templates select="." mode="label.markup"/>
147 </xsl:variable>
148 <xsl:copy-of select="$label"/>
149 <xsl:if test="$label != ''">
150 <xsl:value-of select="$autotoc.label.separator"/>
151 </xsl:if>
152 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
153 </a>
154 </h3>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:template>
158
159</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.