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:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exslt="http://exslt.org/common" 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 ng db exslt" version="1.0">
8 <!-- ********************************************************************
9 $Id: chunk-code.xsl 9328 2012-05-03 16:28:23Z 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 <xsl:when test="self::set">
136 <xsl:value-of select="$root.filename"/>
137 <xsl:if test="not($recursive)">
138 <xsl:value-of select="$html.ext"/>
142 <xsl:when test="self::book">
143 <xsl:text>bk</xsl:text>
144 <xsl:number level="any" format="01"/>
145 <xsl:if test="not($recursive)">
146 <xsl:value-of select="$html.ext"/>
150 <xsl:when test="self::article">
152 <!-- in a set, make sure we inherit the right book info... -->
153 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
154 <xsl:with-param name="recursive" select="true()"/>
155 </xsl:apply-templates>
158 <xsl:text>ar</xsl:text>
159 <xsl:number level="any" format="01" from="book"/>
160 <xsl:if test="not($recursive)">
161 <xsl:value-of select="$html.ext"/>
165 <xsl:when test="self::preface">
167 <!-- in a set, make sure we inherit the right book info... -->
168 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
169 <xsl:with-param name="recursive" select="true()"/>
170 </xsl:apply-templates>
173 <xsl:text>pr</xsl:text>
174 <xsl:number level="any" format="01" from="book"/>
175 <xsl:if test="not($recursive)">
176 <xsl:value-of select="$html.ext"/>
180 <xsl:when test="self::chapter">
182 <!-- in a set, make sure we inherit the right book info... -->
183 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
184 <xsl:with-param name="recursive" select="true()"/>
185 </xsl:apply-templates>
188 <xsl:text>ch</xsl:text>
189 <xsl:number level="any" format="01" from="book"/>
190 <xsl:if test="not($recursive)">
191 <xsl:value-of select="$html.ext"/>
195 <xsl:when test="self::appendix">
197 <!-- in a set, make sure we inherit the right book info... -->
198 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
199 <xsl:with-param name="recursive" select="true()"/>
200 </xsl:apply-templates>
203 <xsl:text>ap</xsl:text>
204 <xsl:number level="any" format="a" from="book"/>
205 <xsl:if test="not($recursive)">
206 <xsl:value-of select="$html.ext"/>
210 <xsl:when test="self::part">
212 <xsl:when test="/set">
213 <!-- in a set, make sure we inherit the right book info... -->
214 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
215 <xsl:with-param name="recursive" select="true()"/>
216 </xsl:apply-templates>
222 <xsl:text>pt</xsl:text>
223 <xsl:number level="any" format="01" from="book"/>
224 <xsl:if test="not($recursive)">
225 <xsl:value-of select="$html.ext"/>
229 <xsl:when test="self::reference">
231 <xsl:when test="/set">
232 <!-- in a set, make sure we inherit the right book info... -->
233 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
234 <xsl:with-param name="recursive" select="true()"/>
235 </xsl:apply-templates>
241 <xsl:text>rn</xsl:text>
242 <xsl:number level="any" format="01" from="book"/>
243 <xsl:if test="not($recursive)">
244 <xsl:value-of select="$html.ext"/>
248 <xsl:when test="self::refentry">
250 <xsl:when test="parent::reference">
251 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
252 <xsl:with-param name="recursive" select="true()"/>
253 </xsl:apply-templates>
257 <!-- in a set, make sure we inherit the right book info... -->
258 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
259 <xsl:with-param name="recursive" select="true()"/>
260 </xsl:apply-templates>
265 <xsl:text>re</xsl:text>
266 <xsl:number level="any" format="01" from="book"/>
267 <xsl:if test="not($recursive)">
268 <xsl:value-of select="$html.ext"/>
272 <xsl:when test="self::colophon">
274 <xsl:when test="/set">
275 <!-- in a set, make sure we inherit the right book info... -->
276 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
277 <xsl:with-param name="recursive" select="true()"/>
278 </xsl:apply-templates>
284 <xsl:text>co</xsl:text>
285 <xsl:number level="any" format="01" from="book"/>
286 <xsl:if test="not($recursive)">
287 <xsl:value-of select="$html.ext"/>
291 <xsl:when test="self::sect1 or self::sect2 or self::sect3 or self::sect4 or self::sect5 or self::section">
292 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
293 <xsl:with-param name="recursive" select="true()"/>
294 </xsl:apply-templates>
295 <xsl:text>s</xsl:text>
296 <xsl:number format="01"/>
297 <xsl:if test="not($recursive)">
298 <xsl:value-of select="$html.ext"/>
302 <xsl:when test="self::bibliography">
304 <xsl:when test="/set">
305 <!-- in a set, make sure we inherit the right book info... -->
306 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
307 <xsl:with-param name="recursive" select="true()"/>
308 </xsl:apply-templates>
314 <xsl:text>bi</xsl:text>
315 <xsl:number level="any" format="01" from="book"/>
316 <xsl:if test="not($recursive)">
317 <xsl:value-of select="$html.ext"/>
321 <xsl:when test="self::glossary">
323 <xsl:when test="/set">
324 <!-- in a set, make sure we inherit the right book info... -->
325 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
326 <xsl:with-param name="recursive" select="true()"/>
327 </xsl:apply-templates>
333 <xsl:text>go</xsl:text>
334 <xsl:number level="any" format="01" from="book"/>
335 <xsl:if test="not($recursive)">
336 <xsl:value-of select="$html.ext"/>
340 <xsl:when test="self::index">
342 <xsl:when test="/set">
343 <!-- in a set, make sure we inherit the right book info... -->
344 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
345 <xsl:with-param name="recursive" select="true()"/>
346 </xsl:apply-templates>
352 <xsl:text>ix</xsl:text>
353 <xsl:number level="any" format="01" from="book"/>
354 <xsl:if test="not($recursive)">
355 <xsl:value-of select="$html.ext"/>
359 <xsl:when test="self::setindex">
360 <xsl:text>si</xsl:text>
361 <xsl:number level="any" format="01" from="set"/>
362 <xsl:if test="not($recursive)">
363 <xsl:value-of select="$html.ext"/>
367 <xsl:when test="self::topic">
369 <xsl:when test="/set">
370 <!-- in a set, make sure we inherit the right book info... -->
371 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
372 <xsl:with-param name="recursive" select="true()"/>
373 </xsl:apply-templates>
379 <xsl:text>to</xsl:text>
380 <xsl:number level="any" format="01" from="book"/>
381 <xsl:if test="not($recursive)">
382 <xsl:value-of select="$html.ext"/>
387 <xsl:text>chunk-filename-error-</xsl:text>
388 <xsl:value-of select="name(.)"/>
389 <xsl:number level="any" format="01" from="set"/>
390 <xsl:if test="not($recursive)">
391 <xsl:value-of select="$html.ext"/>
397 <!-- ==================================================================== -->
401 <xsl:template match="processing-instruction('dbhtml')">
405 <!-- ==================================================================== -->
408 <xsl:template match="*" mode="find.chunks">
409 <xsl:variable name="chunk">
410 <xsl:call-template name="chunk"/>
414 <xsl:when test="$chunk != 0">
415 <cf:div id="{generate-id()}">
416 <xsl:apply-templates select="." mode="class.attribute"/>
417 <xsl:apply-templates select="*" mode="find.chunks"/>
421 <xsl:apply-templates select="*" mode="find.chunks"/>
426 <!-- Leave legalnotice chunk out of the list for Next and Prev -->
427 <xsl:template match="legalnotice" mode="find.chunks"/>
429 <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="*/self::ng:* or */self::db:*"><xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Note: namesp. cut : processing stripped document</xslo:message><xslo:apply-templates select="exslt:node-set($stripped-content)" 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="/">
430 <!-- * Get a title for current doc so that we let the user -->
431 <!-- * know what document we are processing at this point. -->
432 <xsl:variable name="doc.title">
433 <xsl:call-template name="get.doc.title"/>
436 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
437 toss the namespace and continue. Use the docbook5 namespaced
438 stylesheets for DocBook5 if you don't want to use this feature.-->
439 <xsl:when test="false()"/>
440 <!-- Can't process unless namespace removed -->
441 <xsl:when test="false()"/>
444 <xsl:when test="$rootid != ''">
446 <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0">
447 <xsl:message terminate="yes">
448 <xsl:text>ID '</xsl:text>
449 <xsl:value-of select="$rootid"/>
450 <xsl:text>' not found in document.</xsl:text>
454 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
455 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
457 <xsl:if test="$collect.xref.targets != 'only'">
458 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
459 <xsl:if test="$tex.math.in.alt != ''">
460 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="collect.tex.math"/>
462 <xsl:if test="$generate.manifest != 0">
463 <xsl:call-template name="generate.manifest">
464 <xsl:with-param name="node" select="key('id',$rootid)"/>
472 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
473 <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
475 <xsl:if test="$collect.xref.targets != 'only'">
476 <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
477 <xsl:if test="$tex.math.in.alt != ''">
478 <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
480 <xsl:if test="$generate.manifest != 0">
481 <xsl:call-template name="generate.manifest">
482 <xsl:with-param name="node" select="$profiled-nodes"/>
492 <xsl:template match="*" mode="process.root">
493 <xsl:apply-templates select="."/>
494 <xsl:call-template name="generate.css.files"/>
497 <!-- ====================================================================== -->
499 <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">
501 <xsl:when test="$onechunk != 0 and parent::*">
505 <xsl:call-template name="process-chunk-element"/>
510 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
511 <xsl:variable name="ischunk">
512 <xsl:call-template name="chunk"/>
516 <xsl:when test="not(parent::*)">
517 <xsl:call-template name="process-chunk-element"/>
519 <xsl:when test="$ischunk = 0">
523 <xsl:call-template name="process-chunk-element"/>
528 <xsl:template match="setindex |book/index |article/index |part/index">
529 <!-- some implementations use completely empty index tags to indicate -->
530 <!-- where an automatically generated index should be inserted. so -->
531 <!-- if the index is completely empty, skip it. -->
532 <xsl:if test="count(*)>0 or $generate.index != '0'">
533 <xsl:call-template name="process-chunk-element"/>
537 <!-- Resolve xml:base attributes -->
538 <xsl:template match="@fileref">
539 <!-- need a check for absolute urls -->
541 <xsl:when test="contains(., ':')">
542 <!-- it has a uri scheme so it is an absolute uri -->
543 <xsl:value-of select="."/>
545 <xsl:when test="$keep.relative.image.uris != 0">
546 <!-- leave it alone -->
547 <xsl:value-of select="."/>
550 <!-- its a relative uri -->
551 <xsl:call-template name="relative-uri">
552 <xsl:with-param name="destdir">
553 <xsl:call-template name="dbhtml-dir">
554 <xsl:with-param name="context" select=".."/>
562 <!-- ==================================================================== -->
563 <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">
564 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
565 <xsl:if test="$ischunk='1'">
566 <xsl:call-template name="make-relative-filename">
567 <xsl:with-param name="base.dir">
568 <xsl:if test="$manifest.in.base.dir = 0">
569 <xsl:value-of select="$chunk.base.dir"/>
572 <xsl:with-param name="base.name">
573 <xsl:apply-templates mode="chunk-filename" select="."/>
579 <xsl:apply-templates select="*" mode="enumerate-files"/>
582 <xsl:template match="book/index|article/index|part/index" mode="enumerate-files">
583 <xsl:if test="$htmlhelp.output != 1">
584 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
585 <xsl:if test="$ischunk='1'">
586 <xsl:call-template name="make-relative-filename">
587 <xsl:with-param name="base.dir">
588 <xsl:if test="$manifest.in.base.dir = 0">
589 <xsl:value-of select="$chunk.base.dir"/>
592 <xsl:with-param name="base.name">
593 <xsl:apply-templates mode="chunk-filename" select="."/>
599 <xsl:apply-templates select="*" mode="enumerate-files"/>
603 <xsl:template match="legalnotice" mode="enumerate-files">
604 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
605 <xsl:if test="$generate.legalnotice.link != 0">
606 <xsl:call-template name="make-relative-filename">
607 <xsl:with-param name="base.dir">
608 <xsl:if test="$manifest.in.base.dir = 0">
609 <xsl:value-of select="$chunk.base.dir"/>
612 <xsl:with-param name="base.name">
613 <xsl:apply-templates mode="chunk-filename" select="."/>
621 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
622 <xsl:variable name="longdesc.uri">
623 <xsl:call-template name="longdesc.uri">
624 <xsl:with-param name="mediaobject" select="."/>
627 <xsl:variable name="mediaobject" select="."/>
629 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
630 <xsl:call-template name="longdesc.uri">
631 <xsl:with-param name="mediaobject" select="$mediaobject"/>
638 <xsl:template match="text()" mode="enumerate-files">