Debian Codegraph @

docbook-xsl-ns/website/website-common.xsl

raw
1 <?xml version='1.0'?>
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"
6 version='1.0'>
7
8 <!-- ********************************************************************
9
10 This file is part of the WebSite distribution.
11 See ../README or http://nwalsh.com/website/ for copyright
12 copyright and other information.
13
14 ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:import href="../html/docbook.xsl"/>
19 <xsl:import href="xbel.xsl"/>
20 <xsl:include href="../VERSION.xsl"/>
21 <xsl:include href="param.xsl"/>
22 <xsl:include href="head.xsl"/>
23 <xsl:include href="rss.xsl"/>
24 <xsl:include href="olink.xsl"/>
25
26 <xsl:preserve-space elements="*"/>
27 <xsl:strip-space elements="website webpage"/>
28
29 <xsl:output method="html"
30 indent="no"/>
31
32 <!-- ==================================================================== -->
33
34 <xsl:template name="admon.graphic">
35 <xsl:param name="node" select="."/>
36 <xsl:call-template name="root-rel-path"/>
37 <xsl:value-of select="$admon.graphics.path"/>
38 <xsl:choose>
39 <xsl:when test="name($node)='note'">note</xsl:when>
40 <xsl:when test="name($node)='warning'">warning</xsl:when>
41 <xsl:when test="name($node)='caution'">caution</xsl:when>
42 <xsl:when test="name($node)='tip'">tip</xsl:when>
43 <xsl:when test="name($node)='important'">important</xsl:when>
44 <xsl:otherwise>note</xsl:otherwise>
45 </xsl:choose>
46 <xsl:value-of select="$admon.graphics.extension"/>
47 </xsl:template>
48
49 <doc:template name="admon.graphic">
50 <refpurpose>Select appropriate admonition graphic</refpurpose>
51 <refdescription>
52 <para>Selects the appropriate admonition graphic file and returns the
53 fully qualified path to it.</para>
54 </refdescription>
55 <refparam>
56 <variablelist>
57 <varlistentry><term>node</term>
58 <listitem>
59 <para>The source node to use for the purpose of selection. It should
60 be one of the admonition elements (<sgmltag>note</sgmltag>,
61 <sgmltag>warning</sgmltag>, etc.). The default node is the context
62 node.</para>
63 </listitem>
64 </varlistentry>
65 </variablelist>
66 </refparam>
67 <refreturns>
68 <para>The fully qualified path to the admonition graphic. If the
69 <varname>node</varname> is not an admonition element, the
70 <quote>note</quote> graphic is returned.</para>
71 </refreturns>
72 </doc:template>
73
74 <!-- ==================================================================== -->
75
76 <xsl:template match="/">
77 <xsl:apply-templates/>
78 </xsl:template>
79
80 <!-- ==================================================================== -->
81
82 <xsl:template name="allpages.banner"/>
83
84 <!-- ==================================================================== -->
85
86 <xsl:template name="webpage.table.footer"/>
87
88 <xsl:template name="webpage.footer">
89 <xsl:variable name="page" select="."/>
90 <xsl:variable name="footers" select="$page/config[@param='footer']
91 |$page/config[@param='footlink']
92 |$autolayout/autolayout/config[@param='footer']
93 |$autolayout/autolayout/config[@param='footlink']"/>
94
95 <xsl:variable name="tocentry" select="$autolayout//*[@id=$page/@id]"/>
96 <xsl:variable name="toc" select="($tocentry/ancestor-or-self::toc[1]
97 | $autolayout//toc[1])[last()]"/>
98
99 <xsl:variable name="feedback">
100 <xsl:choose>
101 <xsl:when test="$page/config[@param='feedback.href']">
102 <xsl:value-of select="($page/config[@param='feedback.href'])[1]/@value"/>
103 </xsl:when>
104 <xsl:when test="$autolayout/autolayout/config[@param='feedback.href']">
105 <xsl:value-of select="($autolayout/autolayout/config[@param='feedback.href'])[1]/@value"/>
106 </xsl:when>
107 <xsl:otherwise>
108 <xsl:value-of select="$feedback.href"/>
109 </xsl:otherwise>
110 </xsl:choose>
111 </xsl:variable>
112
113 <div class="navfoot">
114 <xsl:if test="$footer.hr != 0"><hr/></xsl:if>
115 <table width="100%" border="0" summary="Footer navigation">
116 <tr>
117 <td width="33%" align="left">
118 <span class="footdate">
119 <xsl:call-template name="rcsdate.format">
120 <xsl:with-param name="rcsdate"
121 select="$page/config[@param='rcsdate']/@value"/>
122 </xsl:call-template>
123 </span>
124 </td>
125 <td width="34%" align="center">
126 <xsl:choose>
127 <xsl:when test="not($toc)">
128 <xsl:message>
129 <xsl:text>Cannot determine TOC for </xsl:text>
130 <xsl:value-of select="$page/@id"/>
131 </xsl:message>
132 </xsl:when>
133 <xsl:when test="$toc/@id = $page/@id">
134 <!-- nop; this is the home page -->
135 </xsl:when>
136 <xsl:otherwise>
137 <span class="foothome">
138 <a>
139 <xsl:attribute name="href">
140 <xsl:call-template name="homeuri"/>
141 </xsl:attribute>
142 <xsl:call-template name="gentext.nav.home"/>
143 </a>
144 <xsl:if test="$footers">
145 <xsl:text> | </xsl:text>
146 </xsl:if>
147 </span>
148 </xsl:otherwise>
149 </xsl:choose>
150
151 <xsl:apply-templates select="$footers" mode="footer.link.mode"/>
152 </td>
153 <td width="33%" align="right">
154 <xsl:choose>
155 <xsl:when test="$feedback != ''">
156 <span class="footfeed">
157 <a>
158 <xsl:choose>
159 <xsl:when test="$feedback.with.ids != 0">
160 <xsl:attribute name="href">
161 <xsl:value-of select="$feedback"/>
162 <xsl:value-of select="$page/@id"/>
163 </xsl:attribute>
164 </xsl:when>
165 <xsl:otherwise>
166 <xsl:attribute name="href">
167 <xsl:value-of select="$feedback"/>
168 </xsl:attribute>
169 </xsl:otherwise>
170 </xsl:choose>
171 <xsl:value-of select="$feedback.link.text"/>
172 </a>
173 </span>
174 </xsl:when>
175 <xsl:otherwise>&#160;</xsl:otherwise>
176 </xsl:choose>
177 </td>
178 </tr>
179 <tr>
180 <td colspan="3" align="right">
181 <span class="footcopy">
182 <xsl:choose>
183 <xsl:when test="head/copyright">
184 <xsl:apply-templates select="head/copyright" mode="footer.mode"/>
185 </xsl:when>
186 <xsl:otherwise>
187 <xsl:apply-templates mode="footer.mode"
188 select="$autolayout/autolayout/copyright"/>
189 </xsl:otherwise>
190 </xsl:choose>
191 </span>
192 </td>
193 </tr>
194 <xsl:if test="$sequential.links != 0">
195 <tr>
196 <xsl:variable name="prev">
197 <xsl:call-template name="prev.page"/>
198 </xsl:variable>
199 <xsl:variable name="next">
200 <xsl:call-template name="next.page"/>
201 </xsl:variable>
202 <xsl:variable name="ptoc"
203 select="$autolayout/autolayout//*[$prev=@id]"/>
204 <xsl:variable name="ntoc"
205 select="$autolayout/autolayout//*[$next=@id]"/>
206
207 <td align="left" valign="top">
208 <xsl:choose>
209 <xsl:when test="$prev != ''">
210 <xsl:call-template name="link.to.page">
211 <xsl:with-param name="frompage" select="$tocentry"/>
212 <xsl:with-param name="page" select="$ptoc"/>
213 <xsl:with-param name="linktext" select="'Prev'"/>
214 </xsl:call-template>
215 </xsl:when>
216 <xsl:otherwise>&#160;</xsl:otherwise>
217 </xsl:choose>
218 </td>
219 <td>&#160;</td>
220 <td align="right" valign="top">
221 <xsl:choose>
222 <xsl:when test="$next != ''">
223 <xsl:call-template name="link.to.page">
224 <xsl:with-param name="frompage" select="$tocentry"/>
225 <xsl:with-param name="page" select="$ntoc"/>
226 <xsl:with-param name="linktext" select="'Next'"/>
227 </xsl:call-template>
228 </xsl:when>
229 <xsl:otherwise>&#160;</xsl:otherwise>
230 </xsl:choose>
231 </td>
232 </tr>
233 </xsl:if>
234 </table>
235 </div>
236 </xsl:template>
237
238 <xsl:template name="rcsdate.format">
239 <xsl:param name="rcsdate" select="./config[@param='rcsdate']/@value"/>
240 <xsl:value-of select="$rcsdate"/>
241 </xsl:template>
242
243 <xsl:template match="config" mode="footer.link.mode">
244 <span class="foothome">
245 <xsl:if test="position() &gt; 1">
246 <xsl:text> | </xsl:text>
247 </xsl:if>
248 <xsl:choose>
249 <xsl:when test="@param='footlink'">
250 <xsl:variable name="id" select="@value"/>
251 <xsl:variable name="tocentry"
252 select="$autolayout//*[@id=$id]"/>
253 <xsl:if test="count($tocentry) != 1">
254 <xsl:message>
255 <xsl:text>Footlink to </xsl:text>
256 <xsl:value-of select="$id"/>
257 <xsl:text> does not id a unique page.</xsl:text>
258 </xsl:message>
259 </xsl:if>
260 <xsl:variable name="dir">
261 <xsl:choose>
262 <xsl:when test="starts-with($tocentry/@dir, '/')">
263 <xsl:value-of select="substring($tocentry/@dir, 2)"/>
264 </xsl:when>
265 <xsl:otherwise>
266 <xsl:value-of select="$tocentry/@dir"/>
267 </xsl:otherwise>
268 </xsl:choose>
269 </xsl:variable>
270 <a>
271 <xsl:attribute name="href">
272 <xsl:call-template name="root-rel-path"/>
273 <xsl:value-of select="$dir"/>
274 <xsl:value-of select="$filename-prefix"/>
275 <xsl:value-of select="$tocentry/@filename"/>
276 </xsl:attribute>
277 <xsl:value-of select="@altval"/>
278 </a>
279 </xsl:when>
280 <xsl:otherwise>
281 <a href="{@value}">
282 <xsl:value-of select="@altval"/>
283 </a>
284 </xsl:otherwise>
285 </xsl:choose>
286 </span>
287 </xsl:template>
288
289 <!-- ==================================================================== -->
290
291 <xsl:template name="homeuri">
292 <xsl:param name="page" select="ancestor-or-self::webpage"/>
293 <xsl:variable name="id" select="$page/@id"/>
294 <xsl:variable name="tocentry"
295 select="$autolayout//*[@id=$id]"/>
296 <xsl:variable name="toc" select="$tocentry/ancestor::toc"/>
297 <xsl:variable name="first-toc"
298 select="$autolayout/autolayout/toc[1]"/>
299
300 <xsl:call-template name="root-rel-path"/>
301 <xsl:choose>
302 <xsl:when test="$toc">
303 <xsl:choose>
304 <xsl:when test="starts-with($toc/@dir, '/')">
305 <xsl:value-of select="substring($toc/@dir, 2)"/>
306 </xsl:when>
307 <xsl:otherwise>
308 <xsl:value-of select="$toc/@dir"/>
309 </xsl:otherwise>
310 </xsl:choose>
311 <xsl:value-of select="$filename-prefix"/>
312 <xsl:value-of select="$toc/@filename"/>
313 </xsl:when>
314 <xsl:otherwise>
315 <xsl:choose>
316 <xsl:when test="starts-with($first-toc/@dir, '/')">
317 <xsl:value-of select="substring($first-toc/@dir, 2)"/>
318 </xsl:when>
319 <xsl:otherwise>
320 <xsl:value-of select="$first-toc/@dir"/>
321 </xsl:otherwise>
322 </xsl:choose>
323 <xsl:value-of select="$filename-prefix"/>
324 <xsl:value-of select="$first-toc/@filename"/>
325 </xsl:otherwise>
326 </xsl:choose>
327 </xsl:template>
328
329 <!-- ==================================================================== -->
330
331 <xsl:template match="copyright" mode="footer.mode">
332 <span class="{name(.)}">
333 <xsl:call-template name="gentext.element.name"/>
334 <xsl:call-template name="gentext.space"/>
335 <xsl:call-template name="dingbat">
336 <xsl:with-param name="dingbat">copyright</xsl:with-param>
337 </xsl:call-template>
338 <xsl:call-template name="gentext.space"/>
339 <xsl:apply-templates select="year" mode="footer.mode"/>
340 <xsl:call-template name="gentext.space"/>
341 <xsl:apply-templates select="holder" mode="footer.mode"/>
342 <xsl:value-of select="$biblioentry.item.separator"/>
343 </span>
344 </xsl:template>
345
346 <xsl:template match="year" mode="footer.mode">
347 <xsl:apply-templates/><xsl:text>, </xsl:text>
348 </xsl:template>
349
350 <xsl:template match="year[position()=last()]" mode="footer.mode">
351 <xsl:apply-templates/>
352 </xsl:template>
353
354 <xsl:template match="holder" mode="footer.mode">
355 <xsl:apply-templates/>
356 <xsl:if test="position() != last()">, </xsl:if>
357 </xsl:template>
358
359 <!-- ==================================================================== -->
360
361 <xsl:template match="config">
362 </xsl:template>
363
364 <!-- ==================================================================== -->
365
366 <xsl:template match="head">
367 </xsl:template>
368
369 <xsl:template match="head/title" mode="title.mode">
370 <h1><xsl:apply-templates/></h1>
371 </xsl:template>
372
373 <xsl:template match="head/title">
374 <xsl:apply-templates/>
375 </xsl:template>
376
377 <!-- ==================================================================== -->
378
379 <xsl:template name="directory-depth">
380 <xsl:param name="dir"></xsl:param>
381 <xsl:param name="count" select="0"/>
382
383 <xsl:choose>
384 <xsl:when test='contains($dir,"/")'>
385 <xsl:call-template name="directory-depth">
386 <xsl:with-param name="dir" select="substring-after($dir,'/')"/>
387 <xsl:with-param name="count" select="$count + 1"/>
388 </xsl:call-template>
389 </xsl:when>
390 <xsl:otherwise>
391 <xsl:choose>
392 <xsl:when test='$dir=""'>
393 <xsl:value-of select="$count"/>
394 </xsl:when>
395 <xsl:otherwise>
396 <xsl:value-of select="$count + 1"/>
397 </xsl:otherwise>
398 </xsl:choose>
399 </xsl:otherwise>
400 </xsl:choose>
401 </xsl:template>
402
403 <xsl:template name="root-rel-path">
404 <xsl:param name="webpage" select="ancestor-or-self::webpage"/>
405 <xsl:variable name="tocentry" select="$autolayout//*[$webpage/@id=@id]"/>
406 <xsl:apply-templates select="$tocentry" mode="toc-rel-path"/>
407 </xsl:template>
408
409 <!-- ==================================================================== -->
410
411 <xsl:template match="footnote" mode="footnote.number">
412 <xsl:choose>
413 <xsl:when test="ancestor::table|ancestor::informaltable">
414 <xsl:number level="any" from="table|informaltable" format="a"/>
415 </xsl:when>
416 <xsl:otherwise>
417 <xsl:number level="any" from="webpage" format="1"/>
418 </xsl:otherwise>
419 </xsl:choose>
420 </xsl:template>
421
422 <xsl:template name="process.footnotes">
423 <!-- we're only interested in footnotes that occur on this page, not
424 on descendants of this page (which will be similarly processed) -->
425 <xsl:variable name="thispage"
426 select="ancestor-or-self::webpage"/>
427 <xsl:variable name="footnotes"
428 select=".//footnote[ancestor-or-self::webpage=$thispage]"/>
429 <xsl:variable name="table.footnotes"
430 select=".//table//footnote[ancestor-or-self::webpage=$thispage]
431 |.//informaltable//footnote[ancestor-or-self::webpage
432 =$thispage]"/>
433
434 <!-- Only bother to do this if there's at least one non-table footnote -->
435 <xsl:if test="count($footnotes)>count($table.footnotes)">
436 <div class="footnotes">
437 <hr width="100" align="left"/>
438 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
439 </div>
440 </xsl:if>
441 </xsl:template>
442
443 <!-- ==================================================================== -->
444
445 <xsl:template match="@*" mode="copy">
446 <xsl:attribute name="{local-name(.)}">
447 <xsl:value-of select="."/>
448 </xsl:attribute>
449 </xsl:template>
450
451 <xsl:template match="html:*">
452 <xsl:element name="{local-name(.)}" namespace="">
453 <xsl:apply-templates select="@*" mode="copy"/>
454 <xsl:apply-templates/>
455 </xsl:element>
456 </xsl:template>
457
458 <!-- ==================================================================== -->
459
460 <xsl:template match="processing-instruction('php')">
461 <xsl:processing-instruction name="php">
462 <xsl:value-of select="."/>
463 </xsl:processing-instruction>
464 </xsl:template>
465
466 <!-- ==================================================================== -->
467
468 <xsl:template match="rddl:*" xmlns:rddl='http://www.rddl.org/'>
469 <xsl:element name="{name(.)}">
470 <xsl:apply-templates select="@*" mode="copy"/>
471 <xsl:apply-templates/>
472 </xsl:element>
473 </xsl:template>
474
475 <xsl:template match="section[@rddl]" xmlns:rddl='http://www.rddl.org/'>
476 <xsl:variable name="rddl" select="id(@rddl)"/>
477 <xsl:choose>
478 <xsl:when test="local-name($rddl) != 'resource'">
479 <xsl:message>
480 <xsl:text>Warning: section rddl isn't an rddl:resource: </xsl:text>
481 <xsl:value-of select="@rddl"/>
482 </xsl:message>
483 <xsl:apply-imports/>
484 </xsl:when>
485 <xsl:otherwise>
486 <xsl:element name="{name($rddl)}">
487 <xsl:apply-templates select="$rddl/@*" mode="copy"/>
488 <xsl:apply-imports/>
489 </xsl:element>
490 </xsl:otherwise>
491 </xsl:choose>
492 </xsl:template>
493
494 <!-- ==================================================================== -->
495
496 <xsl:template name="page.uri">
497 <xsl:param name="href" select="''"/>
498 <xsl:param name="page" select="ancestor-or-self::tocentry"/>
499 <xsl:param name="relpath">
500 <xsl:call-template name="toc-rel-path">
501 <xsl:with-param name="pageid" select="$page/@id"/>
502 </xsl:call-template>
503 </xsl:param>
504
505 <!--
506 <xsl:message><xsl:value-of select="$page/@id"/>: <xsl:value-of select="$relpath"/></xsl:message>
507 -->
508
509 <xsl:variable name="dir">
510 <xsl:choose>
511 <xsl:when test="starts-with($page/@dir, '/')">
512 <xsl:value-of select="substring($page/@dir, 2)"/>
513 </xsl:when>
514 <xsl:otherwise>
515 <xsl:value-of select="$page/@dir"/>
516 </xsl:otherwise>
517 </xsl:choose>
518 </xsl:variable>
519
520 <xsl:variable name="html.href">
521 <xsl:choose>
522 <xsl:when test="$href != ''">
523 <xsl:value-of select="$href"/>
524 </xsl:when>
525 <xsl:when test="$page/@href">
526 <xsl:value-of select="$page/@href"/>
527 </xsl:when>
528 <xsl:otherwise>
529 <xsl:value-of select="concat($relpath,$dir,$filename-prefix)"/>
530 <xsl:value-of select="$page/@filename"/>
531 </xsl:otherwise>
532 </xsl:choose>
533 </xsl:variable>
534
535 <xsl:value-of select="$html.href"/>
536 </xsl:template>
537
538 <xsl:template name="link.to.page">
539 <xsl:param name="href" select="''"/>
540 <xsl:param name="frompage"/>
541 <xsl:param name="page" select="ancestor-or-self::tocentry"/>
542 <xsl:param name="relpath">
543 <xsl:choose>
544 <xsl:when test="$frompage">
545 <xsl:call-template name="toc-rel-path">
546 <xsl:with-param name="pageid" select="$frompage/@id"/>
547 </xsl:call-template>
548 </xsl:when>
549 <xsl:otherwise>
550 <xsl:call-template name="toc-rel-path">
551 <xsl:with-param name="pageid" select="$page/@id"/>
552 </xsl:call-template>
553 </xsl:otherwise>
554 </xsl:choose>
555 </xsl:param>
556 <xsl:param name="linktext" select="'???'"/>
557
558 <a>
559 <xsl:attribute name="href">
560 <xsl:call-template name="page.uri">
561 <xsl:with-param name="href" select="$href"/>
562 <xsl:with-param name="page" select="$page"/>
563 <xsl:with-param name="relpath" select="$relpath"/>
564 </xsl:call-template>
565 </xsl:attribute>
566 <xsl:if test="summary">
567 <xsl:attribute name="title">
568 <xsl:value-of select="normalize-space(string(summary))"/>
569 </xsl:attribute>
570 </xsl:if>
571 <xsl:copy-of select="$linktext"/>
572 </a>
573 </xsl:template>
574
575 <xsl:template name="next.page">
576 <xsl:param name="page" select="ancestor-or-self::webpage"/>
577 <xsl:variable name="id" select="$page/@id"/>
578 <xsl:variable name="tocentry"
579 select="$autolayout//*[@id=$id]"/>
580 <xsl:variable name="next-following"
581 select="$tocentry/following::tocentry[1]"/>
582 <xsl:variable name="next-child"
583 select="$tocentry/descendant::tocentry[1]"/>
584
585 <xsl:variable name="nextid">
586 <xsl:choose>
587 <xsl:when test="$next-child">
588 <xsl:value-of select="$next-child/@id"/>
589 </xsl:when>
590 <xsl:when test="$next-following">
591 <xsl:value-of select="$next-following/@id"/>
592 </xsl:when>
593 <xsl:otherwise></xsl:otherwise>
594 </xsl:choose>
595 </xsl:variable>
596 <xsl:value-of select="$nextid"/>
597 </xsl:template>
598
599 <xsl:template name="prev.page">
600 <xsl:param name="page" select="ancestor-or-self::webpage"/>
601 <xsl:variable name="id" select="$page/@id"/>
602 <xsl:variable name="tocentry"
603 select="$autolayout//*[@id=$id]"/>
604 <xsl:variable name="prev-ancestor"
605 select="($tocentry/ancestor::tocentry
606 |$tocentry/ancestor::toc)[last()]"/>
607 <xsl:variable name="prev-sibling"
608 select="$tocentry/preceding-sibling::tocentry[1]"/>
609
610 <xsl:variable name="previd">
611 <xsl:choose>
612 <xsl:when test="$prev-sibling">
613 <xsl:value-of select="$prev-sibling/@id"/>
614 </xsl:when>
615 <xsl:when test="$prev-ancestor">
616 <xsl:value-of select="$prev-ancestor/@id"/>
617 </xsl:when>
618 <xsl:otherwise></xsl:otherwise>
619 </xsl:choose>
620 </xsl:variable>
621 <xsl:value-of select="$previd"/>
622 </xsl:template>
623
624 <xsl:template name="top.page">
625 <xsl:param name="page" select="ancestor-or-self::webpage"/>
626 <xsl:variable name="id" select="$page/@id"/>
627 <xsl:variable name="tocentry"
628 select="$autolayout//*[@id=$id]"/>
629
630 <xsl:value-of select="$tocentry/ancestor::toc/@id"/>
631 </xsl:template>
632
633 <xsl:template name="up.page">
634 <xsl:param name="page" select="ancestor-or-self::webpage"/>
635 <xsl:variable name="id" select="$page/@id"/>
636 <xsl:variable name="tocentry"
637 select="$autolayout//*[@id=$id]"/>
638
639 <xsl:choose>
640 <xsl:when test="$tocentry/ancestor::tocentry">
641 <xsl:value-of select="$tocentry/ancestor::tocentry[1]/@id"/>
642 </xsl:when>
643 <xsl:when test="$tocentry/ancestor::toc">
644 <xsl:value-of select="$tocentry/ancestor::toc[1]/@id"/>
645 </xsl:when>
646 <xsl:otherwise></xsl:otherwise>
647 </xsl:choose>
648 </xsl:template>
649
650 <xsl:template name="first.page">
651 <xsl:param name="page" select="ancestor-or-self::webpage"/>
652 <xsl:variable name="id" select="$page/@id"/>
653 <xsl:variable name="tocentry"
654 select="$autolayout//*[@id=$id]"/>
655
656 <xsl:value-of select="$tocentry/preceding-sibling::tocentry[last()]/@id"/>
657 </xsl:template>
658
659 <xsl:template name="last.page">
660 <xsl:param name="page" select="ancestor-or-self::webpage"/>
661 <xsl:variable name="id" select="$page/@id"/>
662 <xsl:variable name="tocentry"
663 select="$autolayout//*[@id=$id]"/>
664
665 <xsl:variable name="prev-sibling"
666 select="$tocentry/preceding-sibling::tocentry[1]"/>
667
668 <xsl:value-of select="$tocentry/following-sibling::tocentry[last()]/@id"/>
669 </xsl:template>
670
671 <xsl:template match="autolayout" mode="collect.targets">
672 <targetset>
673 <xsl:apply-templates mode="olink.mode"/>
674 </targetset>
675 </xsl:template>
676
677 <xsl:template match="toc|tocentry|notoc" mode="olink.mode">
678 <xsl:text>&#10;</xsl:text>
679 <xsl:call-template name="tocentry"/>
680 <xsl:apply-templates select="tocentry" mode="olink.mode"/>
681 </xsl:template>
682
683
684 <xsl:template name="tocentry">
685 <xsl:choose>
686 <xsl:when test="@href">
687 <!-- no op -->
688 </xsl:when>
689 <xsl:otherwise>
690 <xsl:if test="not(@page)">
691 <xsl:message terminate="yes">
692 <xsl:text>All toc entries must have a page attribute.</xsl:text>
693 </xsl:message>
694 </xsl:if>
695
696 <xsl:variable name="page" select="document(@page,.)"/>
697
698 <xsl:if test="not($page/*[1]/@id)">
699 <xsl:message terminate="yes">
700 <xsl:value-of select="@page"/>
701 <xsl:text>: missing ID.</xsl:text>
702 </xsl:message>
703 </xsl:if>
704
705 <xsl:variable name="id" select="$page/*[1]/@id"/>
706
707 <xsl:variable name="filename">
708 <xsl:choose>
709 <xsl:when test="@filename">
710 <xsl:value-of select="$filename-prefix"/>
711 <xsl:value-of select="@filename"/>
712 </xsl:when>
713 <xsl:when test="/layout/config[@param='default-filename']">
714 <xsl:value-of select="$filename-prefix"/>
715 <xsl:value-of select="(/layout/config[@param='default-filename'])[1]/@value"/>
716 </xsl:when>
717 <xsl:otherwise><xsl:value-of select="$filename-prefix"/>index.html</xsl:otherwise>
718 </xsl:choose>
719 </xsl:variable>
720
721 <xsl:variable name="dir" select="@dir"/>
722
723 <xsl:if test="$filename = ''">
724 <xsl:message terminate="yes">
725 <xsl:value-of select="@page"/>
726 <xsl:text>: missing filename.</xsl:text>
727 </xsl:message>
728 </xsl:if>
729
730 <!--
731 <xsl:message>
732 <xsl:value-of select="@page"/>
733 <xsl:text>: </xsl:text>
734 <xsl:if test="$dir != ''">
735 <xsl:value-of select="$dir"/>
736 </xsl:if>
737 <xsl:value-of select="$filename"/>
738 </xsl:message>
739 -->
740
741 <document>
742 <xsl:attribute name="targetdoc">
743 <xsl:value-of select="$id"/>
744 </xsl:attribute>
745 <xsl:attribute name="baseuri">
746 <xsl:value-of select="$filename"/>
747 </xsl:attribute>
748 <xsl:if test="$dir != ''">
749 <xsl:attribute name="dir">
750 <xsl:value-of select="$dir"/>
751 </xsl:attribute>
752 </xsl:if>
753
754 <xsl:apply-templates select="$page" mode="olink.mode"/>
755 </document>
756 </xsl:otherwise>
757 </xsl:choose>
758 </xsl:template>
759
760 <xsl:template match="webpage" mode="olink.mode">
761 <xsl:call-template name="div"/>
762 </xsl:template>
763
764 <xsl:template match="webpage" mode="xref-to" >
765 <xsl:param name="referrer"/>
766 <xsl:param name="xrefstyle"/>
767
768 <xsl:apply-templates select="." mode="object.xref.markup">
769 <xsl:with-param name="purpose" select="'xref'"/>
770 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
771 <xsl:with-param name="referrer" select="$referrer"/>
772 </xsl:apply-templates>
773 <!-- FIXME: What about "in Chapter X"? -->
774 </xsl:template>
775
776 <xsl:template match="webpage" mode="title.markup">
777 <xsl:param name="allow-anchors" select="0"/>
778 <xsl:apply-templates select="head/title"
779 mode="title.markup">
780 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
781 </xsl:apply-templates>
782 </xsl:template>
783
784 <xsl:param name="local.l10n.xml" select="document('')" />
785 <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
786 <l:l10n language="en">
787 <l:context name="title">
788 <l:template name="webpage" text="%t"/>
789 </l:context>
790 <l:context name="xref">
791 <l:template name="webpage" text="%t"/>
792 </l:context>
793 </l:l10n>
794 <l:l10n language="de">
795 <l:context name="title">
796 <l:template name="webpage" text="%t"/>
797 </l:context>
798 <l:context name="xref">
799 <l:template name="webpage" text="%t"/>
800 </l:context>
801 </l:l10n>
802 <l:l10n language="fr">
803 <l:context name="title">
804 <l:template name="webpage" text="%t"/>
805 </l:context>
806 <l:context name="xref">
807 <l:template name="webpage" text="%t"/>
808 </l:context>
809 </l:l10n>
810 <l:l10n language="es">
811 <l:context name="title">
812 <l:template name="webpage" text="%t"/>
813 </l:context>
814 <l:context name="xref">
815 <l:template name="webpage" text="%t"/>
816 </l:context>
817 </l:l10n>
818 </l:i18n>
819 </xsl:stylesheet>