1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <!--This file was created automatically by xsl2profile-->
5 <!--from the DocBook XSL stylesheets.-->
6 <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:exslt="http://exslt.org/common" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="exsl cf exslt" version="1.0">
8 <!-- ********************************************************************
9 $Id: chunk-code.xsl 9936 2014-08-29 21:34:58Z bobstayton $
10 ********************************************************************
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
16 ******************************************************************** -->
18 <!-- ==================================================================== -->
21 <xsl:template match="*" mode="chunk-filename">
22 <!-- returns the filename of a chunk -->
23 <xsl:variable name="ischunk">
24 <xsl:call-template name="chunk"/>
27 <xsl:variable name="fn">
28 <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
33 <xsl:value-of select="$ischunk"/>
34 <xsl:text> (</xsl:text>
35 <xsl:value-of select="local-name(.)"/>
36 <xsl:text>) </xsl:text>
37 <xsl:value-of select="$fn"/>
38 <xsl:text>, </xsl:text>
39 <xsl:call-template name="dbhtml-dir"/>
43 <!-- 2003-11-25 by ndw:
44 The following test used to read test="$ischunk != 0 and $fn != ''"
45 I've removed the ischunk part of the test so that href.to.uri and
46 href.from.uri will be fully qualified even if the source or target
47 isn't a chunk. I *think* that if $fn != '' then it's appropriate
48 to put the directory on the front, even if the element isn't a
49 chunk. I could be wrong. -->
51 <xsl:if test="$fn != ''">
52 <xsl:call-template name="dbhtml-dir"/>
55 <xsl:value-of select="$chunked.filename.prefix"/>
57 <xsl:value-of select="$fn"/>
58 <!-- You can't add the html.ext here because dbhtml filename= may already -->
59 <!-- have added it. It really does have to be handled in the recursive template -->
62 <xsl:template match="*" mode="recursive-chunk-filename">
63 <xsl:param name="recursive" select="false()"/>
65 <!-- returns the filename of a chunk -->
66 <xsl:variable name="ischunk">
67 <xsl:call-template name="chunk"/>
70 <xsl:variable name="dbhtml-filename">
71 <xsl:call-template name="pi.dbhtml_filename"/>
74 <xsl:variable name="filename">
76 <xsl:when test="$dbhtml-filename != ''">
77 <xsl:value-of select="$dbhtml-filename"/>
79 <!-- if this is the root element, use the root.filename -->
80 <xsl:when test="not(parent::*) and $root.filename != ''">
81 <xsl:value-of select="$root.filename"/>
82 <xsl:value-of select="$html.ext"/>
85 <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
87 <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
88 <!-- * if this legalnotice has an ID, then go ahead and use -->
89 <!-- * just the value of that ID as the basename for the file -->
90 <!-- * (that is, without prepending an "ln-" too it) -->
91 <xsl:value-of select="(@id|@xml:id)[1]"/>
92 <xsl:value-of select="$html.ext"/>
95 <!-- * otherwise, if this legalnotice does not have an ID, -->
96 <!-- * then we generate an ID... -->
97 <xsl:variable name="id">
98 <xsl:call-template name="object.id"/>
100 <!-- * ...and then we take that generated ID, prepend an -->
101 <!-- * "ln-" to it, and use that as the basename for the file -->
102 <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
106 <!-- if there's no dbhtml filename, and if we're to use IDs as -->
107 <!-- filenames, then use the ID to generate the filename. -->
108 <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
109 <xsl:value-of select="(@id|@xml:id)[1]"/>
110 <xsl:value-of select="$html.ext"/>
117 <xsl:when test="$ischunk='0'">
118 <!-- if called on something that isn't a chunk, walk up... -->
120 <xsl:when test="count(parent::*)>0">
121 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
122 <xsl:with-param name="recursive" select="$recursive"/>
123 </xsl:apply-templates>
125 <!-- unless there is no up, in which case return "" -->
130 <xsl:when test="not($recursive) and $filename != ''">
131 <!-- if this chunk has an explicit name, use it -->
132 <xsl:value-of select="$filename"/>
135 <!-- treat nested set separate from root -->
136 <xsl:when test="self::set and ancestor::set">
137 <xsl:text>se</xsl:text>
138 <xsl:number level="any" format="01"/>
139 <xsl:if test="not($recursive)">
140 <xsl:value-of select="$html.ext"/>
144 <xsl:when test="self::set">
145 <xsl:value-of select="$root.filename"/>
146 <xsl:if test="not($recursive)">
147 <xsl:value-of select="$html.ext"/>
151 <xsl:when test="self::book">
152 <xsl:text>bk</xsl:text>
153 <xsl:number level="any" format="01"/>
154 <xsl:if test="not($recursive)">
155 <xsl:value-of select="$html.ext"/>
159 <xsl:when test="self::article">
161 <!-- in a set, make sure we inherit the right book info... -->
162 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
163 <xsl:with-param name="recursive" select="true()"/>
164 </xsl:apply-templates>
167 <xsl:text>ar</xsl:text>
168 <xsl:number level="any" format="01" from="book"/>
169 <xsl:if test="not($recursive)">
170 <xsl:value-of select="$html.ext"/>
174 <xsl:when test="self::preface">
176 <!-- in a set, make sure we inherit the right book info... -->
177 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
178 <xsl:with-param name="recursive" select="true()"/>
179 </xsl:apply-templates>
182 <xsl:text>pr</xsl:text>
183 <xsl:number level="any" format="01" from="book"/>
184 <xsl:if test="not($recursive)">
185 <xsl:value-of select="$html.ext"/>
189 <xsl:when test="self::chapter">
191 <!-- in a set, make sure we inherit the right book info... -->
192 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
193 <xsl:with-param name="recursive" select="true()"/>
194 </xsl:apply-templates>
197 <xsl:text>ch</xsl:text>
198 <xsl:number level="any" format="01" from="book"/>
199 <xsl:if test="not($recursive)">
200 <xsl:value-of select="$html.ext"/>
204 <xsl:when test="self::appendix">
206 <!-- in a set, make sure we inherit the right book info... -->
207 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
208 <xsl:with-param name="recursive" select="true()"/>
209 </xsl:apply-templates>
212 <xsl:text>ap</xsl:text>
213 <xsl:number level="any" format="a" from="book"/>
214 <xsl:if test="not($recursive)">
215 <xsl:value-of select="$html.ext"/>
219 <xsl:when test="self::part">
221 <xsl:when test="/set">
222 <!-- in a set, make sure we inherit the right book info... -->
223 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
224 <xsl:with-param name="recursive" select="true()"/>
225 </xsl:apply-templates>
231 <xsl:text>pt</xsl:text>
232 <xsl:number level="any" format="01" from="book"/>
233 <xsl:if test="not($recursive)">
234 <xsl:value-of select="$html.ext"/>
238 <xsl:when test="self::reference">
240 <xsl:when test="/set">
241 <!-- in a set, make sure we inherit the right book info... -->
242 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
243 <xsl:with-param name="recursive" select="true()"/>
244 </xsl:apply-templates>
250 <xsl:text>rn</xsl:text>
251 <xsl:number level="any" format="01" from="book"/>
252 <xsl:if test="not($recursive)">
253 <xsl:value-of select="$html.ext"/>
257 <xsl:when test="self::refentry">
259 <xsl:when test="parent::reference">
260 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
261 <xsl:with-param name="recursive" select="true()"/>
262 </xsl:apply-templates>
266 <!-- in a set, make sure we inherit the right book info... -->
267 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
268 <xsl:with-param name="recursive" select="true()"/>
269 </xsl:apply-templates>
274 <xsl:text>re</xsl:text>
275 <xsl:number level="any" format="01" from="book"/>
276 <xsl:if test="not($recursive)">
277 <xsl:value-of select="$html.ext"/>
281 <xsl:when test="self::colophon">
283 <xsl:when test="/set">
284 <!-- in a set, make sure we inherit the right book info... -->
285 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
286 <xsl:with-param name="recursive" select="true()"/>
287 </xsl:apply-templates>
293 <xsl:text>co</xsl:text>
294 <xsl:number level="any" format="01" from="book"/>
295 <xsl:if test="not($recursive)">
296 <xsl:value-of select="$html.ext"/>
300 <xsl:when test="self::sect1 or self::sect2 or self::sect3 or self::sect4 or self::sect5 or self::section">
301 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
302 <xsl:with-param name="recursive" select="true()"/>
303 </xsl:apply-templates>
304 <xsl:text>s</xsl:text>
305 <xsl:number format="01"/>
306 <xsl:if test="not($recursive)">
307 <xsl:value-of select="$html.ext"/>
311 <xsl:when test="self::bibliography">
313 <xsl:when test="/set">
314 <!-- in a set, make sure we inherit the right book info... -->
315 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
316 <xsl:with-param name="recursive" select="true()"/>
317 </xsl:apply-templates>
323 <xsl:text>bi</xsl:text>
324 <xsl:number level="any" format="01" from="book"/>
325 <xsl:if test="not($recursive)">
326 <xsl:value-of select="$html.ext"/>
330 <xsl:when test="self::glossary">
332 <xsl:when test="/set">
333 <!-- in a set, make sure we inherit the right book info... -->
334 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
335 <xsl:with-param name="recursive" select="true()"/>
336 </xsl:apply-templates>
342 <xsl:text>go</xsl:text>
343 <xsl:number level="any" format="01" from="book"/>
344 <xsl:if test="not($recursive)">
345 <xsl:value-of select="$html.ext"/>
349 <xsl:when test="self::index">
351 <xsl:when test="/set">
352 <!-- in a set, make sure we inherit the right book info... -->
353 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
354 <xsl:with-param name="recursive" select="true()"/>
355 </xsl:apply-templates>
361 <xsl:text>ix</xsl:text>
362 <xsl:number level="any" format="01" from="book"/>
363 <xsl:if test="not($recursive)">
364 <xsl:value-of select="$html.ext"/>
368 <xsl:when test="self::setindex">
369 <xsl:text>si</xsl:text>
370 <xsl:number level="any" format="01" from="set"/>
371 <xsl:if test="not($recursive)">
372 <xsl:value-of select="$html.ext"/>
376 <xsl:when test="self::topic">
378 <xsl:when test="/set">
379 <!-- in a set, make sure we inherit the right book info... -->
380 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
381 <xsl:with-param name="recursive" select="true()"/>
382 </xsl:apply-templates>
388 <xsl:text>to</xsl:text>
389 <xsl:number level="any" format="01" from="book"/>
390 <xsl:if test="not($recursive)">
391 <xsl:value-of select="$html.ext"/>
396 <xsl:text>chunk-filename-error-</xsl:text>
397 <xsl:value-of select="name(.)"/>
398 <xsl:number level="any" format="01" from="set"/>
399 <xsl:if test="not($recursive)">
400 <xsl:value-of select="$html.ext"/>
406 <!-- ==================================================================== -->
410 <xsl:template match="processing-instruction('dbhtml')">
414 <!-- ==================================================================== -->
417 <xsl:template match="*" mode="find.chunks">
418 <xsl:variable name="chunk">
419 <xsl:call-template name="chunk"/>
423 <xsl:when test="$chunk != 0">
424 <cf:div id="{generate-id()}">
425 <xsl:apply-templates select="." mode="class.attribute"/>
426 <xsl:apply-templates select="*" mode="find.chunks"/>
430 <xsl:apply-templates select="*" mode="find.chunks"/>
435 <!-- Leave legalnotice chunk out of the list for Next and Prev -->
436 <xsl:template match="legalnotice" mode="find.chunks"/>
438 <xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="$exsl.node.set.available != 0 and namespace-uri(/*) = 'http://docbook.org/ns/docbook'"><xslo:variable name="no.namespace"><xslo:apply-templates select="/*" mode="stripNS"/></xslo:variable><xslo:call-template name="log.message"><xslo:with-param name="level">Note</xslo:with-param><xslo:with-param name="source"><xslo:call-template name="get.doc.title"/></xslo:with-param><xslo:with-param name="context-desc"><xslo:text>namesp. cut</xslo:text></xslo:with-param><xslo:with-param name="message"><xslo:text>stripped namespace before processing</xslo:text></xslo:with-param></xslo:call-template><xslo:apply-templates select="exslt:node-set($no.namespace)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/">
439 <!-- * Get a title for current doc so that we let the user -->
440 <!-- * know what document we are processing at this point. -->
441 <xsl:variable name="doc.title">
442 <xsl:call-template name="get.doc.title"/>
445 <xsl:when test="false()"/>
446 <!-- Can't process unless namespace fixed with exsl node-set()-->
447 <xsl:when test="false()"/>
450 <xsl:when test="$rootid != ''">
452 <xsl:when test="count($profiled-nodes//*[@id=$rootid or @xml:id=$rootid]) = 0">
453 <xsl:message terminate="yes">
454 <xsl:text>ID '</xsl:text>
455 <xsl:value-of select="$rootid"/>
456 <xsl:text>' not found in document.</xsl:text>
460 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
461 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
463 <xsl:if test="$collect.xref.targets != 'only'">
464 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="process.root"/>
465 <xsl:if test="$tex.math.in.alt != ''">
466 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="collect.tex.math"/>
468 <xsl:if test="$generate.manifest != 0">
469 <xsl:call-template name="generate.manifest">
470 <xsl:with-param name="node" select="key('id',$rootid)"/>
478 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
479 <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
481 <xsl:if test="$collect.xref.targets != 'only'">
482 <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
483 <xsl:if test="$tex.math.in.alt != ''">
484 <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
486 <xsl:if test="$generate.manifest != 0">
487 <xsl:call-template name="generate.manifest">
488 <xsl:with-param name="node" select="$profiled-nodes"/>
498 <xsl:template match="*" mode="process.root">
499 <xsl:apply-templates select="."/>
500 <xsl:call-template name="generate.css.files"/>
503 <!-- ====================================================================== -->
505 <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">
507 <xsl:when test="$onechunk != 0 and parent::*">
511 <xsl:call-template name="process-chunk-element"/>
516 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
517 <xsl:variable name="ischunk">
518 <xsl:call-template name="chunk"/>
522 <xsl:when test="not(parent::*)">
523 <xsl:call-template name="process-chunk-element"/>
525 <xsl:when test="$ischunk = 0">
529 <xsl:call-template name="process-chunk-element"/>
534 <xsl:template match="setindex |book/index |article/index |part/index">
535 <!-- some implementations use completely empty index tags to indicate -->
536 <!-- where an automatically generated index should be inserted. so -->
537 <!-- if the index is completely empty, skip it. -->
538 <xsl:if test="count(*)>0 or $generate.index != '0'">
539 <xsl:call-template name="process-chunk-element"/>
543 <!-- Resolve xml:base attributes -->
544 <xsl:template match="@fileref">
545 <!-- need a check for absolute urls -->
547 <xsl:when test="contains(., ':')">
548 <!-- it has a uri scheme so it is an absolute uri -->
549 <xsl:value-of select="."/>
551 <xsl:when test="$keep.relative.image.uris != 0">
552 <!-- leave it alone -->
553 <xsl:value-of select="."/>
556 <!-- its a relative uri -->
557 <xsl:call-template name="relative-uri">
558 <xsl:with-param name="destdir">
559 <xsl:call-template name="dbhtml-dir">
560 <xsl:with-param name="context" select=".."/>
568 <!-- ==================================================================== -->
569 <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">
570 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
571 <xsl:if test="$ischunk='1'">
572 <xsl:call-template name="make-relative-filename">
573 <xsl:with-param name="base.dir">
574 <xsl:if test="$manifest.in.base.dir = 0">
575 <xsl:value-of select="$chunk.base.dir"/>
578 <xsl:with-param name="base.name">
579 <xsl:apply-templates mode="chunk-filename" select="."/>
585 <xsl:apply-templates select="*" mode="enumerate-files"/>
588 <xsl:template match="book/index|article/index|part/index" mode="enumerate-files">
589 <xsl:if test="$htmlhelp.output != 1">
590 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
591 <xsl:if test="$ischunk='1'">
592 <xsl:call-template name="make-relative-filename">
593 <xsl:with-param name="base.dir">
594 <xsl:if test="$manifest.in.base.dir = 0">
595 <xsl:value-of select="$chunk.base.dir"/>
598 <xsl:with-param name="base.name">
599 <xsl:apply-templates mode="chunk-filename" select="."/>
605 <xsl:apply-templates select="*" mode="enumerate-files"/>
609 <xsl:template match="legalnotice" mode="enumerate-files">
610 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
611 <xsl:if test="$generate.legalnotice.link != 0">
612 <xsl:call-template name="make-relative-filename">
613 <xsl:with-param name="base.dir">
614 <xsl:if test="$manifest.in.base.dir = 0">
615 <xsl:value-of select="$chunk.base.dir"/>
618 <xsl:with-param name="base.name">
619 <xsl:apply-templates mode="chunk-filename" select="."/>
627 <xsl:template match="revhistory" mode="enumerate-files">
628 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
629 <xsl:if test="$generate.revhistory.link != 0">
630 <xsl:call-template name="make-relative-filename">
631 <xsl:with-param name="base.dir">
632 <xsl:if test="$manifest.in.base.dir = 0">
633 <xsl:value-of select="$chunk.base.dir"/>
636 <xsl:with-param name="base.name">
637 <xsl:call-template name="ln.or.rh.filename">
638 <xsl:with-param name="is.ln" select="false()"/>
647 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
648 <xsl:variable name="longdesc.uri">
649 <xsl:call-template name="longdesc.uri">
650 <xsl:with-param name="mediaobject" select="."/>
653 <xsl:variable name="mediaobject" select="."/>
655 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
656 <xsl:call-template name="longdesc.uri">
657 <xsl:with-param name="mediaobject" select="$mediaobject"/>
664 <xsl:template match="text()" mode="enumerate-files">