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="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl cf" version="1.0">
6 <!-- ********************************************************************
7 $Id: chunk-code.xsl 9936 2014-08-29 21:34:58Z 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="$chunked.filename.prefix"/>
55 <xsl:value-of select="$fn"/>
56 <!-- You can't add the html.ext here because dbhtml filename= may already -->
57 <!-- have added it. It really does have to be handled in the recursive template -->
60 <xsl:template match="*" mode="recursive-chunk-filename">
61 <xsl:param name="recursive" select="false()"/>
63 <!-- returns the filename of a chunk -->
64 <xsl:variable name="ischunk">
65 <xsl:call-template name="chunk"/>
68 <xsl:variable name="dbhtml-filename">
69 <xsl:call-template name="pi.dbhtml_filename"/>
72 <xsl:variable name="filename">
74 <xsl:when test="$dbhtml-filename != ''">
75 <xsl:value-of select="$dbhtml-filename"/>
77 <!-- if this is the root element, use the root.filename -->
78 <xsl:when test="not(parent::*) and $root.filename != ''">
79 <xsl:value-of select="$root.filename"/>
80 <xsl:value-of select="$html.ext"/>
83 <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
85 <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
86 <!-- * if this legalnotice has an ID, then go ahead and use -->
87 <!-- * just the value of that ID as the basename for the file -->
88 <!-- * (that is, without prepending an "ln-" too it) -->
89 <xsl:value-of select="(@id|@xml:id)[1]"/>
90 <xsl:value-of select="$html.ext"/>
93 <!-- * otherwise, if this legalnotice does not have an ID, -->
94 <!-- * then we generate an ID... -->
95 <xsl:variable name="id">
96 <xsl:call-template name="object.id"/>
98 <!-- * ...and then we take that generated ID, prepend an -->
99 <!-- * "ln-" to it, and use that as the basename for the file -->
100 <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
104 <!-- if there's no dbhtml filename, and if we're to use IDs as -->
105 <!-- filenames, then use the ID to generate the filename. -->
106 <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
107 <xsl:value-of select="(@id|@xml:id)[1]"/>
108 <xsl:value-of select="$html.ext"/>
115 <xsl:when test="$ischunk='0'">
116 <!-- if called on something that isn't a chunk, walk up... -->
118 <xsl:when test="count(parent::*)>0">
119 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
120 <xsl:with-param name="recursive" select="$recursive"/>
121 </xsl:apply-templates>
123 <!-- unless there is no up, in which case return "" -->
128 <xsl:when test="not($recursive) and $filename != ''">
129 <!-- if this chunk has an explicit name, use it -->
130 <xsl:value-of select="$filename"/>
133 <!-- treat nested set separate from root -->
134 <xsl:when test="self::set and ancestor::set">
135 <xsl:text>se</xsl:text>
136 <xsl:number level="any" format="01"/>
137 <xsl:if test="not($recursive)">
138 <xsl:value-of select="$html.ext"/>
142 <xsl:when test="self::set">
143 <xsl:value-of select="$root.filename"/>
144 <xsl:if test="not($recursive)">
145 <xsl:value-of select="$html.ext"/>
149 <xsl:when test="self::book">
150 <xsl:text>bk</xsl:text>
151 <xsl:number level="any" format="01"/>
152 <xsl:if test="not($recursive)">
153 <xsl:value-of select="$html.ext"/>
157 <xsl:when test="self::article">
159 <!-- in a set, make sure we inherit the right book info... -->
160 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
161 <xsl:with-param name="recursive" select="true()"/>
162 </xsl:apply-templates>
165 <xsl:text>ar</xsl:text>
166 <xsl:number level="any" format="01" from="book"/>
167 <xsl:if test="not($recursive)">
168 <xsl:value-of select="$html.ext"/>
172 <xsl:when test="self::preface">
174 <!-- in a set, make sure we inherit the right book info... -->
175 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
176 <xsl:with-param name="recursive" select="true()"/>
177 </xsl:apply-templates>
180 <xsl:text>pr</xsl:text>
181 <xsl:number level="any" format="01" from="book"/>
182 <xsl:if test="not($recursive)">
183 <xsl:value-of select="$html.ext"/>
187 <xsl:when test="self::chapter">
189 <!-- in a set, make sure we inherit the right book info... -->
190 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
191 <xsl:with-param name="recursive" select="true()"/>
192 </xsl:apply-templates>
195 <xsl:text>ch</xsl:text>
196 <xsl:number level="any" format="01" from="book"/>
197 <xsl:if test="not($recursive)">
198 <xsl:value-of select="$html.ext"/>
202 <xsl:when test="self::appendix">
204 <!-- in a set, make sure we inherit the right book info... -->
205 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
206 <xsl:with-param name="recursive" select="true()"/>
207 </xsl:apply-templates>
210 <xsl:text>ap</xsl:text>
211 <xsl:number level="any" format="a" from="book"/>
212 <xsl:if test="not($recursive)">
213 <xsl:value-of select="$html.ext"/>
217 <xsl:when test="self::part">
219 <xsl:when test="/set">
220 <!-- in a set, make sure we inherit the right book info... -->
221 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
222 <xsl:with-param name="recursive" select="true()"/>
223 </xsl:apply-templates>
229 <xsl:text>pt</xsl:text>
230 <xsl:number level="any" format="01" from="book"/>
231 <xsl:if test="not($recursive)">
232 <xsl:value-of select="$html.ext"/>
236 <xsl:when test="self::reference">
238 <xsl:when test="/set">
239 <!-- in a set, make sure we inherit the right book info... -->
240 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
241 <xsl:with-param name="recursive" select="true()"/>
242 </xsl:apply-templates>
248 <xsl:text>rn</xsl:text>
249 <xsl:number level="any" format="01" from="book"/>
250 <xsl:if test="not($recursive)">
251 <xsl:value-of select="$html.ext"/>
255 <xsl:when test="self::refentry">
257 <xsl:when test="parent::reference">
258 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
259 <xsl:with-param name="recursive" select="true()"/>
260 </xsl:apply-templates>
264 <!-- in a set, make sure we inherit the right book info... -->
265 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
266 <xsl:with-param name="recursive" select="true()"/>
267 </xsl:apply-templates>
272 <xsl:text>re</xsl:text>
273 <xsl:number level="any" format="01" from="book"/>
274 <xsl:if test="not($recursive)">
275 <xsl:value-of select="$html.ext"/>
279 <xsl:when test="self::colophon">
281 <xsl:when test="/set">
282 <!-- in a set, make sure we inherit the right book info... -->
283 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
284 <xsl:with-param name="recursive" select="true()"/>
285 </xsl:apply-templates>
291 <xsl:text>co</xsl:text>
292 <xsl:number level="any" format="01" from="book"/>
293 <xsl:if test="not($recursive)">
294 <xsl:value-of select="$html.ext"/>
298 <xsl:when test="self::sect1 or self::sect2 or self::sect3 or self::sect4 or self::sect5 or self::section">
299 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
300 <xsl:with-param name="recursive" select="true()"/>
301 </xsl:apply-templates>
302 <xsl:text>s</xsl:text>
303 <xsl:number format="01"/>
304 <xsl:if test="not($recursive)">
305 <xsl:value-of select="$html.ext"/>
309 <xsl:when test="self::bibliography">
311 <xsl:when test="/set">
312 <!-- in a set, make sure we inherit the right book info... -->
313 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
314 <xsl:with-param name="recursive" select="true()"/>
315 </xsl:apply-templates>
321 <xsl:text>bi</xsl:text>
322 <xsl:number level="any" format="01" from="book"/>
323 <xsl:if test="not($recursive)">
324 <xsl:value-of select="$html.ext"/>
328 <xsl:when test="self::glossary">
330 <xsl:when test="/set">
331 <!-- in a set, make sure we inherit the right book info... -->
332 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
333 <xsl:with-param name="recursive" select="true()"/>
334 </xsl:apply-templates>
340 <xsl:text>go</xsl:text>
341 <xsl:number level="any" format="01" from="book"/>
342 <xsl:if test="not($recursive)">
343 <xsl:value-of select="$html.ext"/>
347 <xsl:when test="self::index">
349 <xsl:when test="/set">
350 <!-- in a set, make sure we inherit the right book info... -->
351 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
352 <xsl:with-param name="recursive" select="true()"/>
353 </xsl:apply-templates>
359 <xsl:text>ix</xsl:text>
360 <xsl:number level="any" format="01" from="book"/>
361 <xsl:if test="not($recursive)">
362 <xsl:value-of select="$html.ext"/>
366 <xsl:when test="self::setindex">
367 <xsl:text>si</xsl:text>
368 <xsl:number level="any" format="01" from="set"/>
369 <xsl:if test="not($recursive)">
370 <xsl:value-of select="$html.ext"/>
374 <xsl:when test="self::topic">
376 <xsl:when test="/set">
377 <!-- in a set, make sure we inherit the right book info... -->
378 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
379 <xsl:with-param name="recursive" select="true()"/>
380 </xsl:apply-templates>
386 <xsl:text>to</xsl:text>
387 <xsl:number level="any" format="01" from="book"/>
388 <xsl:if test="not($recursive)">
389 <xsl:value-of select="$html.ext"/>
394 <xsl:text>chunk-filename-error-</xsl:text>
395 <xsl:value-of select="name(.)"/>
396 <xsl:number level="any" format="01" from="set"/>
397 <xsl:if test="not($recursive)">
398 <xsl:value-of select="$html.ext"/>
404 <!-- ==================================================================== -->
408 <xsl:template match="processing-instruction('dbhtml')">
412 <!-- ==================================================================== -->
415 <xsl:template match="*" mode="find.chunks">
416 <xsl:variable name="chunk">
417 <xsl:call-template name="chunk"/>
421 <xsl:when test="$chunk != 0">
422 <cf:div id="{generate-id()}">
423 <xsl:apply-templates select="." mode="class.attribute"/>
424 <xsl:apply-templates select="*" mode="find.chunks"/>
428 <xsl:apply-templates select="*" mode="find.chunks"/>
433 <!-- Leave legalnotice chunk out of the list for Next and Prev -->
434 <xsl:template match="legalnotice" mode="find.chunks"/>
436 <xsl:template match="/">
437 <!-- * Get a title for current doc so that we let the user -->
438 <!-- * know what document we are processing at this point. -->
439 <xsl:variable name="doc.title">
440 <xsl:call-template name="get.doc.title"/>
443 <xsl:when test="$exsl.node.set.available != 0 and namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
444 <xsl:call-template name="log.message">
445 <xsl:with-param name="level">Note</xsl:with-param>
446 <xsl:with-param name="source" select="$doc.title"/>
447 <xsl:with-param name="context-desc">
448 <xsl:text>namesp. cut</xsl:text>
450 <xsl:with-param name="message">
451 <xsl:text>stripped namespace before processing</xsl:text>
455 <xsl:apply-templates select="exsl:node-set($no.namespace)"/>
457 <!-- Can't process unless namespace fixed with exsl node-set()-->
458 <xsl:when test="namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
459 <xsl:message terminate="yes">
460 <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
461 <xsl:text> cannot proceed.</xsl:text>
466 <xsl:when test="$rootid != ''">
468 <xsl:when test="count(key('id',$rootid)) = 0">
469 <xsl:message terminate="yes">
470 <xsl:text>ID '</xsl:text>
471 <xsl:value-of select="$rootid"/>
472 <xsl:text>' not found in document.</xsl:text>
476 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
477 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
479 <xsl:if test="$collect.xref.targets != 'only'">
480 <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/>
481 <xsl:if test="$tex.math.in.alt != ''">
482 <xsl:apply-templates select="key('id',$rootid)" 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="key('id',$rootid)"/>
494 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
495 <xsl:apply-templates select="/" mode="collect.targets"/>
497 <xsl:if test="$collect.xref.targets != 'only'">
498 <xsl:apply-templates select="/" mode="process.root"/>
499 <xsl:if test="$tex.math.in.alt != ''">
500 <xsl:apply-templates select="/" mode="collect.tex.math"/>
502 <xsl:if test="$generate.manifest != 0">
503 <xsl:call-template name="generate.manifest">
504 <xsl:with-param name="node" select="/"/>
514 <xsl:template match="*" mode="process.root">
515 <xsl:apply-templates select="."/>
516 <xsl:call-template name="generate.css.files"/>
519 <!-- ====================================================================== -->
521 <xsl:template match="set|book|part|preface|chapter|appendix |article |topic |reference|refentry |book/glossary|article/glossary|part/glossary |book/bibliography|article/bibliography|part/bibliography |colophon">
523 <xsl:when test="$onechunk != 0 and parent::*">
527 <xsl:call-template name="process-chunk-element"/>
532 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
533 <xsl:variable name="ischunk">
534 <xsl:call-template name="chunk"/>
538 <xsl:when test="not(parent::*)">
539 <xsl:call-template name="process-chunk-element"/>
541 <xsl:when test="$ischunk = 0">
545 <xsl:call-template name="process-chunk-element"/>
550 <xsl:template match="setindex |book/index |article/index |part/index">
551 <!-- some implementations use completely empty index tags to indicate -->
552 <!-- where an automatically generated index should be inserted. so -->
553 <!-- if the index is completely empty, skip it. -->
554 <xsl:if test="count(*)>0 or $generate.index != '0'">
555 <xsl:call-template name="process-chunk-element"/>
559 <!-- Resolve xml:base attributes -->
560 <xsl:template match="@fileref">
561 <!-- need a check for absolute urls -->
563 <xsl:when test="contains(., ':')">
564 <!-- it has a uri scheme so it is an absolute uri -->
565 <xsl:value-of select="."/>
567 <xsl:when test="$keep.relative.image.uris != 0">
568 <!-- leave it alone -->
569 <xsl:value-of select="."/>
572 <!-- its a relative uri -->
573 <xsl:call-template name="relative-uri">
574 <xsl:with-param name="destdir">
575 <xsl:call-template name="dbhtml-dir">
576 <xsl:with-param name="context" select=".."/>
584 <!-- ==================================================================== -->
585 <xsl:template match="set|book|part|preface|chapter|appendix |article |topic |reference|refentry |sect1|sect2|sect3|sect4|sect5 |section |book/glossary|article/glossary|part/glossary |book/bibliography|article/bibliography|part/bibliography |colophon" mode="enumerate-files">
586 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
587 <xsl:if test="$ischunk='1'">
588 <xsl:call-template name="make-relative-filename">
589 <xsl:with-param name="base.dir">
590 <xsl:if test="$manifest.in.base.dir = 0">
591 <xsl:value-of select="$chunk.base.dir"/>
594 <xsl:with-param name="base.name">
595 <xsl:apply-templates mode="chunk-filename" select="."/>
601 <xsl:apply-templates select="*" mode="enumerate-files"/>
604 <xsl:template match="book/index|article/index|part/index" mode="enumerate-files">
605 <xsl:if test="$htmlhelp.output != 1">
606 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
607 <xsl:if test="$ischunk='1'">
608 <xsl:call-template name="make-relative-filename">
609 <xsl:with-param name="base.dir">
610 <xsl:if test="$manifest.in.base.dir = 0">
611 <xsl:value-of select="$chunk.base.dir"/>
614 <xsl:with-param name="base.name">
615 <xsl:apply-templates mode="chunk-filename" select="."/>
621 <xsl:apply-templates select="*" mode="enumerate-files"/>
625 <xsl:template match="legalnotice" mode="enumerate-files">
626 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
627 <xsl:if test="$generate.legalnotice.link != 0">
628 <xsl:call-template name="make-relative-filename">
629 <xsl:with-param name="base.dir">
630 <xsl:if test="$manifest.in.base.dir = 0">
631 <xsl:value-of select="$chunk.base.dir"/>
634 <xsl:with-param name="base.name">
635 <xsl:apply-templates mode="chunk-filename" select="."/>
643 <xsl:template match="revhistory" mode="enumerate-files">
644 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
645 <xsl:if test="$generate.revhistory.link != 0">
646 <xsl:call-template name="make-relative-filename">
647 <xsl:with-param name="base.dir">
648 <xsl:if test="$manifest.in.base.dir = 0">
649 <xsl:value-of select="$chunk.base.dir"/>
652 <xsl:with-param name="base.name">
653 <xsl:call-template name="ln.or.rh.filename">
654 <xsl:with-param name="is.ln" select="false()"/>
663 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
664 <xsl:variable name="longdesc.uri">
665 <xsl:call-template name="longdesc.uri">
666 <xsl:with-param name="mediaobject" select="."/>
669 <xsl:variable name="mediaobject" select="."/>
671 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
672 <xsl:call-template name="longdesc.uri">
673 <xsl:with-param name="mediaobject" select="$mediaobject"/>
680 <xsl:template match="text()" mode="enumerate-files">