]> granicus.if.org Git - apache/blob - docs/manual/style/xsl/common.xsl
1873135cc1c7c0ad939902e4a76b94b133abd2b6
[apache] / docs / manual / style / xsl / common.xsl
1 <?xml version="1.0"?>
2
3 <!--
4  Copyright 2002-2004 The Apache Software Foundation
5
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 -->
18
19 <!DOCTYPE xsl:stylesheet [
20     <!ENTITY nbsp SYSTEM "util/nbsp.xml">
21     <!ENTITY lf SYSTEM "util/lf.xml">
22 ]>
23 <xsl:stylesheet version="1.0"
24               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25                   xmlns="http://www.w3.org/1999/xhtml">
26
27 <!--                                                                      -->
28 <!-- Please, don't hard-code output strings! Use the language             -->
29 <!-- files and the translation "stuff"...                                 -->
30 <!--                                                                      -->
31
32 <!-- Injected variables:                                                  -->
33 <!--   $is-chm          - (boolean) target is for CHM generation or not   -->
34 <!--   $is-zip          - (boolean) target is for ZIP generation or not   -->
35 <!--   $message         - (node-set) localized common text snippets       -->
36 <!--   $doclang         - (string) document language                      -->
37 <!--   $output-encoding - (string) MIME charset name of the output        -->
38 <!--                      encoding                                        -->
39
40 <!-- Constants used for case translation -->
41 <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
42 <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
43
44 <!-- space separated list of blockelements defined in common.dtd -->
45 <!--    used for inline content catching in <example>s           -->
46 <xsl:variable name="blockelements">
47     p  example  note  table  ul  ol  dl  pre  img  blockquote
48 </xsl:variable>
49
50 <!-- relative path to /manual/ -->
51 <xsl:variable name="metafile" select="document(/*/@metafile)/metafile" />
52 <xsl:variable name="path"     select="$metafile/relpath" />
53
54 <!-- load outsourced page types -->
55 <xsl:include href="moduleindex.xsl" />
56 <xsl:include href="directiveindex.xsl" />
57 <xsl:include href="manualpage.xsl" />
58 <xsl:include href="synopsis.xsl" />
59 <xsl:include href="sitemap.xsl" />
60 <xsl:include href="indexpage.xsl" />
61 <xsl:include href="quickreference.xsl" />
62 <xsl:include href="faq.xsl" />
63
64 <!-- load utility snippets -->
65 <xsl:include href="util/modtrans.xsl" />
66
67 <!-- make sure, we set relative anchors only, if we're actually -->
68 <!-- transforming a modulefile (see <directive> template)       -->
69 <xsl:variable name="in-modulesynopsis" select="boolean(/modulesynopsis)" />
70
71 <!-- when referencing to a directory, we may need to complete the path -->
72 <!-- with the index file (for offline applications like *.chm files)   -->
73 <xsl:variable name="index-file">
74     <xsl:if test="$is-chm or $is-zip">index.html</xsl:if>
75 </xsl:variable>
76
77 <!-- it may be desired to open external targets in a new window -->
78 <xsl:variable name="ext-target" select="boolean($is-chm)" />
79
80 <!-- #################################################################### -->
81 <!-- Utility templates for constructing pages                             -->
82 <!-- #################################################################### -->
83
84 <!-- ==================================================================== -->
85 <!-- HTML head                                                            -->
86 <!-- ==================================================================== -->
87 <xsl:template name="head">
88 <head>
89     <!-- the meta element is necessary for offline handling like CHM -->
90     <xsl:choose>
91     <xsl:when test="$is-chm or $is-zip">
92         <meta http-equiv="Content-Type"
93                  content="text/html; charset={$output-encoding}" />
94     </xsl:when>
95     <xsl:otherwise>
96         <xsl:comment>
97             &lf;
98             <xsl:text>        </xsl:text>
99             <xsl:text>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>
100             <xsl:text>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>
101             &lf;
102             <xsl:text>              </xsl:text>
103             <xsl:text>This file is generated from xml source: </xsl:text>
104             <xsl:text>DO NOT EDIT</xsl:text>
105             &lf;
106             <xsl:text>        </xsl:text>
107             <xsl:text>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>
108             <xsl:text>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>
109             &lf;
110             <xsl:text>      </xsl:text>
111         </xsl:comment>
112     </xsl:otherwise>
113     </xsl:choose>&lf;
114
115     <title>
116         <xsl:choose>
117         <xsl:when test="name">
118             <xsl:value-of select="name"/>
119         </xsl:when>
120
121         <xsl:otherwise>
122             <xsl:value-of select="title"/>
123         </xsl:otherwise>
124         </xsl:choose>
125
126         <xsl:text> </xsl:text>
127         <xsl:value-of select="normalize-space($message[@id='apachetitle'])"/>
128     </title>&lf;
129
130     <!-- chm files get a slightly different stylesheet -->
131     <xsl:choose>
132     <xsl:when test="$is-chm">
133         <link type="text/css" rel="stylesheet" media="all"
134               href="{$path}/style/css/manual-chm.css" />
135     </xsl:when>
136     <!-- zip packages do also -->
137     <xsl:when test="$is-zip">
138         <link title="Main stylesheet"  type="text/css" media="all"
139                 rel="stylesheet"
140                href="{$path}/style/css/manual-zip.css" />&lf;
141         <link title="No Sidebar - Default font size" type="text/css" media="all"
142                rel="alternate stylesheet"
143                href="{$path}/style/css/manual-zip-100pc.css"/>
144     </xsl:when>
145     <xsl:otherwise>
146         <link title="Main stylesheet"  type="text/css" media="all"
147                 rel="stylesheet"
148                href="{$path}/style/css/manual.css" />&lf;
149         <link title="No Sidebar - Default font size" type="text/css" media="all"
150                rel="alternate stylesheet"
151                href="{$path}/style/css/manual-loose-100pc.css"/>
152     </xsl:otherwise>
153     </xsl:choose>&lf;
154
155     <link type="text/css" media="print"
156            rel="stylesheet"
157            href="{$path}/style/css/manual-print.css"/>
158
159     <!-- chm files do not need a favicon -->
160     <xsl:if test="not($is-chm or $is-zip)">&lf;
161         <link rel="shortcut icon" href="{$path}/images/favicon.ico" />
162     </xsl:if>
163 </head>
164 </xsl:template>
165 <!-- /head -->
166
167
168 <!-- ==================================================================== -->
169 <!-- page top                                                             -->
170 <!-- ==================================================================== -->
171 <xsl:template name="top">
172 <div id="page-header">&lf;
173     <xsl:call-template name="super-menu" />&lf;
174
175     <p class="apache">
176         <xsl:value-of select="normalize-space($message
177                                               [@id='apachehttpserver'])"/>
178     </p>&lf;
179
180     <img src="{$path}/images/feather.gif" alt="" />
181 </div>&lf; <!-- /page-header -->
182
183 <div class="up">
184     <a href="./{$index-file}">
185         <xsl:if test="parentdocument">
186             <xsl:attribute name="href">
187                 <xsl:value-of select="parentdocument/@href"/>
188             </xsl:attribute>
189
190             <xsl:call-template name="helper.uri.fix">
191                 <xsl:with-param name="uri" select="parentdocument/@href" />
192             </xsl:call-template>
193       </xsl:if>
194
195       <img src="{$path}/images/left.gif" alt="&lt;-" title="&lt;-" />
196     </a>
197 </div>&lf;
198
199 <div id="path">&lf;
200     <a href="http://www.apache.org/">
201         <xsl:if test="$ext-target">
202             <xsl:attribute name="target">_blank</xsl:attribute>
203         </xsl:if>
204         <xsl:value-of select="$message[@id='apache']" />
205     </a>
206
207     <xsl:text> &gt; </xsl:text>
208
209     <a href="http://httpd.apache.org/">
210         <xsl:if test="$ext-target">
211             <xsl:attribute name="target">_blank</xsl:attribute>
212         </xsl:if>
213         <xsl:value-of select="$message[@id='http-server']" />
214     </a>
215
216     <xsl:text> &gt; </xsl:text>
217
218     <a href="http://httpd.apache.org/docs-project/">
219         <xsl:if test="$ext-target">
220             <xsl:attribute name="target">_blank</xsl:attribute>
221         </xsl:if>
222         <xsl:value-of select="$message[@id='documentation']" />
223     </a>
224
225     <xsl:if test="not(../indexpage)">
226     <xsl:text> &gt; </xsl:text>
227
228     <a href="{$path}/{$index-file}">
229         <xsl:value-of select="$message[@id='version']"/>
230     </a>
231     </xsl:if>
232
233     <xsl:if test="../modulesynopsis or ../directiveindex or ../quickreference">
234     <xsl:text> &gt; </xsl:text>
235
236     <a href="./{$index-file}">
237         <xsl:value-of select="$message[@id='modules']"/>
238     </a>
239     </xsl:if>
240
241     <xsl:if test="parentdocument/text()">
242     <xsl:text> &gt; </xsl:text>
243
244     <a href="{parentdocument/@href}">
245         <xsl:call-template name="helper.uri.fix">
246             <xsl:with-param name="uri" select="parentdocument/@href"/>
247         </xsl:call-template>
248         <xsl:value-of select="parentdocument"/>
249     </a>
250     </xsl:if>
251 </div> <!-- /path -->
252 </xsl:template>
253 <!-- /top -->
254
255
256 <!-- ==================================================================== -->
257 <!-- out of date                                                          -->
258 <!-- ==================================================================== -->
259 <xsl:template name="outofdate">
260 <xsl:if test="$metafile/variants/variant[.=$doclang]/@outdated = 'yes'">
261     &lf;
262     <div class="outofdate">
263         <xsl:value-of select="$message[@id='outofdate']"/>
264     </div>
265 </xsl:if>
266 </xsl:template>
267
268
269 <!-- ==================================================================== -->
270 <!-- page bottom                                                          -->
271 <!-- ==================================================================== -->
272 <xsl:template name="bottom">
273 <xsl:call-template name="langavail">
274     <xsl:with-param name="position" select="'bottom'" />
275 </xsl:call-template>
276
277 <div id="footer">&lf;
278     <p class="apache">
279         <xsl:text>Copyright 1999-2004 The Apache Software </xsl:text>
280         <xsl:text>Foundation.</xsl:text><br />
281         <xsl:value-of select="$message[@id='licensed']"/>
282         <xsl:text> </xsl:text>
283
284         <a href="http://www.apache.org/licenses/LICENSE-2.0">
285             <xsl:if test="$ext-target">
286                 <xsl:attribute name="target">_blank</xsl:attribute>
287             </xsl:if>
288             <xsl:text>Apache License, Version 2.0</xsl:text>
289         </a>
290         <xsl:text>.</xsl:text>
291     </p>&lf;
292
293     <xsl:call-template name="super-menu"/>
294
295 </div> <!-- /footer -->
296 </xsl:template>
297 <!-- /bottom -->
298
299
300 <!-- ==================================================================== -->
301 <!-- build an "available languages" section                               -->
302 <!-- ==================================================================== -->
303 <xsl:template name="langavail">
304 <xsl:param name="position" select="'top'" />
305
306 <xsl:if test="not($is-chm or $is-zip)">
307 <div class="{$position}lang">&lf;
308     <p>
309         <span>
310             <xsl:value-of select="$message[@id='langavail']" />
311             <xsl:text>: </xsl:text>
312         </span>
313
314         <xsl:for-each select="$metafile/variants/variant">
315         <xsl:sort select="." />
316
317             <a href="{$path}/{.}{$metafile/path}{$metafile/basename}.html">
318                 <xsl:if test="$metafile/basename = 'index'">
319                     <xsl:attribute name="href">
320                         <xsl:value-of
321                             select="concat($path, '/', ., $metafile/path)" />
322                     </xsl:attribute>
323                 </xsl:if>
324                 <xsl:if test="$doclang != .">
325                     <xsl:attribute name="hreflang">
326                         <xsl:value-of select="." />
327                     </xsl:attribute>
328                     <xsl:attribute name="rel">alternate</xsl:attribute>
329                 </xsl:if>
330                 <xsl:attribute name="title">
331                     <xsl:value-of select="document(concat('../lang/', .,
332                                                    '.xml'))
333                                           /language/messages/message
334                                           [@id='nativename']" />
335                 </xsl:attribute>
336
337                 &nbsp;
338                 <xsl:value-of select="." />
339                 &nbsp;
340             </a>
341             <xsl:if test="position() != last()">
342                 <xsl:text> |&#xA;</xsl:text>
343             </xsl:if>
344         </xsl:for-each>
345     </p>&lf;
346 </div> <!-- /.{$position}lang -->
347 </xsl:if>
348
349 <xsl:if test="$position = 'top'">
350     <xsl:call-template name="outofdate" />
351 </xsl:if>
352
353 </xsl:template>
354 <!-- /langavail -->
355
356
357 <!-- ==================================================================== -->
358 <!-- Process a documentation section                                      -->
359 <!-- ==================================================================== -->
360 <xsl:template match="section">
361 <xsl:call-template name="toplink" />&lf;
362 <div class="section">&lf;
363
364     <!-- Section heading -->
365     <h2>
366         <xsl:choose>
367         <xsl:when test="@id">
368           <a id="{@id}" name="{@id}">
369               <xsl:apply-templates select="title" mode="print" />
370           </a>
371         </xsl:when>
372
373         <xsl:otherwise>
374             <xsl:apply-templates select="title" mode="print" />
375         </xsl:otherwise>
376         </xsl:choose>
377     </h2>
378
379     <!-- Section body -->
380     <xsl:apply-templates />
381 </div> <!-- /.section -->
382 </xsl:template>
383 <!-- /section -->
384
385
386 <!-- ==================================================================== -->
387 <!-- handle subsections (lower level headings)                            -->
388 <!-- ==================================================================== -->
389 <xsl:template match="section/section">
390 <!-- Section heading -->
391 <h3>
392     <xsl:choose>
393     <xsl:when test="@id">
394         <a id="{@id}" name="{@id}">
395             <xsl:apply-templates select="title" mode="print" />
396         </a>
397     </xsl:when>
398
399     <xsl:otherwise>
400         <xsl:apply-templates select="title" mode="print" />
401     </xsl:otherwise>
402     </xsl:choose>
403 </h3>
404
405 <!-- Section body -->
406 <xsl:apply-templates />
407 </xsl:template>
408 <!-- /section/section -->
409
410
411 <!-- ==================================================================== -->
412 <!-- handle subsubsections (h4)                                           -->
413 <!-- ==================================================================== -->
414 <xsl:template match="section/section/section">
415 <!-- Section heading -->
416 <h4>
417     <xsl:choose>
418     <xsl:when test="@id">
419         <a id="{@id}" name="{@id}">
420             <xsl:apply-templates select="title" mode="print" />
421         </a>
422     </xsl:when>
423
424     <xsl:otherwise>
425         <xsl:apply-templates select="title" mode="print" />
426     </xsl:otherwise>
427     </xsl:choose>
428 </h4>
429
430 <!-- Section body -->
431 <xsl:apply-templates/>
432
433 </xsl:template>
434 <!-- /section/section/section -->
435
436
437 <!-- ==================================================================== -->
438 <!-- section nesting > h4 is not supported for now                        -->
439 <!-- ==================================================================== -->
440 <xsl:template match="section/section/section/section">
441 <xsl:message terminate="yes">
442     <xsl:text>FATAL: exceeding maximum section nesting level.</xsl:text>
443     &lf;&lf;
444     <xsl:text>Perhaps you should consider to split your document into</xsl:text>
445     &lf;
446     <xsl:text>several ones...</xsl:text>
447     &lf;
448 </xsl:message>
449 </xsl:template>
450 <!-- /section/section/section/section -->
451
452
453 <!-- ==================================================================== -->
454 <!-- (sub)section titles                                                  -->
455 <!-- ==================================================================== -->
456 <xsl:template match="section/title" mode="print">
457 <xsl:apply-templates/>
458 </xsl:template>
459 <xsl:template match="section/title" />
460 <!-- /section/title -->
461
462
463 <!-- ==================================================================== -->
464 <!-- generate section index                                               -->
465 <!-- ==================================================================== -->
466 <xsl:template match="section" mode="index">
467 <li>
468     <img src="{$path}/images/down.gif" alt="" />
469     <xsl:text> </xsl:text>
470     <xsl:choose>
471     <xsl:when test="@id">
472         <a href="#{@id}">
473             <xsl:apply-templates select="title" mode="print" />
474         </a>
475     </xsl:when>
476     <xsl:otherwise>
477         <xsl:apply-templates select="title" mode="print" />
478     </xsl:otherwise>
479     </xsl:choose>
480 </li>&lf;
481 </xsl:template>
482 <!-- /section index -->
483
484
485 <!-- ==================================================================== -->
486 <!-- docs super menu                                                      -->
487 <!-- ==================================================================== -->
488 <xsl:template name="super-menu">
489 <p class="menu">
490     <a href="{$path}/mod/{$index-file}">
491         <xsl:value-of select="$message[@id='modules']" />
492     </a>
493
494     <xsl:text> | </xsl:text>
495
496     <a href="{$path}/mod/directives.html">
497         <xsl:value-of select="$message[@id='directives']" />
498     </a>
499
500     <xsl:text> | </xsl:text>
501
502     <a href="{$path}/faq/{$index-file}">
503         <xsl:value-of select="$message[@id='faq']" />
504     </a>
505
506     <xsl:text> | </xsl:text>
507
508     <a href="{$path}/glossary.html">
509         <xsl:value-of select="$message[@id='glossary']" />
510     </a>
511
512     <xsl:text> | </xsl:text>
513
514     <a href="{$path}/sitemap.html">
515         <xsl:value-of select="$message[@id='sitemap']" />
516     </a>
517 </p>
518 </xsl:template>
519 <!-- /super-menu -->
520
521
522 <!-- ==================================================================== -->
523 <!-- <example>                                                            -->
524 <!-- iterate over *all* nodes; bare text and other inline stuff is        -->
525 <!-- wrapped into <p><code>, block level elements (defined in             -->
526 <!-- $blockelements) are applied "as is"                                  -->
527 <!-- ==================================================================== -->
528 <xsl:variable name="blocks"
529             select="concat(' ', normalize-space($blockelements), ' ')" />
530
531 <xsl:template match="example">
532 <div class="example">
533     <xsl:apply-templates select="title" mode="print" />
534
535     <xsl:for-each select="./node()">
536         <xsl:variable name="is-block-node"
537                     select="boolean(contains($blocks,
538                                              concat(' ', local-name(), ' ')))"/>
539         <!-- bb = (number of) blocks nodes before (the current) -->
540         <xsl:variable name="bb"
541                     select="count(preceding-sibling::*[
542                                 contains($blocks,
543                                          concat(' ', local-name(), ' '))])" />
544
545         <xsl:if test="$is-block-node or position()=last()">
546             <xsl:variable name="content">
547                 <!-- phew. short explanation, what happens here:      -->
548                 <!-- We want to get the inline stuff between the last -->
549                 <!-- block node and the current node.                 -->
550                 <!-- So filter all previous nodes for the condition   -->
551                 <!-- that the number of block nodes of all of *their* -->
552                 <!-- previous nodes is >= $bb. Hope that helps ;-)    -->
553                 <xsl:apply-templates
554                     select="preceding-sibling::node()[
555                                 count(preceding-sibling::*[
556                                     contains($blocks,
557                                              concat(' ', local-name(), ' '))])
558                                 &gt;= $bb]" />
559
560                 <xsl:apply-templates
561                     select="self::node()[not($is-block-node)]" />
562             </xsl:variable>
563
564             <!-- apply bare text only, if it's not only \s or empty -->
565             <xsl:if test="not(normalize-space($content) = '')">
566                 <p><code>
567                     <!-- same as $content above. xsl:copy-of seems to make -->
568                     <!-- thread problems with xalan-j ... -->
569                     <xsl:apply-templates
570                         select="preceding-sibling::node()[
571                                     count(preceding-sibling::*[
572                                         contains($blocks,
573                                                  concat(' ', local-name(),
574                                                         ' '))])
575                                     &gt;= $bb]" />
576
577                     <xsl:apply-templates
578                         select="self::node()[not($is-block-node)]" />
579                 </code></p>
580             </xsl:if>
581
582             <xsl:apply-templates select="self::node()[$is-block-node]" />
583         </xsl:if>
584     </xsl:for-each>
585     <!-- /node() -->
586 </div> <!-- /.example -->
587 </xsl:template>
588 <!-- /example -->
589
590
591 <!-- ==================================================================== -->
592 <!-- example/title                                                        -->
593 <!-- ==================================================================== -->
594 <xsl:template match="example/title" mode="print">
595 <h3>
596     <xsl:apply-templates/>
597 </h3>
598 </xsl:template>
599 <xsl:template match="example/title" />
600 <!-- /example/title -->
601
602
603 <!-- ==================================================================== -->
604 <!-- indentations                                                         -->
605 <!-- ==================================================================== -->
606 <xsl:template match="indent">
607 <span class="indent">
608     <xsl:apply-templates/>
609 </span>
610 </xsl:template>
611 <!-- /indent -->
612
613
614 <!-- ==================================================================== -->
615 <!-- <note>                                                               -->
616 <!-- ==================================================================== -->
617 <xsl:template match="note">
618 <div class="note">
619     <xsl:if test="@type='warning'">
620         <xsl:attribute name="class">warning</xsl:attribute>
621     </xsl:if>
622
623     <xsl:apply-templates/>
624 </div>
625 </xsl:template>
626 <!-- /note -->
627
628
629 <!-- ==================================================================== -->
630 <!-- <note><title>                                                        -->
631 <!-- ==================================================================== -->
632 <xsl:template match="note/title">
633 <h3>
634     <xsl:apply-templates/>
635 </h3>
636 </xsl:template>
637 <!-- /note/title -->
638
639
640 <!-- ==================================================================== -->
641 <!-- <directive>                                                          -->
642 <!-- Inserts link to another directive, which might be in another module. -->
643 <!-- References are converted into lower case.                            -->
644 <!-- ==================================================================== -->
645 <xsl:template match="directive" name="directive">
646 <code class="directive">
647     <xsl:choose>
648     <xsl:when test="@module">
649         <xsl:variable name="lowerdirective"
650             select="translate(., $uppercase, $lowercase)" />
651
652         <xsl:choose>
653         <xsl:when test="$in-modulesynopsis and @module = /modulesynopsis/name">
654             <a href="#{$lowerdirective}">
655                 <xsl:if test="@type='section'">&lt;</xsl:if>
656                 <xsl:value-of select="."/>
657                 <xsl:if test="@type='section'">&gt;</xsl:if>
658             </a>
659         </xsl:when>
660         <xsl:otherwise>
661             <a href="{$path}/mod/{@module}.html#{$lowerdirective}">
662                 <xsl:if test="@type='section'">&lt;</xsl:if>
663                 <xsl:value-of select="."/>
664                 <xsl:if test="@type='section'">&gt;</xsl:if>
665             </a>
666         </xsl:otherwise>
667         </xsl:choose>
668     </xsl:when>
669
670     <xsl:otherwise>
671         <xsl:if test="@type='section'">&lt;</xsl:if>
672         <xsl:value-of select="."/>
673         <xsl:if test="@type='section'">&gt;</xsl:if>
674     </xsl:otherwise>
675     </xsl:choose>
676 </code>
677 </xsl:template>
678 <!-- /directive -->
679
680
681 <!-- ==================================================================== -->
682 <!-- <module>                                                             -->
683 <!-- Inserts a link to refereed module                                    -->
684 <!-- ==================================================================== -->
685 <xsl:template match="module" name="module">
686 <code class="module">
687     <a href="{$path}/mod/{.}.html">
688         <xsl:value-of select="."/>
689     </a>
690 </code>
691 </xsl:template>
692 <!-- /module -->
693
694
695 <!-- ==================================================================== -->
696 <!-- <program>                                                            -->
697 <!-- Inserts a link to referred program                                   -->
698 <!-- ==================================================================== -->
699 <xsl:template match="program">
700 <code class="program">
701     <a href="{$path}/programs/{normalize-space(.)}.html">
702         <xsl:value-of select="normalize-space(.)" />
703     </a>
704 </code>
705 </xsl:template>
706 <!-- /program -->
707
708
709 <!-- ==================================================================== -->
710 <!-- <related>                                                            -->
711 <!-- ==================================================================== -->
712 <xsl:template match="related">
713 <table class="related">
714 <tr>
715     <th>
716         <xsl:value-of select="$message[@id='relatedmodules']" />
717     </th>
718     <th>
719         <xsl:value-of select="$message[@id='relateddirectives']" />
720     </th>
721 </tr>
722 <tr>
723     <td>
724         <xsl:if test="count(modulelist/*) &gt; 0">
725             <ul>
726                 <xsl:apply-templates select="modulelist" />
727             </ul>
728         </xsl:if>
729     </td>
730     <td>
731         <xsl:if test="count(directivelist/*) &gt; 0">
732             <ul>
733                 <xsl:apply-templates select="directivelist"/>
734             </ul>
735         </xsl:if>
736     </td>
737 </tr>
738 </table>
739 </xsl:template>
740 <!-- /related -->
741
742 <!-- ==================================================================== -->
743 <!-- related/modulelist                                                   -->
744 <!-- ==================================================================== -->
745 <xsl:template match="related/modulelist">
746 <xsl:for-each select="module">
747     <li>
748         <xsl:call-template name="module"/>
749     </li>
750 </xsl:for-each>
751 </xsl:template>
752 <!-- /related/modulelist -->
753
754
755 <!-- ==================================================================== -->
756 <!-- related/directivelist                                                -->
757 <!-- ==================================================================== -->
758 <xsl:template match="related/directivelist">
759 <xsl:for-each select="directive">
760     <li>
761         <xsl:call-template name="directive"/>
762     </li>
763 </xsl:for-each>
764 </xsl:template>
765 <!-- /related/directivelist -->
766
767
768 <!-- ==================================================================== -->
769 <!-- <table>                                                              -->
770 <!-- ==================================================================== -->
771 <xsl:template match="table">
772 <table>
773     <!-- existing border attribute will result in <table class="bordered"> -->
774     <xsl:if test="@border">
775         <xsl:attribute name="class">bordered</xsl:attribute>
776     </xsl:if>
777
778     <xsl:choose>
779     <xsl:when test="@style = 'zebra'">
780         <xsl:apply-templates select="tr" mode="zebra-table" />
781     </xsl:when>
782     <xsl:when test="@style = 'data'">
783         <xsl:apply-templates select="tr" mode="data-table" />
784     </xsl:when>
785     <xsl:otherwise>
786         <xsl:apply-templates />
787     </xsl:otherwise>
788     </xsl:choose>
789 </table>
790 </xsl:template>
791 <!-- /table -->
792
793 <!-- data-table -->
794 <xsl:template match="tr" mode="data-table">
795 <!-- style="data": fixed font, padding-left and right alignment for <td>s -->
796 <xsl:variable name="cross-table" select="boolean(
797     preceding-sibling::tr/th[1]|following-sibling::tr/th[1])" />
798
799 <tr>
800     <xsl:for-each select="node()">
801         <xsl:choose>
802         <xsl:when test="local-name() = 'td'">
803             <td class="data">
804                 <xsl:apply-templates select="*|@*|text()" />
805             </td>
806         </xsl:when>
807         <xsl:when test="local-name() = 'th' and
808                         (not($cross-table) or
809                          count(preceding-sibling::*) &gt; 0)">
810             <th class="data">
811                 <xsl:apply-templates select="*|@*|text()" />
812             </th>
813         </xsl:when>
814         <xsl:otherwise>
815             <xsl:apply-templates select="self::node()" />
816         </xsl:otherwise>
817         </xsl:choose>
818     </xsl:for-each>
819 </tr>&lf;
820 </xsl:template>
821
822
823 <!-- zebra-table -->
824 <xsl:template match="tr" mode="zebra-table">
825 <!-- style="zebra": alternating colors per row, i.e. every second row -->
826 <!--                gets a class="odd". Header lines (no <td>) get a  -->
827 <!--                class="header". These lines will be excluded from -->
828 <!--                the "odd" line count. That way header lines act   -->
829 <!--                interjectional, which creates a better visual and -->
830 <!--                psychological effect.                             -->
831 <tr>
832     <xsl:choose>
833     <xsl:when test="count(td) = 0">
834         <xsl:attribute name="class">header</xsl:attribute>
835     </xsl:when>
836
837     <xsl:when test="position() mod 2 = (count(preceding-sibling::tr[count(td) = 0]) mod 2)">
838         <xsl:attribute name="class">odd</xsl:attribute>
839     </xsl:when>
840     </xsl:choose>
841
842     <xsl:apply-templates />
843 </tr>&lf;
844 </xsl:template>
845 <!-- /zebra-table -->
846
847
848 <!-- ==================================================================== -->
849 <!-- <ol>                                                                 -->
850 <!-- ==================================================================== -->
851 <xsl:template match="ol">
852 <ol>
853     <!-- A. B. C. D. (list-style-type="upper-alpha") -->
854     <xsl:choose>
855     <xsl:when test="@type = 'A'">
856         <xsl:attribute name="class">up-A</xsl:attribute>
857     </xsl:when>
858     <xsl:when test="@type = 'a'">
859         <xsl:attribute name="class">lo-A</xsl:attribute>
860     </xsl:when>
861     </xsl:choose>
862
863     <xsl:apply-templates/>
864 </ol>
865 </xsl:template>
866 <!-- /ol -->
867
868
869 <!-- ==================================================================== -->
870 <!-- diverse elements                                                     -->
871 <!-- Passes through content                                               -->
872 <!-- ==================================================================== -->
873 <xsl:template match="summary|description|usage|syntax|default">
874 <xsl:apply-templates/>
875 </xsl:template>
876 <!-- /diverse -->
877
878
879 <!-- ==================================================================== -->
880 <!-- <a>                                                                  -->
881 <!-- ==================================================================== -->
882 <xsl:template match="a">
883 <xsl:choose>
884 <xsl:when test="not(@href)">
885     <xsl:copy>
886         <xsl:apply-templates select="@*|*|text()"/>
887     </xsl:copy>
888 </xsl:when>
889 <xsl:otherwise>
890     <a href="@href">
891         <xsl:apply-templates select="@*"/>
892         <xsl:call-template name="helper.uri.fix">
893             <xsl:with-param name="uri" select="@href"/>
894         </xsl:call-template>
895
896         <xsl:apply-templates select="*|text()"/>
897     </a>
898 </xsl:otherwise>
899 </xsl:choose>
900 </xsl:template> 
901 <!-- /a -->
902
903
904 <!-- ==================================================================== -->
905 <!-- toplink                                                              -->
906 <!-- ==================================================================== -->
907 <xsl:template name="toplink">
908 <div class="top">
909     <a href="#page-header"><img src="{$path}/images/up.gif" alt="top" /></a>
910 </div>
911 </xsl:template>
912 <!-- /toplink -->
913
914
915 <!-- ==================================================================== -->
916 <!-- <transnote>                                                          -->
917 <!-- translator's notes are displayed in a different color                -->
918 <!-- ==================================================================== -->
919 <xsl:template match="transnote">
920 <span class="transnote">
921     <xsl:text>(</xsl:text>
922     <em>
923         <xsl:value-of select="$message[@id='transnote']" />
924     </em>
925     <xsl:text> </xsl:text>
926     <xsl:apply-templates />
927     <xsl:text>)</xsl:text>
928 </span>
929 </xsl:template>
930 <!-- /transnote -->
931
932 <!-- ==================================================================== -->
933 <!-- <phonetic>                                                           -->
934 <!-- phonetics are enclosed in  square brackets and displayed in a        -->
935 <!-- different color                                                      -->
936 <!-- ==================================================================== -->
937 <xsl:template match="phonetic">
938 <span class="phonetic">
939     <xsl:text>[</xsl:text>
940     <xsl:apply-templates />
941     <xsl:text>]</xsl:text>
942 </span>
943 </xsl:template>
944 <!-- /phonetic -->
945
946
947 <!-- ==================================================================== -->
948 <!-- <glossary>                                                           -->
949 <!-- link to a glossary anchor                                            -->
950 <!-- ==================================================================== -->
951 <xsl:template match="glossary">
952 <span>
953     <xsl:attribute name="title">
954         <xsl:value-of select="$message[@id='glossarylink']" />
955     </xsl:attribute>
956     <xsl:text>&#x2192;</xsl:text>
957 </span>&nbsp;
958 <a href="{$path}/glossary.html#{@ref}">
959     <xsl:apply-templates />
960 </a>
961 </xsl:template>
962 <!-- /glossary -->
963
964 <!-- ==================================================================== -->
965 <!-- Filter &#160; in text() nodes.                                       -->
966 <!-- In some environments this character won't be transformed correctly,  -->
967 <!-- so we just write it explicitely as "&nbsp;" into the output.         -->
968 <!-- ==================================================================== -->
969 <xsl:template match="text()" name="filter.nbsp">
970 <xsl:param name="text" select="." />
971
972 <xsl:choose>
973 <xsl:when test="contains($text, '&#160;')">
974     <xsl:value-of select="substring-before($text, '&#160;')" />
975     &nbsp;
976     <xsl:call-template name="filter.nbsp">
977         <xsl:with-param name="text" select="substring-after($text, '&#160;')" />
978     </xsl:call-template>
979 </xsl:when>
980 <xsl:otherwise>
981     <xsl:value-of select="$text" />
982 </xsl:otherwise>
983 </xsl:choose>
984 </xsl:template>
985 <!-- /filter.nbsp -->
986
987
988 <!-- ==================================================================== -->
989 <!-- Process everything else by just passing it through                   -->
990 <!-- ==================================================================== -->
991 <xsl:template match="*">
992 <xsl:message terminate="yes">
993     <xsl:text>Unknown element: </xsl:text>
994     <xsl:value-of select="local-name()" />&lf;
995     <xsl:text>Is the document valid (try `build validate-xml`)?</xsl:text>
996 </xsl:message>
997 </xsl:template>
998 <xsl:template match="@*">
999 <xsl:copy>
1000     <xsl:apply-templates select="*|@*|text()" />
1001 </xsl:copy>
1002 </xsl:template>
1003 <xsl:template match="br"><br /></xsl:template>
1004 <xsl:template match="tr"><tr><xsl:apply-templates select="*|@*|text()" /></tr></xsl:template>
1005 <xsl:template match="th"><th><xsl:apply-templates select="*|@*|text()" /></th></xsl:template>
1006 <xsl:template match="td"><td><xsl:apply-templates select="*|@*|text()" /></td></xsl:template>
1007 <xsl:template match="p"><p><xsl:apply-templates select="*|@*|text()" /></p></xsl:template>
1008 <xsl:template match="ul"><ul><xsl:apply-templates select="*|@*|text()" /></ul></xsl:template>
1009 <xsl:template match="li"><li><xsl:apply-templates select="*|@*|text()" /></li></xsl:template>
1010 <xsl:template match="dl"><dl><xsl:apply-templates select="*|@*|text()" /></dl></xsl:template>
1011 <xsl:template match="dt"><dt><xsl:apply-templates select="*|@*|text()" /></dt></xsl:template>
1012 <xsl:template match="dd"><dd><xsl:apply-templates select="*|@*|text()" /></dd></xsl:template>
1013 <xsl:template match="em"><em><xsl:apply-templates select="*|@*|text()" /></em></xsl:template>
1014 <xsl:template match="strong"><strong><xsl:apply-templates select="*|@*|text()" /></strong></xsl:template>
1015 <xsl:template match="pre"><pre><xsl:apply-templates select="*|@*|text()" /></pre></xsl:template>
1016 <xsl:template match="code"><code><xsl:apply-templates select="*|@*|text()" /></code></xsl:template>
1017 <xsl:template match="var"><var><xsl:apply-templates select="*|@*|text()" /></var></xsl:template>
1018 <xsl:template match="dfn"><dfn><xsl:apply-templates select="*|@*|text()" /></dfn></xsl:template>
1019 <xsl:template match="blockquote"><blockquote><xsl:apply-templates select="*|@*|text()" /></blockquote></xsl:template>
1020 <xsl:template match="q"><q><xsl:apply-templates select="*|@*|text()" /></q></xsl:template>
1021 <xsl:template match="cite"><cite><xsl:apply-templates select="*|@*|text()" /></cite></xsl:template>
1022 <xsl:template match="img"><img><xsl:apply-templates select="*|@*|text()" /></img></xsl:template>
1023 <!-- /pass through -->
1024
1025
1026 <!-- ==================================================================== -->
1027 <!-- create a letter bar                                                  -->
1028 <!-- ==================================================================== -->
1029 <xsl:template name="letter-bar">
1030 <xsl:param name="letters" />
1031 <xsl:param name="first" />
1032
1033 <xsl:if test="not($first)">
1034     <xsl:text> | </xsl:text>
1035 </xsl:if>
1036
1037 <a href="#{substring($letters,1,1)}">
1038     &nbsp;
1039     <xsl:value-of select="substring($letters, 1, 1)" />
1040     &nbsp;
1041 </a>
1042
1043 <xsl:if test="string-length($letters) &gt; 1">
1044     <xsl:call-template name="letter-bar">
1045         <xsl:with-param name="letters" select="substring($letters, 2)" />
1046         <xsl:with-param name="first" select="false()" />
1047     </xsl:call-template>
1048 </xsl:if>
1049 </xsl:template>
1050 <!-- /letter-bar -->
1051
1052
1053 <!-- ==================================================================== -->
1054 <!-- template(s) for collecting all start letters of directives           -->
1055 <!-- ==================================================================== -->
1056 <xsl:template name="directive-startletters">
1057 <xsl:param name="directives" />
1058
1059 <xsl:call-template name="_squeeze-letters">
1060     <xsl:with-param name="lastletter" select="''" />
1061     <xsl:with-param name="letters">
1062         <xsl:for-each select="$directives">
1063         <xsl:sort select="name"/>
1064             <xsl:value-of
1065                 select="translate(substring(normalize-space(name), 1, 1),
1066                                   $lowercase, $uppercase)" />
1067         </xsl:for-each>
1068     </xsl:with-param>
1069 </xsl:call-template>
1070 </xsl:template>
1071 <!-- /directive-startletters -->
1072
1073
1074 <!-- ==================================================================== -->
1075 <!-- squeeze subsequent letters in a string                               -->
1076 <!-- ==================================================================== -->
1077 <xsl:template name="_squeeze-letters">
1078 <xsl:param name="letters"/>
1079 <xsl:param name="lastletter"/>
1080
1081 <xsl:variable name="current" select="substring($letters, 1, 1)" />
1082
1083 <xsl:if test="not($lastletter = $current)">
1084     <xsl:value-of select="$current" />
1085 </xsl:if>
1086
1087 <xsl:if test="string-length($letters) &gt; 1">
1088     <xsl:call-template name="_squeeze-letters">
1089         <xsl:with-param name="letters" select="substring($letters, 2)" />
1090         <xsl:with-param name="lastletter" select="$current"/>
1091     </xsl:call-template>
1092 </xsl:if>
1093 </xsl:template>
1094 <!-- /_squeeze-letters -->
1095
1096
1097 <!-- ==================================================================== -->
1098 <!-- fix href and target attribute of an element.                         -->
1099 <!-- ==================================================================== -->
1100 <xsl:template name="helper.uri.fix">
1101 <xsl:param name="uri"/>
1102
1103 <xsl:choose>
1104 <!-- lame is_absolute_uri test -->
1105 <xsl:when test="    contains($uri, ':')
1106                 and string-length(substring-before($uri, ':')) &lt; 7">
1107     <xsl:if test="$ext-target">
1108         <xsl:attribute name="target">_blank</xsl:attribute>
1109     </xsl:if>
1110 </xsl:when>
1111 <xsl:otherwise>
1112     <xsl:variable name="fragment">
1113         <xsl:if test="contains($uri, '#')">
1114             <xsl:value-of select="concat('#', substring-after($uri, '#'))"/>
1115         </xsl:if>
1116     </xsl:variable>
1117     <xsl:variable name="absuri">
1118         <xsl:choose>
1119         <xsl:when test="contains($uri, '#')">
1120             <xsl:value-of select="concat('#', substring-before($uri, '#'))"/>
1121         </xsl:when>
1122         <xsl:otherwise>
1123             <xsl:value-of select="$uri"/>
1124         </xsl:otherwise>
1125         </xsl:choose>
1126     </xsl:variable>
1127         
1128     <xsl:if test="substring($absuri, string-length($uri), 1) = '/'">
1129         <xsl:attribute name="href">
1130             <xsl:value-of select="concat($absuri, $index-file, $fragment)"/>
1131         </xsl:attribute>
1132     </xsl:if>
1133 </xsl:otherwise>
1134 </xsl:choose>
1135 </xsl:template>
1136 <!-- /helper.uri.fix -->
1137
1138
1139 <!-- ==================================================================== -->
1140 <!-- Ignore table hints used for latex                                    -->
1141 <!-- ==================================================================== -->
1142 <xsl:template match="columnspec">
1143 </xsl:template>
1144
1145 <xsl:template match="column">
1146 </xsl:template>
1147
1148 </xsl:stylesheet>