2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:html='http://www.w3.org/1999/xhtml'
4 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
5 exclude-result-prefixes="doc html"
8 <!-- ********************************************************************
9 $Id: website-common.xsl 8100 2008-08-03 18:15:51Z mzjn $
10 ********************************************************************
12 This file is part of the WebSite distribution.
13 See ../README or http://nwalsh.com/website/ for copyright
14 copyright and other information.
16 ******************************************************************** -->
18 <!-- ==================================================================== -->
20 <xsl:import href="../html/docbook.xsl"/>
21 <xsl:import href="xbel.xsl"/>
22 <xsl:include href="../VERSION"/>
23 <xsl:include href="param.xsl"/>
24 <xsl:include href="head.xsl"/>
25 <xsl:include href="rss.xsl"/>
26 <xsl:include href="olink.xsl"/>
28 <xsl:preserve-space elements="*"/>
29 <xsl:strip-space elements="website webpage"/>
31 <xsl:output method="html"
34 <!-- ==================================================================== -->
36 <xsl:template name="admon.graphic">
37 <xsl:param name="node" select="."/>
38 <xsl:call-template name="root-rel-path"/>
39 <xsl:value-of select="$admon.graphics.path"/>
41 <xsl:when test="name($node)='note'">note</xsl:when>
42 <xsl:when test="name($node)='warning'">warning</xsl:when>
43 <xsl:when test="name($node)='caution'">caution</xsl:when>
44 <xsl:when test="name($node)='tip'">tip</xsl:when>
45 <xsl:when test="name($node)='important'">important</xsl:when>
46 <xsl:otherwise>note</xsl:otherwise>
48 <xsl:value-of select="$admon.graphics.extension"/>
51 <doc:template name="admon.graphic">
52 <refpurpose>Select appropriate admonition graphic</refpurpose>
54 <para>Selects the appropriate admonition graphic file and returns the
55 fully qualified path to it.</para>
59 <varlistentry><term>node</term>
61 <para>The source node to use for the purpose of selection. It should
62 be one of the admonition elements (<sgmltag>note</sgmltag>,
63 <sgmltag>warning</sgmltag>, etc.). The default node is the context
70 <para>The fully qualified path to the admonition graphic. If the
71 <varname>node</varname> is not an admonition element, the
72 <quote>note</quote> graphic is returned.</para>
76 <!-- ==================================================================== -->
78 <xsl:template match="/">
79 <xsl:apply-templates/>
82 <!-- ==================================================================== -->
84 <xsl:template name="allpages.banner"/>
86 <!-- ==================================================================== -->
88 <xsl:template name="webpage.table.footer"/>
90 <xsl:template name="webpage.footer">
91 <xsl:variable name="page" select="."/>
92 <xsl:variable name="footers" select="$page/config[@param='footer']
93 |$page/config[@param='footlink']
94 |$autolayout/autolayout/config[@param='footer']
95 |$autolayout/autolayout/config[@param='footlink']"/>
97 <xsl:variable name="tocentry" select="$autolayout//*[@id=$page/@id]"/>
98 <xsl:variable name="toc" select="($tocentry/ancestor-or-self::toc[1]
99 | $autolayout//toc[1])[last()]"/>
101 <xsl:variable name="feedback">
103 <xsl:when test="$page/config[@param='feedback.href']">
104 <xsl:value-of select="($page/config[@param='feedback.href'])[1]/@value"/>
106 <xsl:when test="$autolayout/autolayout/config[@param='feedback.href']">
107 <xsl:value-of select="($autolayout/autolayout/config[@param='feedback.href'])[1]/@value"/>
110 <xsl:value-of select="$feedback.href"/>
115 <div class="navfoot">
116 <xsl:if test="$footer.hr != 0"><hr/></xsl:if>
117 <table width="100%" border="0" summary="Footer navigation">
119 <td width="33%" align="left">
120 <span class="footdate">
121 <xsl:call-template name="rcsdate.format">
122 <xsl:with-param name="rcsdate"
123 select="$page/config[@param='rcsdate']/@value"/>
127 <td width="34%" align="center">
129 <xsl:when test="not($toc)">
131 <xsl:text>Cannot determine TOC for </xsl:text>
132 <xsl:value-of select="$page/@id"/>
135 <xsl:when test="$toc/@id = $page/@id">
136 <!-- nop; this is the home page -->
139 <span class="foothome">
141 <xsl:attribute name="href">
142 <xsl:call-template name="homeuri"/>
144 <xsl:call-template name="gentext.nav.home"/>
146 <xsl:if test="$footers">
147 <xsl:text> | </xsl:text>
153 <xsl:apply-templates select="$footers" mode="footer.link.mode"/>
155 <td width="33%" align="right">
157 <xsl:when test="$feedback != ''">
158 <span class="footfeed">
161 <xsl:when test="$feedback.with.ids != 0">
162 <xsl:attribute name="href">
163 <xsl:value-of select="$feedback"/>
164 <xsl:value-of select="$page/@id"/>
168 <xsl:attribute name="href">
169 <xsl:value-of select="$feedback"/>
173 <xsl:value-of select="$feedback.link.text"/>
177 <xsl:otherwise> </xsl:otherwise>
182 <td colspan="3" align="right">
183 <span class="footcopy">
185 <xsl:when test="head/copyright">
186 <xsl:apply-templates select="head/copyright" mode="footer.mode"/>
189 <xsl:apply-templates mode="footer.mode"
190 select="$autolayout/autolayout/copyright"/>
196 <xsl:if test="$sequential.links != 0">
198 <xsl:variable name="prev">
199 <xsl:call-template name="prev.page"/>
201 <xsl:variable name="next">
202 <xsl:call-template name="next.page"/>
204 <xsl:variable name="ptoc"
205 select="$autolayout/autolayout//*[$prev=@id]"/>
206 <xsl:variable name="ntoc"
207 select="$autolayout/autolayout//*[$next=@id]"/>
209 <td align="left" valign="top">
211 <xsl:when test="$prev != ''">
212 <xsl:call-template name="link.to.page">
213 <xsl:with-param name="frompage" select="$tocentry"/>
214 <xsl:with-param name="page" select="$ptoc"/>
215 <xsl:with-param name="linktext" select="'Prev'"/>
218 <xsl:otherwise> </xsl:otherwise>
222 <td align="right" valign="top">
224 <xsl:when test="$next != ''">
225 <xsl:call-template name="link.to.page">
226 <xsl:with-param name="frompage" select="$tocentry"/>
227 <xsl:with-param name="page" select="$ntoc"/>
228 <xsl:with-param name="linktext" select="'Next'"/>
231 <xsl:otherwise> </xsl:otherwise>
240 <xsl:template name="rcsdate.format">
241 <xsl:param name="rcsdate" select="./config[@param='rcsdate']/@value"/>
242 <xsl:value-of select="$rcsdate"/>
245 <xsl:template match="config" mode="footer.link.mode">
246 <span class="foothome">
247 <xsl:if test="position() > 1">
248 <xsl:text> | </xsl:text>
251 <xsl:when test="@param='footlink'">
252 <xsl:variable name="id" select="@value"/>
253 <xsl:variable name="tocentry"
254 select="$autolayout//*[@id=$id]"/>
255 <xsl:if test="count($tocentry) != 1">
257 <xsl:text>Footlink to </xsl:text>
258 <xsl:value-of select="$id"/>
259 <xsl:text> does not id a unique page.</xsl:text>
262 <xsl:variable name="dir">
264 <xsl:when test="starts-with($tocentry/@dir, '/')">
265 <xsl:value-of select="substring($tocentry/@dir, 2)"/>
268 <xsl:value-of select="$tocentry/@dir"/>
273 <xsl:attribute name="href">
274 <xsl:call-template name="root-rel-path"/>
275 <xsl:value-of select="$dir"/>
276 <xsl:value-of select="$filename-prefix"/>
277 <xsl:value-of select="$tocentry/@filename"/>
279 <xsl:value-of select="@altval"/>
284 <xsl:value-of select="@altval"/>
291 <!-- ==================================================================== -->
293 <xsl:template name="homeuri">
294 <xsl:param name="page" select="ancestor-or-self::webpage"/>
295 <xsl:variable name="id" select="$page/@id"/>
296 <xsl:variable name="tocentry"
297 select="$autolayout//*[@id=$id]"/>
298 <xsl:variable name="toc" select="$tocentry/ancestor::toc"/>
299 <xsl:variable name="first-toc"
300 select="$autolayout/autolayout/toc[1]"/>
302 <xsl:call-template name="root-rel-path"/>
304 <xsl:when test="$toc">
306 <xsl:when test="starts-with($toc/@dir, '/')">
307 <xsl:value-of select="substring($toc/@dir, 2)"/>
310 <xsl:value-of select="$toc/@dir"/>
313 <xsl:value-of select="$filename-prefix"/>
314 <xsl:value-of select="$toc/@filename"/>
318 <xsl:when test="starts-with($first-toc/@dir, '/')">
319 <xsl:value-of select="substring($first-toc/@dir, 2)"/>
322 <xsl:value-of select="$first-toc/@dir"/>
325 <xsl:value-of select="$filename-prefix"/>
326 <xsl:value-of select="$first-toc/@filename"/>
331 <!-- ==================================================================== -->
333 <xsl:template match="copyright" mode="footer.mode">
334 <span class="{name(.)}">
335 <xsl:call-template name="gentext.element.name"/>
336 <xsl:call-template name="gentext.space"/>
337 <xsl:call-template name="dingbat">
338 <xsl:with-param name="dingbat">copyright</xsl:with-param>
340 <xsl:call-template name="gentext.space"/>
341 <xsl:apply-templates select="year" mode="footer.mode"/>
342 <xsl:call-template name="gentext.space"/>
343 <xsl:apply-templates select="holder" mode="footer.mode"/>
344 <xsl:value-of select="$biblioentry.item.separator"/>
348 <xsl:template match="year" mode="footer.mode">
349 <xsl:apply-templates/><xsl:text>, </xsl:text>
352 <xsl:template match="year[position()=last()]" mode="footer.mode">
353 <xsl:apply-templates/>
356 <xsl:template match="holder" mode="footer.mode">
357 <xsl:apply-templates/>
358 <xsl:if test="position() != last()">, </xsl:if>
361 <!-- ==================================================================== -->
363 <xsl:template match="config">
366 <!-- ==================================================================== -->
368 <xsl:template match="head">
371 <xsl:template match="head/title" mode="title.mode">
372 <h1><xsl:apply-templates/></h1>
375 <xsl:template match="head/title">
376 <xsl:apply-templates/>
379 <!-- ==================================================================== -->
381 <xsl:template name="directory-depth">
382 <xsl:param name="dir"></xsl:param>
383 <xsl:param name="count" select="0"/>
386 <xsl:when test='contains($dir,"/")'>
387 <xsl:call-template name="directory-depth">
388 <xsl:with-param name="dir" select="substring-after($dir,'/')"/>
389 <xsl:with-param name="count" select="$count + 1"/>
394 <xsl:when test='$dir=""'>
395 <xsl:value-of select="$count"/>
398 <xsl:value-of select="$count + 1"/>
405 <xsl:template name="root-rel-path">
406 <xsl:param name="webpage" select="ancestor-or-self::webpage"/>
407 <xsl:variable name="tocentry" select="$autolayout//*[$webpage/@id=@id]"/>
408 <xsl:apply-templates select="$tocentry" mode="toc-rel-path"/>
411 <!-- ==================================================================== -->
413 <xsl:template match="footnote" mode="footnote.number">
415 <xsl:when test="ancestor::table|ancestor::informaltable">
416 <xsl:number level="any" from="table|informaltable" format="a"/>
419 <xsl:number level="any" from="webpage" format="1"/>
424 <xsl:template name="process.footnotes">
425 <!-- we're only interested in footnotes that occur on this page, not
426 on descendants of this page (which will be similarly processed) -->
427 <xsl:variable name="thispage"
428 select="ancestor-or-self::webpage"/>
429 <xsl:variable name="footnotes"
430 select=".//footnote[ancestor-or-self::webpage=$thispage]"/>
431 <xsl:variable name="table.footnotes"
432 select=".//table//footnote[ancestor-or-self::webpage=$thispage]
433 |.//informaltable//footnote[ancestor-or-self::webpage
436 <!-- Only bother to do this if there's at least one non-table footnote -->
437 <xsl:if test="count($footnotes)>count($table.footnotes)">
438 <div class="footnotes">
439 <hr width="100" align="left"/>
440 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
445 <!-- ==================================================================== -->
447 <xsl:template match="@*" mode="copy">
448 <xsl:attribute name="{local-name(.)}">
449 <xsl:value-of select="."/>
453 <xsl:template match="html:*">
454 <xsl:element name="{local-name(.)}" namespace="">
455 <xsl:apply-templates select="@*" mode="copy"/>
456 <xsl:apply-templates/>
460 <!-- ==================================================================== -->
462 <xsl:template match="processing-instruction('php')">
463 <xsl:processing-instruction name="php">
464 <xsl:value-of select="."/>
465 </xsl:processing-instruction>
468 <!-- ==================================================================== -->
470 <xsl:template match="rddl:*" xmlns:rddl='http://www.rddl.org/'>
471 <xsl:element name="{name(.)}">
472 <xsl:apply-templates select="@*" mode="copy"/>
473 <xsl:apply-templates/>
477 <xsl:template match="section[@rddl]" xmlns:rddl='http://www.rddl.org/'>
478 <xsl:variable name="rddl" select="id(@rddl)"/>
480 <xsl:when test="local-name($rddl) != 'resource'">
482 <xsl:text>Warning: section rddl isn't an rddl:resource: </xsl:text>
483 <xsl:value-of select="@rddl"/>
488 <xsl:element name="{name($rddl)}">
489 <xsl:apply-templates select="$rddl/@*" mode="copy"/>
496 <!-- ==================================================================== -->
498 <xsl:template name="page.uri">
499 <xsl:param name="href" select="''"/>
500 <xsl:param name="page" select="ancestor-or-self::tocentry"/>
501 <xsl:param name="relpath">
502 <xsl:call-template name="toc-rel-path">
503 <xsl:with-param name="pageid" select="$page/@id"/>
508 <xsl:message><xsl:value-of select="$page/@id"/>: <xsl:value-of select="$relpath"/></xsl:message>
511 <xsl:variable name="dir">
513 <xsl:when test="starts-with($page/@dir, '/')">
514 <xsl:value-of select="substring($page/@dir, 2)"/>
517 <xsl:value-of select="$page/@dir"/>
522 <xsl:variable name="html.href">
524 <xsl:when test="$href != ''">
525 <xsl:value-of select="$href"/>
527 <xsl:when test="$page/@href">
528 <xsl:value-of select="$page/@href"/>
531 <xsl:value-of select="concat($relpath,$dir,$filename-prefix)"/>
532 <xsl:value-of select="$page/@filename"/>
537 <xsl:value-of select="$html.href"/>
540 <xsl:template name="link.to.page">
541 <xsl:param name="href" select="''"/>
542 <xsl:param name="frompage"/>
543 <xsl:param name="page" select="ancestor-or-self::tocentry"/>
544 <xsl:param name="relpath">
546 <xsl:when test="$frompage">
547 <xsl:call-template name="toc-rel-path">
548 <xsl:with-param name="pageid" select="$frompage/@id"/>
552 <xsl:call-template name="toc-rel-path">
553 <xsl:with-param name="pageid" select="$page/@id"/>
558 <xsl:param name="linktext" select="'???'"/>
561 <xsl:attribute name="href">
562 <xsl:call-template name="page.uri">
563 <xsl:with-param name="href" select="$href"/>
564 <xsl:with-param name="page" select="$page"/>
565 <xsl:with-param name="relpath" select="$relpath"/>
568 <xsl:if test="summary">
569 <xsl:attribute name="title">
570 <xsl:value-of select="normalize-space(string(summary))"/>
573 <xsl:copy-of select="$linktext"/>
577 <xsl:template name="next.page">
578 <xsl:param name="page" select="ancestor-or-self::webpage"/>
579 <xsl:variable name="id" select="$page/@id"/>
580 <xsl:variable name="tocentry"
581 select="$autolayout//*[@id=$id]"/>
582 <xsl:variable name="next-following"
583 select="$tocentry/following::tocentry[1]"/>
584 <xsl:variable name="next-child"
585 select="$tocentry/descendant::tocentry[1]"/>
587 <xsl:variable name="nextid">
589 <xsl:when test="$next-child">
590 <xsl:value-of select="$next-child/@id"/>
592 <xsl:when test="$next-following">
593 <xsl:value-of select="$next-following/@id"/>
595 <xsl:otherwise></xsl:otherwise>
598 <xsl:value-of select="$nextid"/>
601 <xsl:template name="prev.page">
602 <xsl:param name="page" select="ancestor-or-self::webpage"/>
603 <xsl:variable name="id" select="$page/@id"/>
604 <xsl:variable name="tocentry"
605 select="$autolayout//*[@id=$id]"/>
606 <xsl:variable name="prev-ancestor"
607 select="($tocentry/ancestor::tocentry
608 |$tocentry/ancestor::toc)[last()]"/>
609 <xsl:variable name="prev-sibling"
610 select="$tocentry/preceding-sibling::tocentry[1]"/>
612 <xsl:variable name="previd">
614 <xsl:when test="$prev-sibling">
615 <xsl:value-of select="$prev-sibling/@id"/>
617 <xsl:when test="$prev-ancestor">
618 <xsl:value-of select="$prev-ancestor/@id"/>
620 <xsl:otherwise></xsl:otherwise>
623 <xsl:value-of select="$previd"/>
626 <xsl:template name="top.page">
627 <xsl:param name="page" select="ancestor-or-self::webpage"/>
628 <xsl:variable name="id" select="$page/@id"/>
629 <xsl:variable name="tocentry"
630 select="$autolayout//*[@id=$id]"/>
632 <xsl:value-of select="$tocentry/ancestor::toc/@id"/>
635 <xsl:template name="up.page">
636 <xsl:param name="page" select="ancestor-or-self::webpage"/>
637 <xsl:variable name="id" select="$page/@id"/>
638 <xsl:variable name="tocentry"
639 select="$autolayout//*[@id=$id]"/>
642 <xsl:when test="$tocentry/ancestor::tocentry">
643 <xsl:value-of select="$tocentry/ancestor::tocentry[1]/@id"/>
645 <xsl:when test="$tocentry/ancestor::toc">
646 <xsl:value-of select="$tocentry/ancestor::toc[1]/@id"/>
648 <xsl:otherwise></xsl:otherwise>
652 <xsl:template name="first.page">
653 <xsl:param name="page" select="ancestor-or-self::webpage"/>
654 <xsl:variable name="id" select="$page/@id"/>
655 <xsl:variable name="tocentry"
656 select="$autolayout//*[@id=$id]"/>
658 <xsl:value-of select="$tocentry/preceding-sibling::tocentry[last()]/@id"/>
661 <xsl:template name="last.page">
662 <xsl:param name="page" select="ancestor-or-self::webpage"/>
663 <xsl:variable name="id" select="$page/@id"/>
664 <xsl:variable name="tocentry"
665 select="$autolayout//*[@id=$id]"/>
667 <xsl:variable name="prev-sibling"
668 select="$tocentry/preceding-sibling::tocentry[1]"/>
670 <xsl:value-of select="$tocentry/following-sibling::tocentry[last()]/@id"/>
673 <xsl:template match="autolayout" mode="collect.targets">
675 <xsl:apply-templates mode="olink.mode"/>
679 <xsl:template match="toc|tocentry|notoc" mode="olink.mode">
680 <xsl:text> </xsl:text>
681 <xsl:call-template name="tocentry"/>
682 <xsl:apply-templates select="tocentry" mode="olink.mode"/>
686 <xsl:template name="tocentry">
688 <xsl:when test="@href">
692 <xsl:if test="not(@page)">
693 <xsl:message terminate="yes">
694 <xsl:text>All toc entries must have a page attribute.</xsl:text>
698 <xsl:variable name="page" select="document(@page,.)"/>
700 <xsl:if test="not($page/*[1]/@id)">
701 <xsl:message terminate="yes">
702 <xsl:value-of select="@page"/>
703 <xsl:text>: missing ID.</xsl:text>
707 <xsl:variable name="id" select="$page/*[1]/@id"/>
709 <xsl:variable name="filename">
711 <xsl:when test="@filename">
712 <xsl:value-of select="$filename-prefix"/>
713 <xsl:value-of select="@filename"/>
715 <xsl:when test="/layout/config[@param='default-filename']">
716 <xsl:value-of select="$filename-prefix"/>
717 <xsl:value-of select="(/layout/config[@param='default-filename'])[1]/@value"/>
719 <xsl:otherwise><xsl:value-of select="$filename-prefix"/>index.html</xsl:otherwise>
723 <xsl:variable name="dir" select="@dir"/>
725 <xsl:if test="$filename = ''">
726 <xsl:message terminate="yes">
727 <xsl:value-of select="@page"/>
728 <xsl:text>: missing filename.</xsl:text>
734 <xsl:value-of select="@page"/>
735 <xsl:text>: </xsl:text>
736 <xsl:if test="$dir != ''">
737 <xsl:value-of select="$dir"/>
739 <xsl:value-of select="$filename"/>
744 <xsl:attribute name="targetdoc">
745 <xsl:value-of select="$id"/>
747 <xsl:attribute name="baseuri">
748 <xsl:value-of select="$filename"/>
750 <xsl:if test="$dir != ''">
751 <xsl:attribute name="dir">
752 <xsl:value-of select="$dir"/>
756 <xsl:apply-templates select="$page" mode="olink.mode"/>
762 <xsl:template match="webpage" mode="olink.mode">
763 <xsl:call-template name="div"/>
766 <xsl:template match="webpage" mode="xref-to" >
767 <xsl:param name="referrer"/>
768 <xsl:param name="xrefstyle"/>
770 <xsl:apply-templates select="." mode="object.xref.markup">
771 <xsl:with-param name="purpose" select="'xref'"/>
772 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
773 <xsl:with-param name="referrer" select="$referrer"/>
774 </xsl:apply-templates>
775 <!-- FIXME: What about "in Chapter X"? -->
778 <xsl:template match="webpage" mode="title.markup">
779 <xsl:param name="allow-anchors" select="0"/>
780 <xsl:apply-templates select="head/title"
782 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
783 </xsl:apply-templates>
786 <xsl:param name="local.l10n.xml" select="document('')" />
787 <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
788 <l:l10n language="en">
789 <l:context name="title">
790 <l:template name="webpage" text="%t"/>
792 <l:context name="xref">
793 <l:template name="webpage" text="%t"/>
796 <l:l10n language="de">
797 <l:context name="title">
798 <l:template name="webpage" text="%t"/>
800 <l:context name="xref">
801 <l:template name="webpage" text="%t"/>
804 <l:l10n language="fr">
805 <l:context name="title">
806 <l:template name="webpage" text="%t"/>
808 <l:context name="xref">
809 <l:template name="webpage" text="%t"/>
812 <l:l10n language="es">
813 <l:context name="title">
814 <l:template name="webpage" text="%t"/>
816 <l:context name="xref">
817 <l:template name="webpage" text="%t"/>