1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl cf ng db" version="1.0">
6 <!-- ********************************************************************
7 $Id: chunk-code.xsl 8596 2010-03-20 04:36:45Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
19 <xsl:template match="*" mode="chunk-filename">
20 <!-- returns the filename of a chunk -->
21 <xsl:variable name="ischunk">
22 <xsl:call-template name="chunk"/>
25 <xsl:variable name="fn">
26 <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
31 <xsl:value-of select="$ischunk"/>
32 <xsl:text> (</xsl:text>
33 <xsl:value-of select="local-name(.)"/>
34 <xsl:text>) </xsl:text>
35 <xsl:value-of select="$fn"/>
36 <xsl:text>, </xsl:text>
37 <xsl:call-template name="dbhtml-dir"/>
41 <!-- 2003-11-25 by ndw:
42 The following test used to read test="$ischunk != 0 and $fn != ''"
43 I've removed the ischunk part of the test so that href.to.uri and
44 href.from.uri will be fully qualified even if the source or target
45 isn't a chunk. I *think* that if $fn != '' then it's appropriate
46 to put the directory on the front, even if the element isn't a
47 chunk. I could be wrong. -->
49 <xsl:if test="$fn != ''">
50 <xsl:call-template name="dbhtml-dir"/>
53 <xsl:value-of select="$fn"/>
54 <!-- You can't add the html.ext here because dbhtml filename= may already -->
55 <!-- have added it. It really does have to be handled in the recursive template -->
58 <xsl:template match="*" mode="recursive-chunk-filename">
59 <xsl:param name="recursive" select="false()"/>
61 <!-- returns the filename of a chunk -->
62 <xsl:variable name="ischunk">
63 <xsl:call-template name="chunk"/>
66 <xsl:variable name="dbhtml-filename">
67 <xsl:call-template name="pi.dbhtml_filename"/>
70 <xsl:variable name="filename">
72 <xsl:when test="$dbhtml-filename != ''">
73 <xsl:value-of select="$dbhtml-filename"/>
75 <!-- if this is the root element, use the root.filename -->
76 <xsl:when test="not(parent::*) and $root.filename != ''">
77 <xsl:value-of select="$root.filename"/>
78 <xsl:value-of select="$html.ext"/>
81 <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
83 <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
84 <!-- * if this legalnotice has an ID, then go ahead and use -->
85 <!-- * just the value of that ID as the basename for the file -->
86 <!-- * (that is, without prepending an "ln-" too it) -->
87 <xsl:value-of select="(@id|@xml:id)[1]"/>
88 <xsl:value-of select="$html.ext"/>
91 <!-- * otherwise, if this legalnotice does not have an ID, -->
92 <!-- * then we generate an ID... -->
93 <xsl:variable name="id">
94 <xsl:call-template name="object.id"/>
96 <!-- * ...and then we take that generated ID, prepend an -->
97 <!-- * "ln-" to it, and use that as the basename for the file -->
98 <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
102 <!-- if there's no dbhtml filename, and if we're to use IDs as -->
103 <!-- filenames, then use the ID to generate the filename. -->
104 <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
105 <xsl:value-of select="(@id|@xml:id)[1]"/>
106 <xsl:value-of select="$html.ext"/>
113 <xsl:when test="$ischunk='0'">
114 <!-- if called on something that isn't a chunk, walk up... -->
116 <xsl:when test="count(parent::*)>0">
117 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
118 <xsl:with-param name="recursive" select="$recursive"/>
119 </xsl:apply-templates>
121 <!-- unless there is no up, in which case return "" -->
126 <xsl:when test="not($recursive) and $filename != ''">
127 <!-- if this chunk has an explicit name, use it -->
128 <xsl:value-of select="$filename"/>
131 <xsl:when test="self::set">
132 <xsl:value-of select="$root.filename"/>
133 <xsl:if test="not($recursive)">
134 <xsl:value-of select="$html.ext"/>
138 <xsl:when test="self::book">
139 <xsl:text>bk</xsl:text>
140 <xsl:number level="any" format="01"/>
141 <xsl:if test="not($recursive)">
142 <xsl:value-of select="$html.ext"/>
146 <xsl:when test="self::article">
148 <!-- in a set, make sure we inherit the right book info... -->
149 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
150 <xsl:with-param name="recursive" select="true()"/>
151 </xsl:apply-templates>
154 <xsl:text>ar</xsl:text>
155 <xsl:number level="any" format="01" from="book"/>
156 <xsl:if test="not($recursive)">
157 <xsl:value-of select="$html.ext"/>
161 <xsl:when test="self::preface">
163 <!-- in a set, make sure we inherit the right book info... -->
164 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
165 <xsl:with-param name="recursive" select="true()"/>
166 </xsl:apply-templates>
169 <xsl:text>pr</xsl:text>
170 <xsl:number level="any" format="01" from="book"/>
171 <xsl:if test="not($recursive)">
172 <xsl:value-of select="$html.ext"/>
176 <xsl:when test="self::chapter">
178 <!-- in a set, make sure we inherit the right book info... -->
179 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
180 <xsl:with-param name="recursive" select="true()"/>
181 </xsl:apply-templates>
184 <xsl:text>ch</xsl:text>
185 <xsl:number level="any" format="01" from="book"/>
186 <xsl:if test="not($recursive)">
187 <xsl:value-of select="$html.ext"/>
191 <xsl:when test="self::appendix">
193 <!-- in a set, make sure we inherit the right book info... -->
194 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
195 <xsl:with-param name="recursive" select="true()"/>
196 </xsl:apply-templates>
199 <xsl:text>ap</xsl:text>
200 <xsl:number level="any" format="a" from="book"/>
201 <xsl:if test="not($recursive)">
202 <xsl:value-of select="$html.ext"/>
206 <xsl:when test="self::part">
208 <xsl:when test="/set">
209 <!-- in a set, make sure we inherit the right book info... -->
210 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
211 <xsl:with-param name="recursive" select="true()"/>
212 </xsl:apply-templates>
218 <xsl:text>pt</xsl:text>
219 <xsl:number level="any" format="01" from="book"/>
220 <xsl:if test="not($recursive)">
221 <xsl:value-of select="$html.ext"/>
225 <xsl:when test="self::reference">
227 <xsl:when test="/set">
228 <!-- in a set, make sure we inherit the right book info... -->
229 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
230 <xsl:with-param name="recursive" select="true()"/>
231 </xsl:apply-templates>
237 <xsl:text>rn</xsl:text>
238 <xsl:number level="any" format="01" from="book"/>
239 <xsl:if test="not($recursive)">
240 <xsl:value-of select="$html.ext"/>
244 <xsl:when test="self::refentry">
246 <xsl:when test="parent::reference">
247 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
248 <xsl:with-param name="recursive" select="true()"/>
249 </xsl:apply-templates>
253 <!-- in a set, make sure we inherit the right book info... -->
254 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
255 <xsl:with-param name="recursive" select="true()"/>
256 </xsl:apply-templates>
261 <xsl:text>re</xsl:text>
262 <xsl:number level="any" format="01" from="book"/>
263 <xsl:if test="not($recursive)">
264 <xsl:value-of select="$html.ext"/>
268 <xsl:when test="self::colophon">
270 <xsl:when test="/set">
271 <!-- in a set, make sure we inherit the right book info... -->
272 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
273 <xsl:with-param name="recursive" select="true()"/>
274 </xsl:apply-templates>
280 <xsl:text>co</xsl:text>
281 <xsl:number level="any" format="01" from="book"/>
282 <xsl:if test="not($recursive)">
283 <xsl:value-of select="$html.ext"/>
287 <xsl:when test="self::sect1 or self::sect2 or self::sect3 or self::sect4 or self::sect5 or self::section">
288 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
289 <xsl:with-param name="recursive" select="true()"/>
290 </xsl:apply-templates>
291 <xsl:text>s</xsl:text>
292 <xsl:number format="01"/>
293 <xsl:if test="not($recursive)">
294 <xsl:value-of select="$html.ext"/>
298 <xsl:when test="self::bibliography">
300 <xsl:when test="/set">
301 <!-- in a set, make sure we inherit the right book info... -->
302 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
303 <xsl:with-param name="recursive" select="true()"/>
304 </xsl:apply-templates>
310 <xsl:text>bi</xsl:text>
311 <xsl:number level="any" format="01" from="book"/>
312 <xsl:if test="not($recursive)">
313 <xsl:value-of select="$html.ext"/>
317 <xsl:when test="self::glossary">
319 <xsl:when test="/set">
320 <!-- in a set, make sure we inherit the right book info... -->
321 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
322 <xsl:with-param name="recursive" select="true()"/>
323 </xsl:apply-templates>
329 <xsl:text>go</xsl:text>
330 <xsl:number level="any" format="01" from="book"/>
331 <xsl:if test="not($recursive)">
332 <xsl:value-of select="$html.ext"/>
336 <xsl:when test="self::index">
338 <xsl:when test="/set">
339 <!-- in a set, make sure we inherit the right book info... -->
340 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
341 <xsl:with-param name="recursive" select="true()"/>
342 </xsl:apply-templates>
348 <xsl:text>ix</xsl:text>
349 <xsl:number level="any" format="01" from="book"/>
350 <xsl:if test="not($recursive)">
351 <xsl:value-of select="$html.ext"/>
355 <xsl:when test="self::setindex">
356 <xsl:text>si</xsl:text>
357 <xsl:number level="any" format="01" from="set"/>
358 <xsl:if test="not($recursive)">
359 <xsl:value-of select="$html.ext"/>
364 <xsl:text>chunk-filename-error-</xsl:text>
365 <xsl:value-of select="name(.)"/>
366 <xsl:number level="any" format="01" from="set"/>
367 <xsl:if test="not($recursive)">
368 <xsl:value-of select="$html.ext"/>
374 <!-- ==================================================================== -->
378 <xsl:template match="processing-instruction('dbhtml')">
382 <!-- ==================================================================== -->
385 <xsl:template match="*" mode="find.chunks">
386 <xsl:variable name="chunk">
387 <xsl:call-template name="chunk"/>
391 <xsl:when test="$chunk != 0">
392 <cf:div id="{generate-id()}">
393 <xsl:apply-templates select="." mode="class.attribute"/>
394 <xsl:apply-templates select="*" mode="find.chunks"/>
398 <xsl:apply-templates select="*" mode="find.chunks"/>
403 <xsl:template match="/">
404 <!-- * Get a title for current doc so that we let the user -->
405 <!-- * know what document we are processing at this point. -->
406 <xsl:variable name="doc.title">
407 <xsl:call-template name="get.doc.title"/>
410 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
411 toss the namespace and continue. Use the docbook5 namespaced
412 stylesheets for DocBook5 if you don't want to use this feature.-->
413 <xsl:when test="$exsl.node.set.available != 0 and (*/self::ng:* or */self::db:*)">
414 <xsl:call-template name="log.message">
415 <xsl:with-param name="level">Note</xsl:with-param>
416 <xsl:with-param name="source" select="$doc.title"/>
417 <xsl:with-param name="context-desc">
418 <xsl:text>namesp. cut</xsl:text>
420 <xsl:with-param name="message">
421 <xsl:text>stripped namespace before processing</xsl:text>
424 <xsl:variable name="nons">
425 <xsl:apply-templates mode="stripNS"/>
427 <xsl:call-template name="log.message">
428 <xsl:with-param name="level">Note</xsl:with-param>
429 <xsl:with-param name="source" select="$doc.title"/>
430 <xsl:with-param name="context-desc">
431 <xsl:text>namesp. cut</xsl:text>
433 <xsl:with-param name="message">
434 <xsl:text>processing stripped document</xsl:text>
437 <xsl:apply-templates select="exsl:node-set($nons)"/>
439 <!-- Can't process unless namespace removed -->
440 <xsl:when test="*/self::ng:* or */self::db:*">
441 <xsl:message terminate="yes">
442 <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
443 <xsl:text> cannot proceed.</xsl:text>
448 <xsl:when test="$rootid != ''">
450 <xsl:when test="count(key('id',$rootid)) = 0">
451 <xsl:message terminate="yes">
452 <xsl:text>ID '</xsl:text>
453 <xsl:value-of select="$rootid"/>
454 <xsl:text>' not found in document.</xsl:text>
458 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
459 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
461 <xsl:if test="$collect.xref.targets != 'only'">
462 <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/>
463 <xsl:if test="$tex.math.in.alt != ''">
464 <xsl:apply-templates select="key('id',$rootid)" mode="collect.tex.math"/>
466 <xsl:if test="$generate.manifest != 0">
467 <xsl:call-template name="generate.manifest">
468 <xsl:with-param name="node" select="key('id',$rootid)"/>
476 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
477 <xsl:apply-templates select="/" mode="collect.targets"/>
479 <xsl:if test="$collect.xref.targets != 'only'">
480 <xsl:apply-templates select="/" mode="process.root"/>
481 <xsl:if test="$tex.math.in.alt != ''">
482 <xsl:apply-templates select="/" mode="collect.tex.math"/>
484 <xsl:if test="$generate.manifest != 0">
485 <xsl:call-template name="generate.manifest">
486 <xsl:with-param name="node" select="/"/>
496 <xsl:template match="*" mode="process.root">
497 <xsl:apply-templates select="."/>
498 <xsl:call-template name="generate.css"/>
501 <!-- ====================================================================== -->
503 <xsl:template match="set|book|part|preface|chapter|appendix |article |reference|refentry |book/glossary|article/glossary|part/glossary |book/bibliography|article/bibliography|part/bibliography |colophon">
505 <xsl:when test="$onechunk != 0 and parent::*">
509 <xsl:call-template name="process-chunk-element"/>
514 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
515 <xsl:variable name="ischunk">
516 <xsl:call-template name="chunk"/>
520 <xsl:when test="not(parent::*)">
521 <xsl:call-template name="process-chunk-element"/>
523 <xsl:when test="$ischunk = 0">
527 <xsl:call-template name="process-chunk-element"/>
532 <xsl:template match="setindex |book/index |article/index |part/index">
533 <!-- some implementations use completely empty index tags to indicate -->
534 <!-- where an automatically generated index should be inserted. so -->
535 <!-- if the index is completely empty, skip it. -->
536 <xsl:if test="count(*)>0 or $generate.index != '0'">
537 <xsl:call-template name="process-chunk-element"/>
541 <!-- Resolve xml:base attributes -->
542 <xsl:template match="@fileref">
543 <!-- need a check for absolute urls -->
545 <xsl:when test="contains(., ':')">
546 <!-- it has a uri scheme so it is an absolute uri -->
547 <xsl:value-of select="."/>
549 <xsl:when test="$keep.relative.image.uris != 0">
550 <!-- leave it alone -->
551 <xsl:value-of select="."/>
554 <!-- its a relative uri -->
555 <xsl:call-template name="relative-uri">
556 <xsl:with-param name="destdir">
557 <xsl:call-template name="dbhtml-dir">
558 <xsl:with-param name="context" select=".."/>
566 <!-- ==================================================================== -->
567 <xsl:template match="set|book|part|preface|chapter|appendix |article |reference|refentry |sect1|sect2|sect3|sect4|sect5 |section |book/glossary|article/glossary|part/glossary |book/bibliography|article/bibliography|part/bibliography |colophon" mode="enumerate-files">
568 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
569 <xsl:if test="$ischunk='1'">
570 <xsl:call-template name="make-relative-filename">
571 <xsl:with-param name="base.dir">
572 <xsl:if test="$manifest.in.base.dir = 0">
573 <xsl:value-of select="$base.dir"/>
576 <xsl:with-param name="base.name">
577 <xsl:apply-templates mode="chunk-filename" select="."/>
583 <xsl:apply-templates select="*" mode="enumerate-files"/>
586 <xsl:template match="book/index|article/index|part/index" mode="enumerate-files">
587 <xsl:if test="$htmlhelp.output != 1">
588 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
589 <xsl:if test="$ischunk='1'">
590 <xsl:call-template name="make-relative-filename">
591 <xsl:with-param name="base.dir">
592 <xsl:if test="$manifest.in.base.dir = 0">
593 <xsl:value-of select="$base.dir"/>
596 <xsl:with-param name="base.name">
597 <xsl:apply-templates mode="chunk-filename" select="."/>
603 <xsl:apply-templates select="*" mode="enumerate-files"/>
607 <xsl:template match="legalnotice" mode="enumerate-files">
608 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
609 <xsl:if test="$generate.legalnotice.link != 0">
610 <xsl:call-template name="make-relative-filename">
611 <xsl:with-param name="base.dir">
612 <xsl:if test="$manifest.in.base.dir = 0">
613 <xsl:value-of select="$base.dir"/>
616 <xsl:with-param name="base.name">
617 <xsl:apply-templates mode="chunk-filename" select="."/>
625 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
626 <xsl:variable name="longdesc.uri">
627 <xsl:call-template name="longdesc.uri">
628 <xsl:with-param name="mediaobject" select="."/>
631 <xsl:variable name="mediaobject" select="."/>
633 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
634 <xsl:call-template name="longdesc.uri">
635 <xsl:with-param name="mediaobject" select="$mediaobject"/>
642 <xsl:template match="text()" mode="enumerate-files">