source: stylesheets/xhtml/lfs-toc.xsl@ 2ec64b3

v5_1_1
Last change on this file since 2ec64b3 was 2ec64b3, checked in by lfs-dev <lfs-dev@…>, 20 years ago

This commit was manufactured by cvs2svn to create tag 'v5_1_1'.

git-svn-id: http://svn.linuxfromscratch.org/LFS/tags/v5_1_1/BOOK@3757 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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