Rocco Rutte:
[apps/madmutt.git] / doc / xslt / xhtml / chunk-common.xsl
1 <?xml version="1.0" encoding="US-ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets. Do not edit this file.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
5
6 <!-- ********************************************************************
7      $Id$
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
12      and other information.
13
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:template name="chunk">
19   <xsl:param name="node" select="."/>
20   <!-- returns 1 if $node is a chunk -->
21
22   <!-- ==================================================================== -->
23   <!-- What's a chunk?
24
25        The root element
26        appendix
27        article
28        bibliography  in article or part or book
29        book
30        chapter
31        colophon
32        glossary      in article or part or book
33        index         in article or part or book
34        part
35        preface
36        refentry
37        reference
38        sect{1,2,3,4,5}  if position()>1 && depth < chunk.section.depth
39        section          if position()>1 && depth < chunk.section.depth
40        set
41        setindex
42                                                                             -->
43   <!-- ==================================================================== -->
44
45 <!--
46   <xsl:message>
47     <xsl:text>chunk: </xsl:text>
48     <xsl:value-of select="name($node)"/>
49     <xsl:text>(</xsl:text>
50     <xsl:value-of select="$node/@id"/>
51     <xsl:text>)</xsl:text>
52     <xsl:text> csd: </xsl:text>
53     <xsl:value-of select="$chunk.section.depth"/>
54     <xsl:text> cfs: </xsl:text>
55     <xsl:value-of select="$chunk.first.sections"/>
56     <xsl:text> ps: </xsl:text>
57     <xsl:value-of select="count($node/parent::section)"/>
58     <xsl:text> prs: </xsl:text>
59     <xsl:value-of select="count($node/preceding-sibling::section)"/>
60   </xsl:message>
61 -->
62
63   <xsl:choose>
64     <xsl:when test="not($node/parent::*)">1</xsl:when>
65
66     <xsl:when test="local-name($node) = 'sect1'                     and $chunk.section.depth &gt;= 1                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::sect1) &gt; 0)">
67       <xsl:text>1</xsl:text>
68     </xsl:when>
69     <xsl:when test="local-name($node) = 'sect2'                     and $chunk.section.depth &gt;= 2                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::sect2) &gt; 0)">
70       <xsl:call-template name="chunk">
71         <xsl:with-param name="node" select="$node/parent::*"/>
72       </xsl:call-template>
73     </xsl:when>
74     <xsl:when test="local-name($node) = 'sect3'                     and $chunk.section.depth &gt;= 3                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::sect3) &gt; 0)">
75       <xsl:call-template name="chunk">
76         <xsl:with-param name="node" select="$node/parent::*"/>
77       </xsl:call-template>
78     </xsl:when>
79     <xsl:when test="local-name($node) = 'sect4'                     and $chunk.section.depth &gt;= 4                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::sect4) &gt; 0)">
80       <xsl:call-template name="chunk">
81         <xsl:with-param name="node" select="$node/parent::*"/>
82       </xsl:call-template>
83     </xsl:when>
84     <xsl:when test="local-name($node) = 'sect5'                     and $chunk.section.depth &gt;= 5                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::sect5) &gt; 0)">
85       <xsl:call-template name="chunk">
86         <xsl:with-param name="node" select="$node/parent::*"/>
87       </xsl:call-template>
88     </xsl:when>
89     <xsl:when test="local-name($node) = 'section'                     and $chunk.section.depth &gt;= count($node/ancestor::section)+1                     and ($chunk.first.sections != 0                          or count($node/preceding-sibling::section) &gt; 0)">
90       <xsl:call-template name="chunk">
91         <xsl:with-param name="node" select="$node/parent::*"/>
92       </xsl:call-template>
93     </xsl:when>
94
95     <xsl:when test="local-name($node)='preface'">1</xsl:when>
96     <xsl:when test="local-name($node)='chapter'">1</xsl:when>
97     <xsl:when test="local-name($node)='appendix'">1</xsl:when>
98     <xsl:when test="local-name($node)='article'">1</xsl:when>
99     <xsl:when test="local-name($node)='part'">1</xsl:when>
100     <xsl:when test="local-name($node)='reference'">1</xsl:when>
101     <xsl:when test="local-name($node)='refentry'">1</xsl:when>
102     <xsl:when test="local-name($node)='index' and $generate.index != 0                     and (local-name($node/parent::*) = 'article'                     or local-name($node/parent::*) = 'book'                     or local-name($node/parent::*) = 'part'                     )">1</xsl:when>
103     <xsl:when test="local-name($node)='bibliography'                     and (local-name($node/parent::*) = 'article'                     or local-name($node/parent::*) = 'book'                     or local-name($node/parent::*) = 'part'                     )">1</xsl:when>
104     <xsl:when test="local-name($node)='glossary'                     and (local-name($node/parent::*) = 'article'                     or local-name($node/parent::*) = 'book'                     or local-name($node/parent::*) = 'part'                     )">1</xsl:when>
105     <xsl:when test="local-name($node)='colophon'">1</xsl:when>
106     <xsl:when test="local-name($node)='book'">1</xsl:when>
107     <xsl:when test="local-name($node)='set'">1</xsl:when>
108     <xsl:when test="local-name($node)='setindex'">1</xsl:when>
109     <xsl:when test="local-name($node)='legalnotice'                     and $generate.legalnotice.link != 0">1</xsl:when>
110     <xsl:otherwise>0</xsl:otherwise>
111   </xsl:choose>
112 </xsl:template>
113
114 <!-- ==================================================================== -->
115
116 <xsl:template match="*" mode="chunk-filename">
117   <!-- returns the filename of a chunk -->
118   <xsl:variable name="ischunk">
119     <xsl:call-template name="chunk"/>
120   </xsl:variable>
121
122   <xsl:variable name="fn">
123     <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
124   </xsl:variable>
125
126   <!--
127   <xsl:message>
128     <xsl:value-of select="$ischunk"/>
129     <xsl:text> (</xsl:text>
130     <xsl:value-of select="local-name(.)"/>
131     <xsl:text>) </xsl:text>
132     <xsl:value-of select="$fn"/>
133     <xsl:text>, </xsl:text>
134     <xsl:call-template name="dbhtml-dir"/>
135   </xsl:message>
136   -->
137
138   <!-- 2003-11-25 by ndw:
139        The following test used to read test="$ischunk != 0 and $fn != ''"
140        I've removed the ischunk part of the test so that href.to.uri and
141        href.from.uri will be fully qualified even if the source or target
142        isn't a chunk. I *think* that if $fn != '' then it's appropriate
143        to put the directory on the front, even if the element isn't a
144        chunk. I could be wrong. -->
145
146   <xsl:if test="$fn != ''">
147     <xsl:call-template name="dbhtml-dir"/>
148   </xsl:if>
149
150   <xsl:value-of select="$fn"/>
151   <!-- You can't add the html.ext here because dbhtml filename= may already -->
152   <!-- have added it. It really does have to be handled in the recursive template -->
153 </xsl:template>
154
155 <xsl:template match="*" mode="recursive-chunk-filename">
156   <xsl:param name="recursive" select="false()"/>
157
158   <!-- returns the filename of a chunk -->
159   <xsl:variable name="ischunk">
160     <xsl:call-template name="chunk"/>
161   </xsl:variable>
162
163   <xsl:variable name="dbhtml-filename">
164     <xsl:call-template name="dbhtml-filename"/>
165   </xsl:variable>
166
167   <xsl:variable name="filename">
168     <xsl:choose>
169       <xsl:when test="$dbhtml-filename != ''">
170         <xsl:value-of select="$dbhtml-filename"/>
171       </xsl:when>
172       <!-- if this is the root element, use the root.filename -->
173       <xsl:when test="not(parent::*) and $root.filename != ''">
174         <xsl:value-of select="$root.filename"/>
175         <xsl:value-of select="$html.ext"/>
176       </xsl:when>
177       <!-- Special case -->
178       <xsl:when test="self::legalnotice and $generate.legalnotice.link != 0">
179         <xsl:variable name="id">
180           <xsl:call-template name="object.id"/>
181         </xsl:variable>
182         <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
183       </xsl:when>
184       <!-- if there's no dbhtml filename, and if we're to use IDs as -->
185       <!-- filenames, then use the ID to generate the filename. -->
186       <xsl:when test="@id and $use.id.as.filename != 0">
187         <xsl:value-of select="@id"/>
188         <xsl:value-of select="$html.ext"/>
189       </xsl:when>
190       <xsl:otherwise/>
191     </xsl:choose>
192   </xsl:variable>
193
194   <xsl:choose>
195     <xsl:when test="$ischunk='0'">
196       <!-- if called on something that isn't a chunk, walk up... -->
197       <xsl:choose>
198         <xsl:when test="count(parent::*)&gt;0">
199           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
200             <xsl:with-param name="recursive" select="$recursive"/>
201           </xsl:apply-templates>
202         </xsl:when>
203         <!-- unless there is no up, in which case return "" -->
204         <xsl:otherwise/>
205       </xsl:choose>
206     </xsl:when>
207
208     <xsl:when test="not($recursive) and $filename != ''">
209       <!-- if this chunk has an explicit name, use it -->
210       <xsl:value-of select="$filename"/>
211     </xsl:when>
212
213     <xsl:when test="self::set">
214       <xsl:value-of select="$root.filename"/>
215       <xsl:if test="not($recursive)">
216         <xsl:value-of select="$html.ext"/>
217       </xsl:if>
218     </xsl:when>
219
220     <xsl:when test="self::book">
221       <xsl:text>bk</xsl:text>
222       <xsl:number level="any" format="01"/>
223       <xsl:if test="not($recursive)">
224         <xsl:value-of select="$html.ext"/>
225       </xsl:if>
226     </xsl:when>
227
228     <xsl:when test="self::article">
229       <xsl:if test="/set">
230         <!-- in a set, make sure we inherit the right book info... -->
231         <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
232           <xsl:with-param name="recursive" select="true()"/>
233         </xsl:apply-templates>
234       </xsl:if>
235
236       <xsl:text>ar</xsl:text>
237       <xsl:number level="any" format="01" from="book"/>
238       <xsl:if test="not($recursive)">
239         <xsl:value-of select="$html.ext"/>
240       </xsl:if>
241     </xsl:when>
242
243     <xsl:when test="self::preface">
244       <xsl:if test="/set">
245         <!-- in a set, make sure we inherit the right book info... -->
246         <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
247           <xsl:with-param name="recursive" select="true()"/>
248         </xsl:apply-templates>
249       </xsl:if>
250
251       <xsl:text>pr</xsl:text>
252       <xsl:number level="any" format="01" from="book"/>
253       <xsl:if test="not($recursive)">
254         <xsl:value-of select="$html.ext"/>
255       </xsl:if>
256     </xsl:when>
257
258     <xsl:when test="self::chapter">
259       <xsl:if test="/set">
260         <!-- in a set, make sure we inherit the right book info... -->
261         <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
262           <xsl:with-param name="recursive" select="true()"/>
263         </xsl:apply-templates>
264       </xsl:if>
265
266       <xsl:text>ch</xsl:text>
267       <xsl:number level="any" format="01" from="book"/>
268       <xsl:if test="not($recursive)">
269         <xsl:value-of select="$html.ext"/>
270       </xsl:if>
271     </xsl:when>
272
273     <xsl:when test="self::appendix">
274       <xsl:if test="/set">
275         <!-- in a set, make sure we inherit the right book info... -->
276         <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
277           <xsl:with-param name="recursive" select="true()"/>
278         </xsl:apply-templates>
279       </xsl:if>
280
281       <xsl:text>ap</xsl:text>
282       <xsl:number level="any" format="a" from="book"/>
283       <xsl:if test="not($recursive)">
284         <xsl:value-of select="$html.ext"/>
285       </xsl:if>
286     </xsl:when>
287
288     <xsl:when test="self::part">
289       <xsl:choose>
290         <xsl:when test="/set">
291           <!-- in a set, make sure we inherit the right book info... -->
292           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
293             <xsl:with-param name="recursive" select="true()"/>
294           </xsl:apply-templates>
295         </xsl:when>
296         <xsl:otherwise>
297         </xsl:otherwise>
298       </xsl:choose>
299
300       <xsl:text>pt</xsl:text>
301       <xsl:number level="any" format="01" from="book"/>
302       <xsl:if test="not($recursive)">
303         <xsl:value-of select="$html.ext"/>
304       </xsl:if>
305     </xsl:when>
306
307     <xsl:when test="self::reference">
308       <xsl:choose>
309         <xsl:when test="/set">
310           <!-- in a set, make sure we inherit the right book info... -->
311           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
312             <xsl:with-param name="recursive" select="true()"/>
313           </xsl:apply-templates>
314         </xsl:when>
315         <xsl:otherwise>
316         </xsl:otherwise>
317       </xsl:choose>
318
319       <xsl:text>rn</xsl:text>
320       <xsl:number level="any" format="01" from="book"/>
321       <xsl:if test="not($recursive)">
322         <xsl:value-of select="$html.ext"/>
323       </xsl:if>
324     </xsl:when>
325
326     <xsl:when test="self::refentry">
327       <xsl:choose>
328         <xsl:when test="parent::reference">
329           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
330             <xsl:with-param name="recursive" select="true()"/>
331           </xsl:apply-templates>
332         </xsl:when>
333         <xsl:otherwise>
334         </xsl:otherwise>
335       </xsl:choose>
336
337       <xsl:text>re</xsl:text>
338       <xsl:number level="any" format="01" from="book"/>
339       <xsl:if test="not($recursive)">
340         <xsl:value-of select="$html.ext"/>
341       </xsl:if>
342     </xsl:when>
343
344     <xsl:when test="self::colophon">
345       <xsl:choose>
346         <xsl:when test="/set">
347           <!-- in a set, make sure we inherit the right book info... -->
348           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
349             <xsl:with-param name="recursive" select="true()"/>
350           </xsl:apply-templates>
351         </xsl:when>
352         <xsl:otherwise>
353         </xsl:otherwise>
354       </xsl:choose>
355
356       <xsl:text>co</xsl:text>
357       <xsl:number level="any" format="01" from="book"/>
358       <xsl:if test="not($recursive)">
359         <xsl:value-of select="$html.ext"/>
360       </xsl:if>
361     </xsl:when>
362
363     <xsl:when test="self::sect1                     or self::sect2                     or self::sect3                     or self::sect4                     or self::sect5                     or self::section">
364       <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
365         <xsl:with-param name="recursive" select="true()"/>
366       </xsl:apply-templates>
367       <xsl:text>s</xsl:text>
368       <xsl:number format="01"/>
369       <xsl:if test="not($recursive)">
370         <xsl:value-of select="$html.ext"/>
371       </xsl:if>
372     </xsl:when>
373
374     <xsl:when test="self::bibliography">
375       <xsl:choose>
376         <xsl:when test="/set">
377           <!-- in a set, make sure we inherit the right book info... -->
378           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
379             <xsl:with-param name="recursive" select="true()"/>
380           </xsl:apply-templates>
381         </xsl:when>
382         <xsl:otherwise>
383         </xsl:otherwise>
384       </xsl:choose>
385
386       <xsl:text>bi</xsl:text>
387       <xsl:number level="any" format="01" from="book"/>
388       <xsl:if test="not($recursive)">
389         <xsl:value-of select="$html.ext"/>
390       </xsl:if>
391     </xsl:when>
392
393     <xsl:when test="self::glossary">
394       <xsl:choose>
395         <xsl:when test="/set">
396           <!-- in a set, make sure we inherit the right book info... -->
397           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
398             <xsl:with-param name="recursive" select="true()"/>
399           </xsl:apply-templates>
400         </xsl:when>
401         <xsl:otherwise>
402         </xsl:otherwise>
403       </xsl:choose>
404
405       <xsl:text>go</xsl:text>
406       <xsl:number level="any" format="01" from="book"/>
407       <xsl:if test="not($recursive)">
408         <xsl:value-of select="$html.ext"/>
409       </xsl:if>
410     </xsl:when>
411
412     <xsl:when test="self::index">
413       <xsl:choose>
414         <xsl:when test="/set">
415           <!-- in a set, make sure we inherit the right book info... -->
416           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
417             <xsl:with-param name="recursive" select="true()"/>
418           </xsl:apply-templates>
419         </xsl:when>
420         <xsl:otherwise>
421         </xsl:otherwise>
422       </xsl:choose>
423
424       <xsl:text>ix</xsl:text>
425       <xsl:number level="any" format="01" from="book"/>
426       <xsl:if test="not($recursive)">
427         <xsl:value-of select="$html.ext"/>
428       </xsl:if>
429     </xsl:when>
430
431     <xsl:when test="self::setindex">
432       <xsl:text>si</xsl:text>
433       <xsl:number level="any" format="01" from="set"/>
434       <xsl:if test="not($recursive)">
435         <xsl:value-of select="$html.ext"/>
436       </xsl:if>
437     </xsl:when>
438
439     <xsl:otherwise>
440       <xsl:text>chunk-filename-error-</xsl:text>
441       <xsl:value-of select="name(.)"/>
442       <xsl:number level="any" format="01" from="set"/>
443       <xsl:if test="not($recursive)">
444         <xsl:value-of select="$html.ext"/>
445       </xsl:if>
446     </xsl:otherwise>
447   </xsl:choose>
448 </xsl:template>
449
450 <!-- ==================================================================== -->
451
452 <xsl:template name="href.target.uri">
453   <xsl:param name="object" select="."/>
454   <xsl:variable name="ischunk">
455     <xsl:call-template name="chunk">
456       <xsl:with-param name="node" select="$object"/>
457     </xsl:call-template>
458   </xsl:variable>
459
460   <xsl:apply-templates mode="chunk-filename" select="$object"/>
461
462   <xsl:if test="$ischunk='0'">
463     <xsl:text>#</xsl:text>
464     <xsl:call-template name="object.id">
465       <xsl:with-param name="object" select="$object"/>
466     </xsl:call-template>
467   </xsl:if>
468 </xsl:template>
469
470 <xsl:template name="href.target">
471   <xsl:param name="context" select="."/>
472   <xsl:param name="object" select="."/>
473
474   <xsl:variable name="href.to.uri">
475     <xsl:call-template name="href.target.uri">
476       <xsl:with-param name="object" select="$object"/>
477     </xsl:call-template>
478   </xsl:variable>
479
480   <xsl:variable name="href.from.uri">
481     <xsl:call-template name="href.target.uri">
482       <xsl:with-param name="object" select="$context"/>
483     </xsl:call-template>
484   </xsl:variable>
485   
486   <!--
487   <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message>
488   <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message>
489   -->
490
491   <xsl:variable name="href.to">
492     <xsl:call-template name="trim.common.uri.paths">
493       <xsl:with-param name="uriA" select="$href.to.uri"/>
494       <xsl:with-param name="uriB" select="$href.from.uri"/>
495       <xsl:with-param name="return" select="'A'"/>
496     </xsl:call-template>
497   </xsl:variable>
498
499   <xsl:variable name="href.from">
500     <xsl:call-template name="trim.common.uri.paths">
501       <xsl:with-param name="uriA" select="$href.to.uri"/>
502       <xsl:with-param name="uriB" select="$href.from.uri"/>
503       <xsl:with-param name="return" select="'B'"/>
504     </xsl:call-template>
505   </xsl:variable>
506
507   <xsl:variable name="depth">
508     <xsl:call-template name="count.uri.path.depth">
509       <xsl:with-param name="filename" select="$href.from"/>
510     </xsl:call-template>
511   </xsl:variable>
512
513   <xsl:variable name="href">
514     <xsl:call-template name="copy-string">
515       <xsl:with-param name="string" select="'../'"/>
516       <xsl:with-param name="count" select="$depth"/>
517     </xsl:call-template>
518     <xsl:value-of select="$href.to"/>
519   </xsl:variable>
520
521   <!--
522   <xsl:message>
523     <xsl:text>In </xsl:text>
524     <xsl:value-of select="name(.)"/>
525     <xsl:text> (</xsl:text>
526     <xsl:value-of select="$href.from"/>
527     <xsl:text>,</xsl:text>
528     <xsl:value-of select="$depth"/>
529     <xsl:text>) </xsl:text>
530     <xsl:value-of select="name($object)"/>
531     <xsl:text> href=</xsl:text>
532     <xsl:value-of select="$href"/>
533   </xsl:message>
534   -->
535
536   <xsl:value-of select="$href"/>
537 </xsl:template>
538
539 <!-- ==================================================================== -->
540
541 <xsl:template name="html.head">
542   <xsl:param name="prev" select="/foo"/>
543   <xsl:param name="next" select="/foo"/>
544   <xsl:variable name="this" select="."/>
545   <xsl:variable name="home" select="/*[1]"/>
546   <xsl:variable name="up" select="parent::*"/>
547
548   <head>
549     <xsl:call-template name="system.head.content"/>
550     <xsl:call-template name="head.content"/>
551
552     <xsl:if test="$home">
553       <link rel="start">
554         <xsl:attribute name="href">
555           <xsl:call-template name="href.target">
556             <xsl:with-param name="object" select="$home"/>
557           </xsl:call-template>
558         </xsl:attribute>
559         <xsl:attribute name="title">
560           <xsl:apply-templates select="$home" mode="object.title.markup.textonly"/>
561         </xsl:attribute>
562       </link>
563     </xsl:if>
564
565     <xsl:if test="$up">
566       <link rel="up">
567         <xsl:attribute name="href">
568           <xsl:call-template name="href.target">
569             <xsl:with-param name="object" select="$up"/>
570           </xsl:call-template>
571         </xsl:attribute>
572         <xsl:attribute name="title">
573           <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
574         </xsl:attribute>
575       </link>
576     </xsl:if>
577
578     <xsl:if test="$prev">
579       <link rel="prev">
580         <xsl:attribute name="href">
581           <xsl:call-template name="href.target">
582             <xsl:with-param name="object" select="$prev"/>
583           </xsl:call-template>
584         </xsl:attribute>
585         <xsl:attribute name="title">
586           <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
587         </xsl:attribute>
588       </link>
589     </xsl:if>
590
591     <xsl:if test="$next">
592       <link rel="next">
593         <xsl:attribute name="href">
594           <xsl:call-template name="href.target">
595             <xsl:with-param name="object" select="$next"/>
596           </xsl:call-template>
597         </xsl:attribute>
598         <xsl:attribute name="title">
599           <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
600         </xsl:attribute>
601       </link>
602     </xsl:if>
603
604     <xsl:if test="$html.extra.head.links != 0">
605       <xsl:for-each select="//part                             |//reference                             |//preface                             |//chapter                             |//article                             |//refentry                             |//appendix[not(parent::article)]|appendix                             |//glossary[not(parent::article)]|glossary                             |//index[not(parent::article)]|index">
606         <link rel="{local-name(.)}">
607           <xsl:attribute name="href">
608             <xsl:call-template name="href.target">
609               <xsl:with-param name="context" select="$this"/>
610               <xsl:with-param name="object" select="."/>
611             </xsl:call-template>
612           </xsl:attribute>
613           <xsl:attribute name="title">
614             <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
615           </xsl:attribute>
616         </link>
617       </xsl:for-each>
618
619       <xsl:for-each select="section|sect1|refsection|refsect1">
620         <link>
621           <xsl:attribute name="rel">
622             <xsl:choose>
623               <xsl:when test="local-name($this) = 'section'                               or local-name($this) = 'refsection'">
624                 <xsl:value-of select="'subsection'"/>
625               </xsl:when>
626               <xsl:otherwise>
627                 <xsl:value-of select="'section'"/>
628               </xsl:otherwise>
629             </xsl:choose>
630           </xsl:attribute>
631           <xsl:attribute name="href">
632             <xsl:call-template name="href.target">
633               <xsl:with-param name="context" select="$this"/>
634               <xsl:with-param name="object" select="."/>
635             </xsl:call-template>
636           </xsl:attribute>
637           <xsl:attribute name="title">
638             <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
639           </xsl:attribute>
640         </link>
641       </xsl:for-each>
642
643       <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3">
644         <link rel="subsection">
645           <xsl:attribute name="href">
646             <xsl:call-template name="href.target">
647               <xsl:with-param name="context" select="$this"/>
648               <xsl:with-param name="object" select="."/>
649             </xsl:call-template>
650           </xsl:attribute>
651           <xsl:attribute name="title">
652             <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
653           </xsl:attribute>
654         </link>
655       </xsl:for-each>
656     </xsl:if>
657
658     <xsl:call-template name="user.head.content"/>
659   </head>
660 </xsl:template>
661
662 <!-- ==================================================================== -->
663
664 <xsl:template name="header.navigation">
665   <xsl:param name="prev" select="/foo"/>
666   <xsl:param name="next" select="/foo"/>
667   <xsl:param name="nav.context"/>
668
669   <xsl:variable name="home" select="/*[1]"/>
670   <xsl:variable name="up" select="parent::*"/>
671
672   <xsl:variable name="row1" select="$navig.showtitles != 0"/>
673   <xsl:variable name="row2" select="count($prev) &gt; 0                                     or (count($up) &gt; 0                                          and generate-id($up) != generate-id($home)                                         and $navig.showtitles != 0)                                     or count($next) &gt; 0"/>
674
675   <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
676     <div class="navheader">
677       <xsl:if test="$row1 or $row2">
678         <table width="100%" summary="Navigation header">
679           <xsl:if test="$row1">
680             <tr>
681               <th colspan="3" align="center">
682                 <xsl:apply-templates select="." mode="object.title.markup"/>
683               </th>
684             </tr>
685           </xsl:if>
686
687           <xsl:if test="$row2">
688             <tr>
689               <td width="20%" align="left">
690                 <xsl:if test="count($prev)&gt;0">
691                   <a accesskey="p">
692                     <xsl:attribute name="href">
693                       <xsl:call-template name="href.target">
694                         <xsl:with-param name="object" select="$prev"/>
695                       </xsl:call-template>
696                     </xsl:attribute>
697                     <xsl:call-template name="navig.content">
698                       <xsl:with-param name="direction" select="'prev'"/>
699                     </xsl:call-template>
700                   </a>
701                 </xsl:if>
702                 <xsl:text>&#160;</xsl:text>
703               </td>
704               <th width="60%" align="center">
705                 <xsl:choose>
706                   <xsl:when test="count($up) &gt; 0                                   and generate-id($up) != generate-id($home)                                   and $navig.showtitles != 0">
707                     <xsl:apply-templates select="$up" mode="object.title.markup"/>
708                   </xsl:when>
709                   <xsl:otherwise>&#160;</xsl:otherwise>
710                 </xsl:choose>
711               </th>
712               <td width="20%" align="right">
713                 <xsl:text>&#160;</xsl:text>
714                 <xsl:if test="count($next)&gt;0">
715                   <a accesskey="n">
716                     <xsl:attribute name="href">
717                       <xsl:call-template name="href.target">
718                         <xsl:with-param name="object" select="$next"/>
719                       </xsl:call-template>
720                     </xsl:attribute>
721                     <xsl:call-template name="navig.content">
722                       <xsl:with-param name="direction" select="'next'"/>
723                     </xsl:call-template>
724                   </a>
725                 </xsl:if>
726               </td>
727             </tr>
728           </xsl:if>
729         </table>
730       </xsl:if>
731       <xsl:if test="$header.rule != 0">
732         <hr/>
733       </xsl:if>
734     </div>
735   </xsl:if>
736 </xsl:template>
737
738 <!-- ==================================================================== -->
739
740 <xsl:template name="footer.navigation">
741   <xsl:param name="prev" select="/foo"/>
742   <xsl:param name="next" select="/foo"/>
743   <xsl:param name="nav.context"/>
744
745   <xsl:variable name="home" select="/*[1]"/>
746   <xsl:variable name="up" select="parent::*"/>
747
748   <xsl:variable name="row1" select="count($prev) &gt; 0                                     or count($up) &gt; 0                                     or count($next) &gt; 0"/>
749
750   <xsl:variable name="row2" select="($prev and $navig.showtitles != 0)                                     or (generate-id($home) != generate-id(.)                                         or $nav.context = 'toc')                                     or ($chunk.tocs.and.lots != 0                                         and $nav.context != 'toc')                                     or ($next and $navig.showtitles != 0)"/>
751
752   <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
753     <div class="navfooter">
754       <xsl:if test="$footer.rule != 0">
755         <hr/>
756       </xsl:if>
757
758       <xsl:if test="$row1 or $row2">
759         <table width="100%" summary="Navigation footer">
760           <xsl:if test="$row1">
761             <tr>
762               <td width="40%" align="left">
763                 <xsl:if test="count($prev)&gt;0">
764                   <a accesskey="p">
765                     <xsl:attribute name="href">
766                       <xsl:call-template name="href.target">
767                         <xsl:with-param name="object" select="$prev"/>
768                       </xsl:call-template>
769                     </xsl:attribute>
770                     <xsl:call-template name="navig.content">
771                       <xsl:with-param name="direction" select="'prev'"/>
772                     </xsl:call-template>
773                   </a>
774                 </xsl:if>
775                 <xsl:text>&#160;</xsl:text>
776               </td>
777               <td width="20%" align="center">
778                 <xsl:choose>
779                   <xsl:when test="count($up)&gt;0                                   and generate-id($up) != generate-id($home)">
780                     <a accesskey="u">
781                       <xsl:attribute name="href">
782                         <xsl:call-template name="href.target">
783                           <xsl:with-param name="object" select="$up"/>
784                         </xsl:call-template>
785                       </xsl:attribute>
786                       <xsl:call-template name="navig.content">
787                         <xsl:with-param name="direction" select="'up'"/>
788                       </xsl:call-template>
789                     </a>
790                   </xsl:when>
791                   <xsl:otherwise>&#160;</xsl:otherwise>
792                 </xsl:choose>
793               </td>
794               <td width="40%" align="right">
795                 <xsl:text>&#160;</xsl:text>
796                 <xsl:if test="count($next)&gt;0">
797                   <a accesskey="n">
798                     <xsl:attribute name="href">
799                       <xsl:call-template name="href.target">
800                         <xsl:with-param name="object" select="$next"/>
801                       </xsl:call-template>
802                     </xsl:attribute>
803                     <xsl:call-template name="navig.content">
804                       <xsl:with-param name="direction" select="'next'"/>
805                     </xsl:call-template>
806                   </a>
807                 </xsl:if>
808               </td>
809             </tr>
810           </xsl:if>
811
812           <xsl:if test="$row2">
813             <tr>
814               <td width="40%" align="left" valign="top">
815                 <xsl:if test="$navig.showtitles != 0">
816                   <xsl:apply-templates select="$prev" mode="object.title.markup"/>
817                 </xsl:if>
818                 <xsl:text>&#160;</xsl:text>
819               </td>
820               <td width="20%" align="center">
821                 <xsl:choose>
822                   <xsl:when test="$home != . or $nav.context = 'toc'">
823                     <a accesskey="h">
824                       <xsl:attribute name="href">
825                         <xsl:call-template name="href.target">
826                           <xsl:with-param name="object" select="$home"/>
827                         </xsl:call-template>
828                       </xsl:attribute>
829                       <xsl:call-template name="navig.content">
830                         <xsl:with-param name="direction" select="'home'"/>
831                       </xsl:call-template>
832                     </a>
833                     <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
834                       <xsl:text>&#160;|&#160;</xsl:text>
835                     </xsl:if>
836                   </xsl:when>
837                   <xsl:otherwise>&#160;</xsl:otherwise>
838                 </xsl:choose>
839
840                 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
841                   <a accesskey="t">
842                     <xsl:attribute name="href">
843                       <xsl:apply-templates select="/*[1]" mode="recursive-chunk-filename">
844                         <xsl:with-param name="recursive" select="true()"/>
845                       </xsl:apply-templates>
846                       <xsl:text>-toc</xsl:text>
847                       <xsl:value-of select="$html.ext"/>
848                     </xsl:attribute>
849                     <xsl:call-template name="gentext">
850                       <xsl:with-param name="key" select="'nav-toc'"/>
851                     </xsl:call-template>
852                   </a>
853                 </xsl:if>
854               </td>
855               <td width="40%" align="right" valign="top">
856                 <xsl:text>&#160;</xsl:text>
857                 <xsl:if test="$navig.showtitles != 0">
858                   <xsl:apply-templates select="$next" mode="object.title.markup"/>
859                 </xsl:if>
860               </td>
861             </tr>
862           </xsl:if>
863         </table>
864       </xsl:if>
865     </div>
866   </xsl:if>
867 </xsl:template>
868
869 <!-- ==================================================================== -->
870
871 <xsl:template name="navig.content">
872     <xsl:param name="direction" select="next"/>
873     <xsl:variable name="navtext">
874         <xsl:choose>
875             <xsl:when test="$direction = 'prev'">
876                 <xsl:call-template name="gentext.nav.prev"/>
877             </xsl:when>
878             <xsl:when test="$direction = 'next'">
879                 <xsl:call-template name="gentext.nav.next"/>
880             </xsl:when>
881             <xsl:when test="$direction = 'up'">
882                 <xsl:call-template name="gentext.nav.up"/>
883             </xsl:when>
884             <xsl:when test="$direction = 'home'">
885                 <xsl:call-template name="gentext.nav.home"/>
886             </xsl:when>
887             <xsl:otherwise>
888                 <xsl:text>xxx</xsl:text>
889             </xsl:otherwise>
890         </xsl:choose>
891     </xsl:variable>
892
893     <xsl:choose>
894         <xsl:when test="$navig.graphics != 0">
895             <img>
896                 <xsl:attribute name="src">
897                     <xsl:value-of select="$navig.graphics.path"/>
898                     <xsl:value-of select="$direction"/>
899                     <xsl:value-of select="$navig.graphics.extension"/>
900                 </xsl:attribute>
901                 <xsl:attribute name="alt">
902                     <xsl:value-of select="$navtext"/>
903                 </xsl:attribute>
904             </img>
905         </xsl:when>
906         <xsl:otherwise>
907             <xsl:value-of select="$navtext"/>
908         </xsl:otherwise>
909     </xsl:choose>
910 </xsl:template>
911
912 <!-- ==================================================================== -->
913
914 <xsl:template match="processing-instruction('dbhtml')">
915   <!-- nop -->
916 </xsl:template>
917
918 <!-- ==================================================================== -->
919
920 <xsl:template name="chunk-element-content">
921   <xsl:param name="prev"/>
922   <xsl:param name="next"/>
923   <xsl:param name="nav.context"/>
924   <xsl:param name="content">
925     <xsl:apply-imports/>
926   </xsl:param>
927
928   <xsl:call-template name="user.preroot"/>
929
930   <html>
931     <xsl:call-template name="html.head">
932       <xsl:with-param name="prev" select="$prev"/>
933       <xsl:with-param name="next" select="$next"/>
934     </xsl:call-template>
935
936     <body>
937       <xsl:call-template name="body.attributes"/>
938       <xsl:call-template name="user.header.navigation"/>
939
940       <xsl:call-template name="header.navigation">
941         <xsl:with-param name="prev" select="$prev"/>
942         <xsl:with-param name="next" select="$next"/>
943         <xsl:with-param name="nav.context" select="$nav.context"/>
944       </xsl:call-template>
945
946       <xsl:call-template name="user.header.content"/>
947
948       <xsl:copy-of select="$content"/>
949
950       <xsl:call-template name="user.footer.content"/>
951
952       <xsl:call-template name="footer.navigation">
953         <xsl:with-param name="prev" select="$prev"/>
954         <xsl:with-param name="next" select="$next"/>
955         <xsl:with-param name="nav.context" select="$nav.context"/>
956       </xsl:call-template>
957
958       <xsl:call-template name="user.footer.navigation"/>
959     </body>
960   </html>
961 </xsl:template>
962
963 </xsl:stylesheet>