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 8596 2010-03-20 04:36:45Z 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="$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 <xsl:when test="self::set">
134 <xsl:value-of select="$root.filename"/>
135 <xsl:if test="not($recursive)">
136 <xsl:value-of select="$html.ext"/>
140 <xsl:when test="self::book">
141 <xsl:text>bk</xsl:text>
142 <xsl:number level="any" format="01"/>
143 <xsl:if test="not($recursive)">
144 <xsl:value-of select="$html.ext"/>
148 <xsl:when test="self::article">
150 <!-- in a set, make sure we inherit the right book info... -->
151 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
152 <xsl:with-param name="recursive" select="true()"/>
153 </xsl:apply-templates>
156 <xsl:text>ar</xsl:text>
157 <xsl:number level="any" format="01" from="book"/>
158 <xsl:if test="not($recursive)">
159 <xsl:value-of select="$html.ext"/>
163 <xsl:when test="self::preface">
165 <!-- in a set, make sure we inherit the right book info... -->
166 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
167 <xsl:with-param name="recursive" select="true()"/>
168 </xsl:apply-templates>
171 <xsl:text>pr</xsl:text>
172 <xsl:number level="any" format="01" from="book"/>
173 <xsl:if test="not($recursive)">
174 <xsl:value-of select="$html.ext"/>
178 <xsl:when test="self::chapter">
180 <!-- in a set, make sure we inherit the right book info... -->
181 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
182 <xsl:with-param name="recursive" select="true()"/>
183 </xsl:apply-templates>
186 <xsl:text>ch</xsl:text>
187 <xsl:number level="any" format="01" from="book"/>
188 <xsl:if test="not($recursive)">
189 <xsl:value-of select="$html.ext"/>
193 <xsl:when test="self::appendix">
195 <!-- in a set, make sure we inherit the right book info... -->
196 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
197 <xsl:with-param name="recursive" select="true()"/>
198 </xsl:apply-templates>
201 <xsl:text>ap</xsl:text>
202 <xsl:number level="any" format="a" from="book"/>
203 <xsl:if test="not($recursive)">
204 <xsl:value-of select="$html.ext"/>
208 <xsl:when test="self::part">
210 <xsl:when test="/set">
211 <!-- in a set, make sure we inherit the right book info... -->
212 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
213 <xsl:with-param name="recursive" select="true()"/>
214 </xsl:apply-templates>
220 <xsl:text>pt</xsl:text>
221 <xsl:number level="any" format="01" from="book"/>
222 <xsl:if test="not($recursive)">
223 <xsl:value-of select="$html.ext"/>
227 <xsl:when test="self::reference">
229 <xsl:when test="/set">
230 <!-- in a set, make sure we inherit the right book info... -->
231 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
232 <xsl:with-param name="recursive" select="true()"/>
233 </xsl:apply-templates>
239 <xsl:text>rn</xsl:text>
240 <xsl:number level="any" format="01" from="book"/>
241 <xsl:if test="not($recursive)">
242 <xsl:value-of select="$html.ext"/>
246 <xsl:when test="self::refentry">
248 <xsl:when test="parent::reference">
249 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
250 <xsl:with-param name="recursive" select="true()"/>
251 </xsl:apply-templates>
255 <!-- in a set, make sure we inherit the right book info... -->
256 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
257 <xsl:with-param name="recursive" select="true()"/>
258 </xsl:apply-templates>
263 <xsl:text>re</xsl:text>
264 <xsl:number level="any" format="01" from="book"/>
265 <xsl:if test="not($recursive)">
266 <xsl:value-of select="$html.ext"/>
270 <xsl:when test="self::colophon">
272 <xsl:when test="/set">
273 <!-- in a set, make sure we inherit the right book info... -->
274 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
275 <xsl:with-param name="recursive" select="true()"/>
276 </xsl:apply-templates>
282 <xsl:text>co</xsl:text>
283 <xsl:number level="any" format="01" from="book"/>
284 <xsl:if test="not($recursive)">
285 <xsl:value-of select="$html.ext"/>
289 <xsl:when test="self::sect1 or self::sect2 or self::sect3 or self::sect4 or self::sect5 or self::section">
290 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
291 <xsl:with-param name="recursive" select="true()"/>
292 </xsl:apply-templates>
293 <xsl:text>s</xsl:text>
294 <xsl:number format="01"/>
295 <xsl:if test="not($recursive)">
296 <xsl:value-of select="$html.ext"/>
300 <xsl:when test="self::bibliography">
302 <xsl:when test="/set">
303 <!-- in a set, make sure we inherit the right book info... -->
304 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
305 <xsl:with-param name="recursive" select="true()"/>
306 </xsl:apply-templates>
312 <xsl:text>bi</xsl:text>
313 <xsl:number level="any" format="01" from="book"/>
314 <xsl:if test="not($recursive)">
315 <xsl:value-of select="$html.ext"/>
319 <xsl:when test="self::glossary">
321 <xsl:when test="/set">
322 <!-- in a set, make sure we inherit the right book info... -->
323 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
324 <xsl:with-param name="recursive" select="true()"/>
325 </xsl:apply-templates>
331 <xsl:text>go</xsl:text>
332 <xsl:number level="any" format="01" from="book"/>
333 <xsl:if test="not($recursive)">
334 <xsl:value-of select="$html.ext"/>
338 <xsl:when test="self::index">
340 <xsl:when test="/set">
341 <!-- in a set, make sure we inherit the right book info... -->
342 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
343 <xsl:with-param name="recursive" select="true()"/>
344 </xsl:apply-templates>
350 <xsl:text>ix</xsl:text>
351 <xsl:number level="any" format="01" from="book"/>
352 <xsl:if test="not($recursive)">
353 <xsl:value-of select="$html.ext"/>
357 <xsl:when test="self::setindex">
358 <xsl:text>si</xsl:text>
359 <xsl:number level="any" format="01" from="set"/>
360 <xsl:if test="not($recursive)">
361 <xsl:value-of select="$html.ext"/>
366 <xsl:text>chunk-filename-error-</xsl:text>
367 <xsl:value-of select="name(.)"/>
368 <xsl:number level="any" format="01" from="set"/>
369 <xsl:if test="not($recursive)">
370 <xsl:value-of select="$html.ext"/>
376 <!-- ==================================================================== -->
380 <xsl:template match="processing-instruction('dbhtml')">
384 <!-- ==================================================================== -->
387 <xsl:template match="*" mode="find.chunks">
388 <xsl:variable name="chunk">
389 <xsl:call-template name="chunk"/>
393 <xsl:when test="$chunk != 0">
394 <cf:div id="{generate-id()}">
395 <xsl:apply-templates select="." mode="class.attribute"/>
396 <xsl:apply-templates select="*" mode="find.chunks"/>
400 <xsl:apply-templates select="*" mode="find.chunks"/>
405 <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="/">
406 <!-- * Get a title for current doc so that we let the user -->
407 <!-- * know what document we are processing at this point. -->
408 <xsl:variable name="doc.title">
409 <xsl:call-template name="get.doc.title"/>
412 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
413 toss the namespace and continue. Use the docbook5 namespaced
414 stylesheets for DocBook5 if you don't want to use this feature.-->
415 <xsl:when test="false()"/>
416 <!-- Can't process unless namespace removed -->
417 <xsl:when test="false()"/>
420 <xsl:when test="$rootid != ''">
422 <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0">
423 <xsl:message terminate="yes">
424 <xsl:text>ID '</xsl:text>
425 <xsl:value-of select="$rootid"/>
426 <xsl:text>' not found in document.</xsl:text>
430 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
431 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
433 <xsl:if test="$collect.xref.targets != 'only'">
434 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
435 <xsl:if test="$tex.math.in.alt != ''">
436 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="collect.tex.math"/>
438 <xsl:if test="$generate.manifest != 0">
439 <xsl:call-template name="generate.manifest">
440 <xsl:with-param name="node" select="key('id',$rootid)"/>
448 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
449 <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
451 <xsl:if test="$collect.xref.targets != 'only'">
452 <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
453 <xsl:if test="$tex.math.in.alt != ''">
454 <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
456 <xsl:if test="$generate.manifest != 0">
457 <xsl:call-template name="generate.manifest">
458 <xsl:with-param name="node" select="$profiled-nodes"/>
468 <xsl:template match="*" mode="process.root">
469 <xsl:apply-templates select="."/>
470 <xsl:call-template name="generate.css"/>
473 <!-- ====================================================================== -->
475 <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">
477 <xsl:when test="$onechunk != 0 and parent::*">
481 <xsl:call-template name="process-chunk-element"/>
486 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
487 <xsl:variable name="ischunk">
488 <xsl:call-template name="chunk"/>
492 <xsl:when test="not(parent::*)">
493 <xsl:call-template name="process-chunk-element"/>
495 <xsl:when test="$ischunk = 0">
499 <xsl:call-template name="process-chunk-element"/>
504 <xsl:template match="setindex |book/index |article/index |part/index">
505 <!-- some implementations use completely empty index tags to indicate -->
506 <!-- where an automatically generated index should be inserted. so -->
507 <!-- if the index is completely empty, skip it. -->
508 <xsl:if test="count(*)>0 or $generate.index != '0'">
509 <xsl:call-template name="process-chunk-element"/>
513 <!-- Resolve xml:base attributes -->
514 <xsl:template match="@fileref">
515 <!-- need a check for absolute urls -->
517 <xsl:when test="contains(., ':')">
518 <!-- it has a uri scheme so it is an absolute uri -->
519 <xsl:value-of select="."/>
521 <xsl:when test="$keep.relative.image.uris != 0">
522 <!-- leave it alone -->
523 <xsl:value-of select="."/>
526 <!-- its a relative uri -->
527 <xsl:call-template name="relative-uri">
528 <xsl:with-param name="destdir">
529 <xsl:call-template name="dbhtml-dir">
530 <xsl:with-param name="context" select=".."/>
538 <!-- ==================================================================== -->
539 <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">
540 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
541 <xsl:if test="$ischunk='1'">
542 <xsl:call-template name="make-relative-filename">
543 <xsl:with-param name="base.dir">
544 <xsl:if test="$manifest.in.base.dir = 0">
545 <xsl:value-of select="$base.dir"/>
548 <xsl:with-param name="base.name">
549 <xsl:apply-templates mode="chunk-filename" select="."/>
555 <xsl:apply-templates select="*" mode="enumerate-files"/>
558 <xsl:template match="book/index|article/index|part/index" mode="enumerate-files">
559 <xsl:if test="$htmlhelp.output != 1">
560 <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
561 <xsl:if test="$ischunk='1'">
562 <xsl:call-template name="make-relative-filename">
563 <xsl:with-param name="base.dir">
564 <xsl:if test="$manifest.in.base.dir = 0">
565 <xsl:value-of select="$base.dir"/>
568 <xsl:with-param name="base.name">
569 <xsl:apply-templates mode="chunk-filename" select="."/>
575 <xsl:apply-templates select="*" mode="enumerate-files"/>
579 <xsl:template match="legalnotice" mode="enumerate-files">
580 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
581 <xsl:if test="$generate.legalnotice.link != 0">
582 <xsl:call-template name="make-relative-filename">
583 <xsl:with-param name="base.dir">
584 <xsl:if test="$manifest.in.base.dir = 0">
585 <xsl:value-of select="$base.dir"/>
588 <xsl:with-param name="base.name">
589 <xsl:apply-templates mode="chunk-filename" select="."/>
597 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
598 <xsl:variable name="longdesc.uri">
599 <xsl:call-template name="longdesc.uri">
600 <xsl:with-param name="mediaobject" select="."/>
603 <xsl:variable name="mediaobject" select="."/>
605 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
606 <xsl:call-template name="longdesc.uri">
607 <xsl:with-param name="mediaobject" select="$mediaobject"/>
614 <xsl:template match="text()" mode="enumerate-files">