source: stylesheets/xhtml/lfs-toc.xsl@ 41a6268

10.0 10.1 11.0 6.0 6.1 6.2 6.2.0 6.2.0-rc1 6.2.0-rc2 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 ken/refactor-virt krejzi/svn lazarus nosym perl-modules qt5new systemd-11177 systemd-13485 trunk v5_1 v5_1-pre1 xry111/git-date xry111/git-date-for-trunk xry111/git-date-test
Last change on this file since 41a6268 was 41a6268, checked in by Bruce Dubbs <bdubbs@…>, 17 years ago

Change to stylesheet to provide toc links (from Manuel)

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@2207 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 5.2 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 -->
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 <a>
101 <xsl:attribute name="href">
102 <xsl:call-template name="href.target">
103 <xsl:with-param name="context" select="$toc-context"/>
104 </xsl:call-template>
105 </xsl:attribute>
106 <xsl:variable name="label">
107 <xsl:apply-templates select="." mode="label.markup"/>
108 </xsl:variable>
109 <xsl:copy-of select="$label"/>
110 <xsl:if test="$label != ''">
111 <xsl:value-of select="$autotoc.label.separator"/>
112 </xsl:if>
113 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
114 </a>
115 </h4>
116 </xsl:when>
117 <xsl:when test="local-name(.) = 'part'">
118 <h3>
119 <a>
120 <xsl:attribute name="href">
121 <xsl:call-template name="href.target">
122 <xsl:with-param name="context" select="$toc-context"/>
123 </xsl:call-template>
124 </xsl:attribute>
125 <xsl:variable name="label">
126 <xsl:apply-templates select="." mode="label.markup"/>
127 </xsl:variable>
128 <xsl:copy-of select="$label"/>
129 <xsl:if test="$label != ''">
130 <xsl:value-of select="$autotoc.label.separator"/>
131 </xsl:if>
132 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
133 </a>
134 </h3>
135 </xsl:when>
136 <xsl:otherwise>
137 <h3>
138 <a>
139 <xsl:attribute name="href">
140 <xsl:call-template name="href.target">
141 <xsl:with-param name="context" select="$toc-context"/>
142 </xsl:call-template>
143 </xsl:attribute>
144 <xsl:variable name="label">
145 <xsl:apply-templates select="." mode="label.markup"/>
146 </xsl:variable>
147 <xsl:copy-of select="$label"/>
148 <xsl:if test="$label != ''">
149 <xsl:value-of select="$autotoc.label.separator"/>
150 </xsl:if>
151 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
152 </a>
153 </h3>
154 </xsl:otherwise>
155 </xsl:choose>
156 </xsl:template>
157
158</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.