]> git.stg.codes - stg.git/blob - doc/xslt/html/chunk-code.xsl
Set output encoding to utf-8.
[stg.git] / doc / xslt / html / chunk-code.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:exsl="http://exslt.org/common"
4                 xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
5                 xmlns:ng="http://docbook.org/docbook-ng"
6                 xmlns:db="http://docbook.org/ns/docbook"
7                 exclude-result-prefixes="exsl cf ng db"
8                 version="1.0">
9
10 <!-- ********************************************************************
11      $Id: chunk-code.xsl 8596 2010-03-20 04:36:45Z bobstayton $
12      ********************************************************************
13
14      This file is part of the XSL DocBook Stylesheet distribution.
15      See ../README or http://docbook.sf.net/release/xsl/current/ for
16      copyright and other information.
17
18      ******************************************************************** -->
19
20 <!-- ==================================================================== -->
21
22
23 <xsl:template match="*" mode="chunk-filename">
24   <!-- returns the filename of a chunk -->
25   <xsl:variable name="ischunk">
26     <xsl:call-template name="chunk"/>
27   </xsl:variable>
28
29   <xsl:variable name="fn">
30     <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
31   </xsl:variable>
32
33   <!--
34   <xsl:message>
35     <xsl:value-of select="$ischunk"/>
36     <xsl:text> (</xsl:text>
37     <xsl:value-of select="local-name(.)"/>
38     <xsl:text>) </xsl:text>
39     <xsl:value-of select="$fn"/>
40     <xsl:text>, </xsl:text>
41     <xsl:call-template name="dbhtml-dir"/>
42   </xsl:message>
43   -->
44
45   <!-- 2003-11-25 by ndw:
46        The following test used to read test="$ischunk != 0 and $fn != ''"
47        I've removed the ischunk part of the test so that href.to.uri and
48        href.from.uri will be fully qualified even if the source or target
49        isn't a chunk. I *think* that if $fn != '' then it's appropriate
50        to put the directory on the front, even if the element isn't a
51        chunk. I could be wrong. -->
52
53   <xsl:if test="$fn != ''">
54     <xsl:call-template name="dbhtml-dir"/>
55   </xsl:if>
56
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 -->
60 </xsl:template>
61
62 <xsl:template match="*" mode="recursive-chunk-filename">
63   <xsl:param name="recursive" select="false()"/>
64
65   <!-- returns the filename of a chunk -->
66   <xsl:variable name="ischunk">
67     <xsl:call-template name="chunk"/>
68   </xsl:variable>
69
70   <xsl:variable name="dbhtml-filename">
71     <xsl:call-template name="pi.dbhtml_filename"/>
72   </xsl:variable>
73
74   <xsl:variable name="filename">
75     <xsl:choose>
76       <xsl:when test="$dbhtml-filename != ''">
77         <xsl:value-of select="$dbhtml-filename"/>
78       </xsl:when>
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"/>
83       </xsl:when>
84       <!-- Special case -->
85       <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
86         <xsl:choose>
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"/>
93           </xsl:when>
94           <xsl:otherwise>
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"/>
99             </xsl:variable>
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)"/>
103           </xsl:otherwise>
104         </xsl:choose>
105       </xsl:when>
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"/>
111       </xsl:when>
112       <xsl:otherwise></xsl:otherwise>
113     </xsl:choose>
114   </xsl:variable>
115
116   <xsl:choose>
117     <xsl:when test="$ischunk='0'">
118       <!-- if called on something that isn't a chunk, walk up... -->
119       <xsl:choose>
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>
124         </xsl:when>
125         <!-- unless there is no up, in which case return "" -->
126         <xsl:otherwise></xsl:otherwise>
127       </xsl:choose>
128     </xsl:when>
129
130     <xsl:when test="not($recursive) and $filename != ''">
131       <!-- if this chunk has an explicit name, use it -->
132       <xsl:value-of select="$filename"/>
133     </xsl:when>
134
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"/>
139       </xsl:if>
140     </xsl:when>
141
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"/>
147       </xsl:if>
148     </xsl:when>
149
150     <xsl:when test="self::article">
151       <xsl:if test="/set">
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>
156       </xsl:if>
157
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"/>
162       </xsl:if>
163     </xsl:when>
164
165     <xsl:when test="self::preface">
166       <xsl:if test="/set">
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>
171       </xsl:if>
172
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"/>
177       </xsl:if>
178     </xsl:when>
179
180     <xsl:when test="self::chapter">
181       <xsl:if test="/set">
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>
186       </xsl:if>
187
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"/>
192       </xsl:if>
193     </xsl:when>
194
195     <xsl:when test="self::appendix">
196       <xsl:if test="/set">
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>
201       </xsl:if>
202
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"/>
207       </xsl:if>
208     </xsl:when>
209
210     <xsl:when test="self::part">
211       <xsl:choose>
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>
217         </xsl:when>
218         <xsl:otherwise>
219         </xsl:otherwise>
220       </xsl:choose>
221
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"/>
226       </xsl:if>
227     </xsl:when>
228
229     <xsl:when test="self::reference">
230       <xsl:choose>
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>
236         </xsl:when>
237         <xsl:otherwise>
238         </xsl:otherwise>
239       </xsl:choose>
240
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"/>
245       </xsl:if>
246     </xsl:when>
247
248     <xsl:when test="self::refentry">
249       <xsl:choose>
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>
254         </xsl:when>
255         <xsl:otherwise>
256           <xsl:if test="/set">
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>
261           </xsl:if>
262         </xsl:otherwise>
263       </xsl:choose>
264
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"/>
269       </xsl:if>
270     </xsl:when>
271
272     <xsl:when test="self::colophon">
273       <xsl:choose>
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>
279         </xsl:when>
280         <xsl:otherwise>
281         </xsl:otherwise>
282       </xsl:choose>
283
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"/>
288       </xsl:if>
289     </xsl:when>
290
291     <xsl:when test="self::sect1
292                     or self::sect2
293                     or self::sect3
294                     or self::sect4
295                     or self::sect5
296                     or self::section">
297       <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
298         <xsl:with-param name="recursive" select="true()"/>
299       </xsl:apply-templates>
300       <xsl:text>s</xsl:text>
301       <xsl:number format="01"/>
302       <xsl:if test="not($recursive)">
303         <xsl:value-of select="$html.ext"/>
304       </xsl:if>
305     </xsl:when>
306
307     <xsl:when test="self::bibliography">
308       <xsl:choose>
309         <xsl:when test="/set">
310           <!-- in a set, make sure we inherit the right book info... -->
311           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
312             <xsl:with-param name="recursive" select="true()"/>
313           </xsl:apply-templates>
314         </xsl:when>
315         <xsl:otherwise>
316         </xsl:otherwise>
317       </xsl:choose>
318
319       <xsl:text>bi</xsl:text>
320       <xsl:number level="any" format="01" from="book"/>
321       <xsl:if test="not($recursive)">
322         <xsl:value-of select="$html.ext"/>
323       </xsl:if>
324     </xsl:when>
325
326     <xsl:when test="self::glossary">
327       <xsl:choose>
328         <xsl:when test="/set">
329           <!-- in a set, make sure we inherit the right book info... -->
330           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
331             <xsl:with-param name="recursive" select="true()"/>
332           </xsl:apply-templates>
333         </xsl:when>
334         <xsl:otherwise>
335         </xsl:otherwise>
336       </xsl:choose>
337
338       <xsl:text>go</xsl:text>
339       <xsl:number level="any" format="01" from="book"/>
340       <xsl:if test="not($recursive)">
341         <xsl:value-of select="$html.ext"/>
342       </xsl:if>
343     </xsl:when>
344
345     <xsl:when test="self::index">
346       <xsl:choose>
347         <xsl:when test="/set">
348           <!-- in a set, make sure we inherit the right book info... -->
349           <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
350             <xsl:with-param name="recursive" select="true()"/>
351           </xsl:apply-templates>
352         </xsl:when>
353         <xsl:otherwise>
354         </xsl:otherwise>
355       </xsl:choose>
356
357       <xsl:text>ix</xsl:text>
358       <xsl:number level="any" format="01" from="book"/>
359       <xsl:if test="not($recursive)">
360         <xsl:value-of select="$html.ext"/>
361       </xsl:if>
362     </xsl:when>
363
364     <xsl:when test="self::setindex">
365       <xsl:text>si</xsl:text>
366       <xsl:number level="any" format="01" from="set"/>
367       <xsl:if test="not($recursive)">
368         <xsl:value-of select="$html.ext"/>
369       </xsl:if>
370     </xsl:when>
371
372     <xsl:otherwise>
373       <xsl:text>chunk-filename-error-</xsl:text>
374       <xsl:value-of select="name(.)"/>
375       <xsl:number level="any" format="01" from="set"/>
376       <xsl:if test="not($recursive)">
377         <xsl:value-of select="$html.ext"/>
378       </xsl:if>
379     </xsl:otherwise>
380   </xsl:choose>
381 </xsl:template>
382
383 <!-- ==================================================================== -->
384
385
386
387 <xsl:template match="processing-instruction('dbhtml')">
388   <!-- nop -->
389 </xsl:template>
390
391 <!-- ==================================================================== -->
392
393
394 <xsl:template match="*" mode="find.chunks">
395   <xsl:variable name="chunk">
396     <xsl:call-template name="chunk"/>
397   </xsl:variable>
398
399   <xsl:choose>
400     <xsl:when test="$chunk != 0">
401       <cf:div id="{generate-id()}">
402         <xsl:apply-templates select="." mode="class.attribute"/>
403         <xsl:apply-templates select="*" mode="find.chunks"/>
404       </cf:div>
405     </xsl:when>
406     <xsl:otherwise>
407       <xsl:apply-templates select="*" mode="find.chunks"/>
408     </xsl:otherwise>
409   </xsl:choose>
410 </xsl:template>
411
412 <xsl:template match="/">
413   <!-- * Get a title for current doc so that we let the user -->
414   <!-- * know what document we are processing at this point. -->
415   <xsl:variable name="doc.title">
416     <xsl:call-template name="get.doc.title"/>
417   </xsl:variable>
418   <xsl:choose>
419     <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
420          toss the namespace and continue.  Use the docbook5 namespaced
421          stylesheets for DocBook5 if you don't want to use this feature.-->
422     <xsl:when test="$exsl.node.set.available != 0 
423                     and (*/self::ng:* or */self::db:*)">
424       <xsl:call-template name="log.message">
425         <xsl:with-param name="level">Note</xsl:with-param>
426         <xsl:with-param name="source" select="$doc.title"/>
427         <xsl:with-param name="context-desc">
428           <xsl:text>namesp. cut</xsl:text>
429         </xsl:with-param>
430         <xsl:with-param name="message">
431           <xsl:text>stripped namespace before processing</xsl:text>
432         </xsl:with-param>
433       </xsl:call-template>
434       <xsl:variable name="nons">
435         <xsl:apply-templates mode="stripNS"/>
436       </xsl:variable>
437       <xsl:call-template name="log.message">
438         <xsl:with-param name="level">Note</xsl:with-param>
439         <xsl:with-param name="source" select="$doc.title"/>
440         <xsl:with-param name="context-desc">
441           <xsl:text>namesp. cut</xsl:text>
442         </xsl:with-param>
443         <xsl:with-param name="message">
444           <xsl:text>processing stripped document</xsl:text>
445         </xsl:with-param>
446       </xsl:call-template>
447       <xsl:apply-templates select="exsl:node-set($nons)"/>
448     </xsl:when>
449     <!-- Can't process unless namespace removed -->
450     <xsl:when test="*/self::ng:* or */self::db:*">
451       <xsl:message terminate="yes">
452         <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
453         <xsl:text> cannot proceed.</xsl:text>
454       </xsl:message>
455     </xsl:when>
456     <xsl:otherwise>
457       <xsl:choose>
458         <xsl:when test="$rootid != ''">
459           <xsl:choose>
460             <xsl:when test="count(key('id',$rootid)) = 0">
461               <xsl:message terminate="yes">
462                 <xsl:text>ID '</xsl:text>
463                 <xsl:value-of select="$rootid"/>
464                 <xsl:text>' not found in document.</xsl:text>
465               </xsl:message>
466             </xsl:when>
467             <xsl:otherwise>
468               <xsl:if test="$collect.xref.targets = 'yes' or
469                             $collect.xref.targets = 'only'">
470                 <xsl:apply-templates select="key('id', $rootid)"
471                                      mode="collect.targets"/>
472               </xsl:if>
473               <xsl:if test="$collect.xref.targets != 'only'">
474                 <xsl:apply-templates select="key('id',$rootid)"
475                                      mode="process.root"/>
476                 <xsl:if test="$tex.math.in.alt != ''">
477                   <xsl:apply-templates select="key('id',$rootid)"
478                                        mode="collect.tex.math"/>
479                 </xsl:if>
480                 <xsl:if test="$generate.manifest != 0">
481                   <xsl:call-template name="generate.manifest">
482                     <xsl:with-param name="node" select="key('id',$rootid)"/>
483                   </xsl:call-template>
484                 </xsl:if>
485               </xsl:if>
486             </xsl:otherwise>
487           </xsl:choose>
488         </xsl:when>
489         <xsl:otherwise>
490           <xsl:if test="$collect.xref.targets = 'yes' or
491                         $collect.xref.targets = 'only'">
492             <xsl:apply-templates select="/" mode="collect.targets"/>
493           </xsl:if>
494           <xsl:if test="$collect.xref.targets != 'only'">
495             <xsl:apply-templates select="/" mode="process.root"/>
496             <xsl:if test="$tex.math.in.alt != ''">
497               <xsl:apply-templates select="/" mode="collect.tex.math"/>
498             </xsl:if>
499             <xsl:if test="$generate.manifest != 0">
500               <xsl:call-template name="generate.manifest">
501                 <xsl:with-param name="node" select="/"/>
502               </xsl:call-template>
503             </xsl:if>
504           </xsl:if>
505         </xsl:otherwise>
506       </xsl:choose>
507     </xsl:otherwise>
508   </xsl:choose>
509 </xsl:template>
510
511 <xsl:template match="*" mode="process.root">
512   <xsl:apply-templates select="."/>
513   <xsl:call-template name="generate.css"/>
514 </xsl:template>
515
516 <!-- ====================================================================== -->
517
518 <xsl:template match="set|book|part|preface|chapter|appendix
519                      |article
520                      |reference|refentry
521                      |book/glossary|article/glossary|part/glossary
522                      |book/bibliography|article/bibliography|part/bibliography
523                      |colophon">
524   <xsl:choose>
525     <xsl:when test="$onechunk != 0 and parent::*">
526       <xsl:apply-imports/>
527     </xsl:when>
528     <xsl:otherwise>
529       <xsl:call-template name="process-chunk-element"/>
530     </xsl:otherwise>
531   </xsl:choose>
532 </xsl:template>
533
534 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
535   <xsl:variable name="ischunk">
536     <xsl:call-template name="chunk"/>
537   </xsl:variable>
538
539   <xsl:choose>
540     <xsl:when test="not(parent::*)">
541       <xsl:call-template name="process-chunk-element"/>
542     </xsl:when>
543     <xsl:when test="$ischunk = 0">
544       <xsl:apply-imports/>
545     </xsl:when>
546     <xsl:otherwise>
547       <xsl:call-template name="process-chunk-element"/>
548     </xsl:otherwise>
549   </xsl:choose>
550 </xsl:template>
551
552 <xsl:template match="setindex
553                      |book/index
554                      |article/index
555                      |part/index">
556   <!-- some implementations use completely empty index tags to indicate -->
557   <!-- where an automatically generated index should be inserted. so -->
558   <!-- if the index is completely empty, skip it. -->
559   <xsl:if test="count(*)>0 or $generate.index != '0'">
560     <xsl:call-template name="process-chunk-element"/>
561   </xsl:if>
562 </xsl:template>
563
564 <!-- Resolve xml:base attributes -->
565 <xsl:template match="@fileref">
566   <!-- need a check for absolute urls -->
567   <xsl:choose>
568     <xsl:when test="contains(., ':')">
569       <!-- it has a uri scheme so it is an absolute uri -->
570       <xsl:value-of select="."/>
571     </xsl:when>
572     <xsl:when test="$keep.relative.image.uris != 0">
573       <!-- leave it alone -->
574       <xsl:value-of select="."/>
575     </xsl:when>
576     <xsl:otherwise>
577       <!-- its a relative uri -->
578       <xsl:call-template name="relative-uri">
579         <xsl:with-param name="destdir">
580           <xsl:call-template name="dbhtml-dir">
581             <xsl:with-param name="context" select=".."/>
582           </xsl:call-template>
583         </xsl:with-param>
584       </xsl:call-template>
585     </xsl:otherwise>
586   </xsl:choose>
587 </xsl:template>
588
589 <!-- ==================================================================== -->
590 <xsl:template match="set|book|part|preface|chapter|appendix
591                      |article
592                      |reference|refentry
593                      |sect1|sect2|sect3|sect4|sect5
594                      |section
595                      |book/glossary|article/glossary|part/glossary
596                      |book/bibliography|article/bibliography|part/bibliography
597                      |colophon"
598               mode="enumerate-files">
599   <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
600   <xsl:if test="$ischunk='1'">
601     <xsl:call-template name="make-relative-filename">
602       <xsl:with-param name="base.dir">
603         <xsl:if test="$manifest.in.base.dir = 0">
604           <xsl:value-of select="$base.dir"/>
605         </xsl:if>
606       </xsl:with-param>
607       <xsl:with-param name="base.name">
608         <xsl:apply-templates mode="chunk-filename" select="."/>
609       </xsl:with-param>
610     </xsl:call-template>
611     <xsl:text>&#10;</xsl:text>
612   </xsl:if>
613   <xsl:apply-templates select="*" mode="enumerate-files"/>
614 </xsl:template>
615
616 <xsl:template match="book/index|article/index|part/index"
617               mode="enumerate-files">
618   <xsl:if test="$htmlhelp.output != 1">
619     <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
620     <xsl:if test="$ischunk='1'">
621       <xsl:call-template name="make-relative-filename">
622         <xsl:with-param name="base.dir">
623           <xsl:if test="$manifest.in.base.dir = 0">
624             <xsl:value-of select="$base.dir"/>
625           </xsl:if>
626         </xsl:with-param>
627         <xsl:with-param name="base.name">
628           <xsl:apply-templates mode="chunk-filename" select="."/>
629         </xsl:with-param>
630       </xsl:call-template>
631       <xsl:text>&#10;</xsl:text>
632     </xsl:if>
633     <xsl:apply-templates select="*" mode="enumerate-files"/>
634   </xsl:if>
635 </xsl:template>
636
637 <xsl:template match="legalnotice" mode="enumerate-files">
638   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
639   <xsl:if test="$generate.legalnotice.link != 0">
640     <xsl:call-template name="make-relative-filename">
641       <xsl:with-param name="base.dir">
642         <xsl:if test="$manifest.in.base.dir = 0">
643           <xsl:value-of select="$base.dir"/>
644         </xsl:if>
645       </xsl:with-param>
646       <xsl:with-param name="base.name">
647         <xsl:apply-templates mode="chunk-filename" select="."/>
648       </xsl:with-param>
649     </xsl:call-template>
650     <xsl:text>&#10;</xsl:text>
651   </xsl:if>
652 </xsl:template>
653
654 <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
655   <xsl:variable name="longdesc.uri">
656     <xsl:call-template name="longdesc.uri">
657       <xsl:with-param name="mediaobject"
658                       select="."/>
659     </xsl:call-template>
660   </xsl:variable>
661   <xsl:variable name="mediaobject" select="."/>
662
663   <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
664     <xsl:call-template name="longdesc.uri">
665       <xsl:with-param name="mediaobject" select="$mediaobject"/>
666     </xsl:call-template>
667     <xsl:text>&#10;</xsl:text>
668   </xsl:if>
669 </xsl:template>
670
671 <xsl:template match="text()" mode="enumerate-files">
672 </xsl:template>
673
674 </xsl:stylesheet>