source: BOOK/stylesheets/lfs-xsl/xhtml/lfs-navigational.xsl@ 75b570d

Last change on this file since 75b570d was 67300de, checked in by Joe Ciccone <jciccone@…>, 16 years ago

Create a clfs-1.1 branch in preperation for a RC.

  • Property mode set to 100644
File size: 14.7 KB
RevLine 
[67300de]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 page header and navigational links
13 are generated. -->
14
15 <!-- html.head:
16 Drop all navigational links from inside head xhtml output. -->
17 <!-- The original template is in {docbook-xsl}/xhtml/chunk-common.xsl -->
18 <xsl:template name="html.head">
19 <head>
20 <xsl:call-template name="system.head.content"/>
21 <xsl:call-template name="head.content"/>
22 <xsl:call-template name="user.head.content"/>
23 </head>
24 </xsl:template>
25
26 <!-- header.navigation:
27 Self-made template that full replaces the original one -->
28 <!-- The original template is in {docbook-xsl}/xhtml/chunk-common.xsl -->
29 <xsl:template name="header.navigation">
30 <xsl:param name="prev" select="/foo"/>
31 <xsl:param name="next" select="/foo"/>
32 <xsl:variable name="up" select="parent::*"/>
33 <xsl:variable name="home" select="/*[1]"/>
34 <!-- Don't generate the header in index.html -->
35 <xsl:if test="$home != .">
36 <div class="navheader">
37 <!-- Book title and version -->
38 <h4>
39 <xsl:apply-templates select="$home" mode="object.title.markup"/>
40 <xsl:text> - </xsl:text>
41 <xsl:apply-templates select="$home" mode="object.subtitle.markup"/>
42 </h4>
43 <!-- Except for preface, part, and index, add the title of the parent -->
44 <xsl:if test="$up != $home">
45 <h3>
46 <xsl:apply-templates select="$up" mode="object.title.markup"/>
47 </h3>
48 </xsl:if>
49 <!-- Create header navigational links -->
50 <xsl:call-template name="navigational.links">
51 <xsl:with-param name="prev" select="$prev"/>
52 <xsl:with-param name="next" select="$next"/>
53 <xsl:with-param name="up" select="$up"/>
54 <xsl:with-param name="home" select="$home"/>
55 </xsl:call-template>
56 </div>
57 </xsl:if>
58 </xsl:template>
59
60 <!-- footer.navigation:
61 Self-made template that full replaces the original one -->
62 <!-- The original template is in {docbook-xsl}/xhtml/chunk-common.xsl -->
63 <xsl:template name="footer.navigation">
64 <xsl:param name="prev" select="/foo"/>
65 <xsl:param name="next" select="/foo"/>
66 <xsl:variable name="up" select="parent::*"/>
67 <xsl:variable name="home" select="/*[1]"/>
68 <!-- Create footer navigational links -->
69 <div class="navfooter">
70 <xsl:call-template name="navigational.links">
71 <xsl:with-param name="prev" select="$prev"/>
72 <xsl:with-param name="next" select="$next"/>
73 <xsl:with-param name="up" select="$up"/>
74 <xsl:with-param name="home" select="$home"/>
75 </xsl:call-template>
76 </div>
77 <!-- In HLFS, add the features.js call -->
78 <xsl:if test="$book-type = 'hlfs'">
79 <script type="text/javascript">
80 <xsl:attribute name="src">
81 <xsl:choose>
82 <xsl:when test="local-name(.)='book' or local-name(.)='part' or
83 local-name(.)='index'">../features.js</xsl:when>
84 <xsl:otherwise>../../features.js</xsl:otherwise>
85 </xsl:choose>
86 </xsl:attribute>
87 </script>
88 </xsl:if>
89 </xsl:template>
90
91 <!-- navigational.links:
92 Self-made template to generate navigational links.
93 Most of the code come from the original header.navigation and
94 footer.navigation templates, with this changes:
95 Changed the output format from table to ul.
96 Placed the same links on both header and footer.
97 Added a title attribute to the link containing the target title
98 (it content is displayed when placing the mouse over the link)
99 For "Prev" and "Next" links, added the target title under it.
100 When "Next" target is the Index, added gentext support for the
101 Index title.
102 Skip links to dummy sect1. -->
103 <xsl:template name="navigational.links">
104 <xsl:param name="prev"/>
105 <xsl:param name="next"/>
106 <xsl:param name="up"/>
107 <xsl:param name="home"/>
108 <ul>
109 <!-- No prev link when prev is home -->
110 <xsl:if test="count($prev)&gt;0 and $prev != $home">
111 <li class="prev">
112 <xsl:choose>
113
114 <!-- If prev is a dummy sect1 that is the first one in a chapter,
115 links to the parent chapter.-->
116 <xsl:when test="$prev[@role='dummy'] and
117 count(preceding-sibling::sect1)=1">
118 <a accesskey="p">
119 <xsl:attribute name="href">
120 <xsl:call-template name="href.target">
121 <xsl:with-param name="object" select=".."/>
122 </xsl:call-template>
123 </xsl:attribute>
124 <xsl:attribute name="title">
125 <xsl:value-of select="../title"/>
126 </xsl:attribute>
127 <xsl:call-template name="navig.content">
128 <xsl:with-param name="direction" select="'prev'"/>
129 </xsl:call-template>
130 </a>
131 <p>
132 <xsl:value-of select="../title"/>
133 </p>
134 </xsl:when>
135
136 <!-- If prev is a dummy sect1 that is not the first one in a chapter,
137 links to the previous sect1.-->
138 <xsl:when test="$prev[@role='dummy'] and
139 count(preceding-sibling::sect1)&gt;1">
140 <a accesskey="p">
141 <xsl:attribute name="href">
142 <xsl:call-template name="href.target">
143 <xsl:with-param name="object" select="preceding-sibling::sect1[position()=2]"/>
144 </xsl:call-template>
145 </xsl:attribute>
146 <xsl:attribute name="title">
147 <xsl:value-of select="preceding-sibling::sect1[position()=2]/title"/>
148 </xsl:attribute>
149 <xsl:call-template name="navig.content">
150 <xsl:with-param name="direction" select="'prev'"/>
151 </xsl:call-template>
152 </a>
153 <p>
154 <xsl:value-of select="preceding-sibling::sect1[position()=2]/title"/>
155 </p>
156 </xsl:when>
157
158 <!-- Code for the "To Boot or To Chroot" CLFS links jumps. -->
159 <xsl:when test="$prev[@id='ch-chroot-devices'] or $prev[@id='ch-boot-whatnext']">
160 <a accesskey="p">
161 <xsl:attribute name="href">
162 <xsl:call-template name="href.target">
163 <xsl:with-param name="object" select="//sect1[@id='ch-temp-system-choose']"/>
164 </xsl:call-template>
165 </xsl:attribute>
166 <xsl:attribute name="title">
167 <xsl:value-of select="//sect1[@id='ch-temp-system-choose']/title"/>
168 </xsl:attribute>
169 <xsl:call-template name="navig.content">
170 <xsl:with-param name="direction" select="'prev'"/>
171 </xsl:call-template>
172 </a>
173 <p>
174 <xsl:value-of select="//sect1[@id='ch-temp-system-choose']/title"/>
175 </p>
176 </xsl:when>
177
178 <!-- Normal prev links -->
179 <xsl:otherwise>
180 <a accesskey="p">
181 <xsl:attribute name="href">
182 <xsl:call-template name="href.target">
183 <xsl:with-param name="object" select="$prev"/>
184 </xsl:call-template>
185 </xsl:attribute>
186 <xsl:attribute name="title">
187 <xsl:value-of select="$prev/title"/>
188 </xsl:attribute>
189 <xsl:call-template name="navig.content">
190 <xsl:with-param name="direction" select="'prev'"/>
191 </xsl:call-template>
192 </a>
193 <p>
194 <xsl:value-of select="$prev/title"/>
195 </p>
196 </xsl:otherwise>
197 </xsl:choose>
198 </li>
199 </xsl:if>
200
201
202 <!-- Next link except in the last page and in the CLFS "choose" page -->
203 <xsl:if test="count($next)&gt;0 and (not(@id) or @id!='ch-temp-system-choose')">
204 <li class="next">
205 <xsl:choose>
206
207 <!-- Current page is sect1 a next is a dummy sect1, link to the next one -->
208 <xsl:when test="$next[@role='dummy'] and local-name(.) = 'sect1'">
209 <a accesskey="n">
210 <xsl:attribute name="href">
211 <xsl:call-template name="href.target">
212 <xsl:with-param name="object" select="following-sibling::sect1[position()=2]"/>
213 </xsl:call-template>
214 </xsl:attribute>
215 <xsl:attribute name="title">
216 <xsl:value-of select="following-sibling::sect1[position()=2]/title"/>
217 </xsl:attribute>
218 <xsl:call-template name="navig.content">
219 <xsl:with-param name="direction" select="'next'"/>
220 </xsl:call-template>
221 </a>
222 <p>
223 <xsl:value-of select="following-sibling::sect1[position()=2]/title"/>
224 </p>
225 </xsl:when>
226
227 <!-- Current page is chapter and next is a dummy sect1, link to the next one -->
228 <xsl:when test="$next[@role='dummy'] and local-name(.) = 'chapter'">
229 <a accesskey="n">
230 <xsl:attribute name="href">
231 <xsl:call-template name="href.target">
232 <xsl:with-param name="object" select="descendant::sect1[position()=2]"/>
233 </xsl:call-template>
234 </xsl:attribute>
235 <xsl:attribute name="title">
236 <xsl:value-of select="descendant::sect1[position()=2]/title"/>
237 </xsl:attribute>
238 <xsl:call-template name="navig.content">
239 <xsl:with-param name="direction" select="'next'"/>
240 </xsl:call-template>
241 </a>
242 <p>
243 <xsl:value-of select="descendant::sect1[position()=2]/title"/>
244 </p>
245 </xsl:when>
246
247 <!-- Code for the "To Boot or To Chroot" CLFS links jumps. -->
248 <xsl:when test="$next[@id='chapter-chroot'] or $next[@id='chapter-boot']">
249 <a accesskey="n">
250 <xsl:attribute name="href">
251 <xsl:call-template name="href.target">
252 <xsl:with-param name="object" select="//part[@id='part5']"/>
253 </xsl:call-template>
254 </xsl:attribute>
255 <xsl:attribute name="title">
256 <xsl:value-of select="//part[@id='part5']/title"/>
257 </xsl:attribute>
258 <xsl:call-template name="navig.content">
259 <xsl:with-param name="direction" select="'next'"/>
260 </xsl:call-template>
261 </a>
262 <p>
263 <xsl:value-of select="//part[@id='part5']/title"/>
264 </p>
265 </xsl:when>
266
267 <!-- Normal next links. Take care of Index gentext support. -->
268 <xsl:otherwise>
269 <a accesskey="n">
270 <xsl:attribute name="href">
271 <xsl:call-template name="href.target">
272 <xsl:with-param name="object" select="$next"/>
273 </xsl:call-template>
274 </xsl:attribute>
275 <xsl:attribute name="title">
276 <xsl:choose>
277 <xsl:when test="local-name($next)='index'">
278 <xsl:call-template name="gentext">
279 <xsl:with-param name="key">Index</xsl:with-param>
280 </xsl:call-template>
281 </xsl:when>
282 <xsl:otherwise>
283 <xsl:value-of select="$next/title"/>
284 </xsl:otherwise>
285 </xsl:choose>
286 </xsl:attribute>
287 <xsl:call-template name="navig.content">
288 <xsl:with-param name="direction" select="'next'"/>
289 </xsl:call-template>
290 </a>
291 <p>
292 <xsl:choose>
293 <xsl:when test="local-name($next)='index'">
294 <xsl:call-template name="gentext">
295 <xsl:with-param name="key">Index</xsl:with-param>
296 </xsl:call-template>
297 </xsl:when>
298 <xsl:otherwise>
299 <xsl:value-of select="$next/title"/>
300 </xsl:otherwise>
301 </xsl:choose>
302 </p>
303 </xsl:otherwise>
304 </xsl:choose>
305 </li>
306 </xsl:if>
307
308
309 <li class="up">
310 <xsl:choose>
311 <!-- Up link except if up is home -->
312 <xsl:when test="count($up)&gt;0 and $up != $home">
313 <a accesskey="u">
314 <xsl:attribute name="href">
315 <xsl:call-template name="href.target">
316 <xsl:with-param name="object" select="$up"/>
317 </xsl:call-template>
318 </xsl:attribute>
319 <xsl:attribute name="title">
320 <xsl:apply-templates select="$up" mode="object.title.markup"/>
321 </xsl:attribute>
322 <xsl:call-template name="navig.content">
323 <xsl:with-param name="direction" select="'up'"/>
324 </xsl:call-template>
325 </a>
326 </xsl:when>
327 <!-- Hack to let the CSS code do its work when there is no up link -->
328 <xsl:otherwise>
329 <xsl:text>.</xsl:text>
330 </xsl:otherwise>
331 </xsl:choose>
332 </li>
333
334
335 <li class="home">
336 <xsl:choose>
337 <!-- No home link in home page -->
338 <xsl:when test="$home != .">
339 <a accesskey="h">
340 <xsl:attribute name="href">
341 <xsl:call-template name="href.target">
342 <xsl:with-param name="object" select="$home"/>
343 </xsl:call-template>
344 </xsl:attribute>
345 <xsl:attribute name="title">
346 <xsl:value-of select="$home/bookinfo/title"/>
347 <xsl:text> - </xsl:text>
348 <xsl:value-of select="$home/bookinfo/subtitle"/>
349 </xsl:attribute>
350 <xsl:call-template name="navig.content">
351 <xsl:with-param name="direction" select="'home'"/>
352 </xsl:call-template>
353 </a>
354 </xsl:when>
355 <!-- Hack to let the CSS code do its work when there is no home link -->
356 <xsl:otherwise>
357 <xsl:text>.</xsl:text>
358 </xsl:otherwise>
359 </xsl:choose>
360 </li>
361 </ul>
362 </xsl:template>
363
364</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.