~ubuntu-branches/ubuntu/vivid/yelp-xsl/vivid-proposed

« back to all changes in this revision

Viewing changes to xslt/docbook/common/db-chunk.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-11-29 10:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20101129100013-1fxze8fm1fegxl8w
Tags: upstream-2.31.6
ImportĀ upstreamĀ versionĀ 2.31.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
 
2
<!--
 
3
This program is free software; you can redistribute it and/or modify it under
 
4
the terms of the GNU Lesser General Public License as published by the Free
 
5
Software Foundation; either version 2 of the License, or (at your option) any
 
6
later version.
 
7
 
 
8
This program is distributed in the hope that it will be useful, but WITHOUT
 
9
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
10
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 
11
details.
 
12
 
 
13
You should have received a copy of the GNU Lesser General Public License
 
14
along with this program; see the file COPYING.LGPL.  If not, write to the
 
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
16
02111-1307, USA.
 
17
-->
 
18
 
 
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
20
                xmlns:exsl="http://exslt.org/common"
 
21
                xmlns:set="http://exslt.org/sets"
 
22
                xmlns:db="http://docbook.org/ns/docbook"
 
23
                extension-element-prefixes="exsl"
 
24
                exclude-result-prefixes="db set"
 
25
                version="1.0">
 
26
 
 
27
<!--!!==========================================================================
 
28
DocBook Chunking
 
29
 
 
30
REMARK: Describe this module
 
31
-->
 
32
 
 
33
 
 
34
<!--@@==========================================================================
 
35
db.chunk.chunks
 
36
A space-seperated list of the names of elements that should be chunked
 
37
 
 
38
REMARK: This parameter sucks
 
39
-->
 
40
<xsl:param name="db.chunk.chunks" select="
 
41
           'appendix    article     bibliography  bibliodiv  book    chapter
 
42
            colophon    dedication  glossary      glossdiv   index
 
43
            lot         part        preface       refentry   reference
 
44
            sect1       sect2       sect3         sect4      sect5
 
45
            section     setindex    simplesect    toc'"/>
 
46
<xsl:variable name="db.chunk.chunks_" select="concat(' ', $db.chunk.chunks, ' ')"/>
 
47
 
 
48
 
 
49
<!--@@==========================================================================
 
50
db.chunk.chunk_top
 
51
Whether the top-level chunk should be output with the chunking mechanism
 
52
 
 
53
REMARK: Describe what this does
 
54
-->
 
55
<xsl:param name="db.chunk.chunk_top" select="false()"/>
 
56
 
 
57
 
 
58
<!--@@==========================================================================
 
59
db.chunk.max_depth
 
60
The maximum depth for chunking sections
 
61
 
 
62
REMARK: Describe what this does
 
63
-->
 
64
<xsl:param name="db.chunk.max_depth">
 
65
  <xsl:choose>
 
66
    <xsl:when test="number(processing-instruction('db.chunk.max_depth'))">
 
67
      <xsl:value-of
 
68
       select="number(processing-instruction('db.chunk.max_depth'))"/>
 
69
    </xsl:when>
 
70
    <xsl:when test="/book | /db:book">
 
71
      <xsl:value-of select="2"/>
 
72
    </xsl:when>
 
73
    <xsl:otherwise>
 
74
      <xsl:value-of select="1"/>
 
75
    </xsl:otherwise>
 
76
  </xsl:choose>
 
77
</xsl:param>
 
78
 
 
79
 
 
80
<!--@@==========================================================================
 
81
db.chunk.basename
 
82
The base filename of the output file, without an extension
 
83
 
 
84
REMARK: Describe what this does
 
85
-->
 
86
<xsl:param name="db.chunk.basename" select="/*/@id | /*/@xml:id"/>
 
87
 
 
88
 
 
89
<!--@@==========================================================================
 
90
db.chunk.extension
 
91
The default file extension for new output documents
 
92
 
 
93
REMARK: Describe what this does
 
94
-->
 
95
<xsl:param name="db.chunk.extension"/>
 
96
 
 
97
 
 
98
<!--@@==========================================================================
 
99
db.chunk.info_chunk
 
100
Whether to create a chunk for the title page
 
101
 
 
102
REMARK: Describe what this does
 
103
-->
 
104
<xsl:param name="db.chunk.info_chunk" select="$db.chunk.max_depth != 0"/>
 
105
 
 
106
 
 
107
<!--@@==========================================================================
 
108
db.chunk.info_basename
 
109
The base filename for the title page
 
110
 
 
111
REMARK: Describe what this does
 
112
-->
 
113
<xsl:param name="db.chunk.info_basename">
 
114
  <xsl:choose>
 
115
    <xsl:when test="$db.chunk.basename">
 
116
      <xsl:value-of select="concat($db.chunk.basename, '-info')"/>
 
117
    </xsl:when>
 
118
    <xsl:otherwise>info</xsl:otherwise>
 
119
  </xsl:choose>
 
120
</xsl:param>
 
121
 
 
122
 
 
123
<!--@@==========================================================================
 
124
db.chunk.doctype_public
 
125
The public DOCTYPE for output files
 
126
 
 
127
REMARK: Describe this
 
128
-->
 
129
<xsl:param name="db.chunk.doctype_public"/>
 
130
 
 
131
 
 
132
<!--@@==========================================================================
 
133
db.chunk.doctype_system
 
134
The system DOCTYPE for output files
 
135
 
 
136
REMARK: Describe this
 
137
-->
 
138
<xsl:param name="db.chunk.doctype_system"/>
 
139
 
 
140
 
 
141
<!--**==========================================================================
 
142
db.chunk
 
143
Creates a new page of output
 
144
$node: The source element for the output page
 
145
$template: The named template to call to create the page
 
146
$href: The name of the file for the output page
 
147
$depth_of_chunk: The depth of this chunk in the document
 
148
 
 
149
REMARK: We need a lot more explanation about chunk flow
 
150
 
 
151
The *{db.chunk} template creates a new output document using the #{exsl:document}
 
152
extension element.  This template calls *{db.chunk.content} to create the content
 
153
of the document, passing through all parameters.  This allows you to override the
 
154
chunking mechanism without having to duplicate the content-generation code.
 
155
-->
 
156
<xsl:template name="db.chunk">
 
157
  <xsl:param name="node" select="."/>
 
158
  <xsl:param name="template"/>
 
159
  <xsl:param name="href">
 
160
    <xsl:choose>
 
161
      <xsl:when test="$template = 'info'">
 
162
        <xsl:value-of select="$db.chunk.info_basename"/>
 
163
      </xsl:when>
 
164
      <xsl:otherwise>
 
165
        <xsl:call-template name="db.chunk.chunk-id">
 
166
          <xsl:with-param name="node" select="$node"/>
 
167
          <xsl:with-param name="depth_in_chunk" select="0"/>
 
168
          <xsl:with-param name="chunk" select="$node"/>
 
169
        </xsl:call-template>
 
170
      </xsl:otherwise>
 
171
    </xsl:choose>
 
172
    <xsl:value-of select="$db.chunk.extension"/>
 
173
  </xsl:param>
 
174
  <xsl:param name="depth_of_chunk">
 
175
    <xsl:call-template name="db.chunk.depth-of-chunk">
 
176
      <xsl:with-param name="node" select="$node"/>
 
177
    </xsl:call-template>
 
178
  </xsl:param>
 
179
  <exsl:document href="{$href}"
 
180
                 doctype-public="{$db.chunk.doctype_public}"
 
181
                 doctype-system="{$db.chunk.doctype_system}">
 
182
    <xsl:call-template name="db.chunk.content">
 
183
      <xsl:with-param name="node" select="$node"/>
 
184
      <xsl:with-param name="template" select="$template"/>
 
185
      <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
186
    </xsl:call-template>
 
187
  </exsl:document>
 
188
  <!-- DONE
 
189
  <xsl:if test="string($template) = ''">
 
190
    <xsl:call-template name="db.chunk.children">
 
191
      <xsl:with-param name="node" select="$node"/>
 
192
      <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
193
    </xsl:call-template>
 
194
  </xsl:if>
 
195
  -->
 
196
</xsl:template>
 
197
 
 
198
 
 
199
<!--**==========================================================================
 
200
db.chunk.content
 
201
Creates the content of a new page of output
 
202
$node: The source element for the output page
 
203
$template: The named template to call to create the page
 
204
$depth_of_chunk: The depth of this chunk in the document
 
205
 
 
206
REMARK: We need a lot more explanation about chunk flow
 
207
 
 
208
The *{db.chunk.content} template creates the actual content of a new output page.
 
209
It should generally only be called by *{db.chunk}.
 
210
 
 
211
This template will always pass the ${depth_in_chunk} and ${depth_of_chunk}
 
212
parameters with appropriate values to the templates it calls.
 
213
-->
 
214
<xsl:template name="db.chunk.content">
 
215
  <xsl:param name="node" select="."/>
 
216
  <xsl:param name="template"/>
 
217
  <xsl:param name="depth_of_chunk">
 
218
    <xsl:call-template name="db.chunk.depth-of-chunk">
 
219
      <xsl:with-param name="node" select="$node"/>
 
220
    </xsl:call-template>
 
221
  </xsl:param>
 
222
  <xsl:choose>
 
223
    <xsl:when test="$template = 'info'">
 
224
      <xsl:apply-templates mode="db.chunk.info.content.mode" select="$node">
 
225
        <xsl:with-param name="depth_in_chunk" select="0"/>
 
226
        <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
227
      </xsl:apply-templates>
 
228
    </xsl:when>
 
229
    <xsl:otherwise>
 
230
      <xsl:apply-templates mode="db.chunk.content.mode" select="$node">
 
231
        <xsl:with-param name="depth_in_chunk" select="0"/>
 
232
        <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
233
      </xsl:apply-templates>
 
234
    </xsl:otherwise>
 
235
  </xsl:choose>
 
236
</xsl:template>
 
237
 
 
238
 
 
239
 
 
240
<!--**==========================================================================
 
241
db.chunk.depth-in-chunk
 
242
Determines the depth of an element in the containing chunk
 
243
$node: The element to determine the depth of
 
244
 
 
245
REMARK: Explain how this works
 
246
-->
 
247
<xsl:template name="db.chunk.depth-in-chunk">
 
248
  <xsl:param name="node" select="."/>
 
249
  <xsl:variable name="divs"
 
250
                select="
 
251
                        count($node/ancestor-or-self::appendix        ) + 
 
252
                        count($node/ancestor-or-self::article         ) + 
 
253
                        count($node/ancestor-or-self::bibliography    ) + 
 
254
                        count($node/ancestor-or-self::bibliodiv       ) +
 
255
                        count($node/ancestor-or-self::book            ) + 
 
256
                        count($node/ancestor-or-self::chapter         ) + 
 
257
                        count($node/ancestor-or-self::colophon        ) + 
 
258
                        count($node/ancestor-or-self::dedication      ) + 
 
259
                        count($node/ancestor-or-self::glossary        ) + 
 
260
                        count($node/ancestor-or-self::glossdiv        ) + 
 
261
                        count($node/ancestor-or-self::index           ) + 
 
262
                        count($node/ancestor-or-self::lot             ) + 
 
263
                        count($node/ancestor-or-self::part            ) + 
 
264
                        count($node/ancestor-or-self::preface         ) + 
 
265
                        count($node/ancestor-or-self::refentry        ) + 
 
266
                        count($node/ancestor-or-self::reference       ) + 
 
267
                        count($node/ancestor-or-self::sect1           ) + 
 
268
                        count($node/ancestor-or-self::sect2           ) + 
 
269
                        count($node/ancestor-or-self::sect3           ) + 
 
270
                        count($node/ancestor-or-self::sect4           ) + 
 
271
                        count($node/ancestor-or-self::sect5           ) + 
 
272
                        count($node/ancestor-or-self::section         ) + 
 
273
                        count($node/ancestor-or-self::setindex        ) + 
 
274
                        count($node/ancestor-or-self::simplesect      ) + 
 
275
                        count($node/ancestor-or-self::toc             ) +
 
276
                        count($node/ancestor-or-self::db:appendix     ) + 
 
277
                        count($node/ancestor-or-self::db:article      ) + 
 
278
                        count($node/ancestor-or-self::db:bibliography ) + 
 
279
                        count($node/ancestor-or-self::db:bibliodiv    ) +
 
280
                        count($node/ancestor-or-self::db:book         ) + 
 
281
                        count($node/ancestor-or-self::db:chapter      ) + 
 
282
                        count($node/ancestor-or-self::db:colophon     ) + 
 
283
                        count($node/ancestor-or-self::db:dedication   ) + 
 
284
                        count($node/ancestor-or-self::db:glossary     ) + 
 
285
                        count($node/ancestor-or-self::db:glossdiv     ) + 
 
286
                        count($node/ancestor-or-self::db:index        ) + 
 
287
                        count($node/ancestor-or-self::db:lot          ) + 
 
288
                        count($node/ancestor-or-self::db:part         ) + 
 
289
                        count($node/ancestor-or-self::db:preface      ) + 
 
290
                        count($node/ancestor-or-self::db:refentry     ) + 
 
291
                        count($node/ancestor-or-self::db:reference    ) + 
 
292
                        count($node/ancestor-or-self::db:sect1        ) + 
 
293
                        count($node/ancestor-or-self::db:sect2        ) + 
 
294
                        count($node/ancestor-or-self::db:sect3        ) + 
 
295
                        count($node/ancestor-or-self::db:sect4        ) + 
 
296
                        count($node/ancestor-or-self::db:sect5        ) + 
 
297
                        count($node/ancestor-or-self::db:section      ) + 
 
298
                        count($node/ancestor-or-self::db:setindex     ) + 
 
299
                        count($node/ancestor-or-self::db:simplesect   ) + 
 
300
                        count($node/ancestor-or-self::db:toc          )"/>
 
301
  <xsl:choose>
 
302
    <xsl:when test="$divs &lt; ($db.chunk.max_depth + 1)">
 
303
      <xsl:value-of select="count($node/ancestor-or-self::*) - $divs"/>
 
304
    </xsl:when>
 
305
    <xsl:otherwise>
 
306
      <xsl:value-of select="count($node/ancestor::*) - $db.chunk.max_depth"/>
 
307
    </xsl:otherwise>
 
308
  </xsl:choose>
 
309
</xsl:template>
 
310
 
 
311
 
 
312
<!--**==========================================================================
 
313
db.chunk.depth-of-chunk
 
314
Determines the depth of teh containing chunk in the document
 
315
$node: The element to determine the depth of
 
316
 
 
317
REMARK: Explain how this works
 
318
-->
 
319
<xsl:template name="db.chunk.depth-of-chunk">
 
320
  <xsl:param name="node" select="."/>
 
321
  <xsl:variable name="divs"
 
322
                select="$node/ancestor-or-self::*
 
323
                         [contains($db.chunk.chunks_,
 
324
                            concat(' ', local-name(.), ' '))]"/>
 
325
  <xsl:choose>
 
326
    <xsl:when test="count($divs) - 1 &lt; $db.chunk.max_depth">
 
327
      <xsl:value-of select="count($divs) - 1"/>
 
328
    </xsl:when>
 
329
    <xsl:otherwise>
 
330
      <xsl:value-of select="$db.chunk.max_depth"/>
 
331
    </xsl:otherwise>
 
332
  </xsl:choose>
 
333
</xsl:template>
 
334
 
 
335
 
 
336
<!--**==========================================================================
 
337
db.chunk.chunk-id
 
338
Determines the id of the chunk that contains an element
 
339
$id: The id of the element to determine the chunk id of
 
340
$node: The element to determine the chunk id of
 
341
$depth_in_chunk: The depth of ${node} in the containing chunk
 
342
 
 
343
REMARK: Explain how this works
 
344
-->
 
345
<xsl:template name="db.chunk.chunk-id">
 
346
  <xsl:param name="id" select="@id | @xml:id"/>
 
347
  <xsl:param name="node" select="key('idkey', $id)"/>
 
348
  <xsl:param name="depth_in_chunk">
 
349
    <xsl:call-template name="db.chunk.depth-in-chunk">
 
350
      <xsl:with-param name="node" select="$node"/>
 
351
    </xsl:call-template>
 
352
  </xsl:param>
 
353
  <xsl:param name="chunk" select="$node/ancestor-or-self::*[$depth_in_chunk + 1]"/>
 
354
  <xsl:choose>
 
355
    <xsl:when test="set:has-same-node($chunk, /*)">
 
356
      <xsl:value-of select="$db.chunk.basename"/>
 
357
    </xsl:when>
 
358
    <xsl:when test="$chunk/@id">
 
359
      <xsl:value-of select="string($chunk/@id)"/>
 
360
    </xsl:when>
 
361
    <xsl:when test="$chunk/@xml:id">
 
362
      <xsl:value-of select="string($chunk/@xml:id)"/>
 
363
    </xsl:when>
 
364
    <xsl:otherwise>
 
365
      <xsl:value-of select="generate-id($chunk)"/>
 
366
    </xsl:otherwise>
 
367
  </xsl:choose>
 
368
</xsl:template>
 
369
 
 
370
 
 
371
<!--**==========================================================================
 
372
db.chunk.chunk-id.axis
 
373
Determines the id of the first chunk along a specified axis
 
374
$node: The base element
 
375
$node: The axis along which to find the first chunk
 
376
$depth_in_chunk: The depth of ${node} in the containing chunk
 
377
$depth_of_chunk: The depth of the containing chunk in the document
 
378
 
 
379
REMARK: Explain how this works, and what the axes are
 
380
-->
 
381
<xsl:template name="db.chunk.chunk-id.axis">
 
382
  <xsl:param name="node" select="."/>
 
383
  <xsl:param name="axis"/>
 
384
  <xsl:param name="depth_in_chunk">
 
385
    <xsl:call-template name="db.chunk.depth-in-chunk">
 
386
      <xsl:with-param name="node" select="$node"/>
 
387
    </xsl:call-template>
 
388
  </xsl:param>
 
389
  <xsl:param name="depth_of_chunk">
 
390
    <xsl:call-template name="db.chunk.depth-of-chunk">
 
391
      <xsl:with-param name="node" select="$node"/>
 
392
    </xsl:call-template>
 
393
  </xsl:param>
 
394
  <xsl:choose>
 
395
    <xsl:when test="depth_in_chunk != 0">
 
396
      <xsl:call-template name="db.chunk.chunk-id.axis">
 
397
        <xsl:with-param name="node" select="$node/ancestor::*[$depth_in_chunk]"/>
 
398
        <xsl:with-param name="axis" select="$axis"/>
 
399
        <xsl:with-param name="depth_in_chunk" select="0"/>
 
400
        <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
401
      </xsl:call-template>
 
402
    </xsl:when>
 
403
    <!-- following -->
 
404
    <xsl:when test="$axis = 'following'">
 
405
      <xsl:variable name="divs"
 
406
                    select="$node/following-sibling::*
 
407
                             [contains($db.chunk.chunks_,
 
408
                                concat(' ', local-name(.), ' '))]"/>
 
409
      <xsl:choose>
 
410
        <xsl:when test="$divs">
 
411
          <xsl:call-template name="db.chunk.chunk-id">
 
412
            <xsl:with-param name="node" select="$divs[1]"/>
 
413
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
414
            <xsl:with-param name="chunk" select="$divs[1]"/>
 
415
          </xsl:call-template>
 
416
        </xsl:when>
 
417
        <xsl:when test="$node/..">
 
418
          <xsl:call-template name="db.chunk.chunk-id.axis">
 
419
            <xsl:with-param name="node" select="$node/.."/>
 
420
            <xsl:with-param name="axis" select="'following'"/>
 
421
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
422
            <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk - 1"/>
 
423
          </xsl:call-template>
 
424
        </xsl:when>
 
425
      </xsl:choose>
 
426
    </xsl:when>
 
427
    <!-- last-descendant -->
 
428
    <xsl:when test="$axis = 'last-descendant'">
 
429
      <xsl:variable name="divs"
 
430
                    select="$node/*[contains($db.chunk.chunks_,
 
431
                                      concat(' ', local-name(.), ' '))]"/>
 
432
      <xsl:choose>
 
433
        <xsl:when test="($depth_of_chunk &gt;= $db.chunk.max_depth)">
 
434
          <xsl:call-template name="db.chunk.chunk-id">
 
435
            <xsl:with-param name="node" select="$node"/>
 
436
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
437
            <xsl:with-param name="chunk" select="$node"/>
 
438
          </xsl:call-template>
 
439
        </xsl:when>
 
440
        <xsl:when test="($depth_of_chunk + 1 = $db.chunk.max_depth) and $divs">
 
441
          <xsl:call-template name="db.chunk.chunk-id">
 
442
            <xsl:with-param name="node" select="$divs[last()]"/>
 
443
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
444
            <xsl:with-param name="chunk" select="$divs[last()]"/>
 
445
          </xsl:call-template>
 
446
        </xsl:when>
 
447
        <xsl:when test="$divs">
 
448
          <xsl:call-template name="db.chunk.chunk-id.axis">
 
449
            <xsl:with-param name="node" select="$divs[last()]"/>
 
450
            <xsl:with-param name="axis" select="'last-descendant'"/>
 
451
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
452
            <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk + 1"/>
 
453
          </xsl:call-template>
 
454
        </xsl:when>
 
455
        <xsl:otherwise>
 
456
          <xsl:call-template name="db.chunk.chunk-id">
 
457
            <xsl:with-param name="node" select="$node"/>
 
458
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
459
            <xsl:with-param name="chunk" select="$node"/>
 
460
          </xsl:call-template>
 
461
        </xsl:otherwise>
 
462
      </xsl:choose>
 
463
    </xsl:when>
 
464
    <!-- next -->
 
465
    <xsl:when test="$axis = 'next'">
 
466
      <xsl:variable name="divs"
 
467
                    select="$node/*[contains($db.chunk.chunks_,
 
468
                                      concat(' ', local-name(.), ' '))]"/>
 
469
      <xsl:choose>
 
470
        <xsl:when test="($depth_of_chunk &lt; $db.chunk.max_depth) and $divs">
 
471
          <xsl:call-template name="db.chunk.chunk-id">
 
472
            <xsl:with-param name="node" select="$divs[1]"/>
 
473
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
474
            <xsl:with-param name="chunk" select="$divs[1]"/>
 
475
          </xsl:call-template>
 
476
        </xsl:when>
 
477
        <xsl:otherwise>
 
478
          <xsl:call-template name="db.chunk.chunk-id.axis">
 
479
            <xsl:with-param name="node" select="$node"/>
 
480
            <xsl:with-param name="axis" select="'following'"/>
 
481
            <xsl:with-param name="depth_in_chunk" select="$depth_in_chunk"/>
 
482
            <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
483
          </xsl:call-template>
 
484
        </xsl:otherwise>
 
485
      </xsl:choose>
 
486
    </xsl:when>
 
487
    <!-- previous -->
 
488
    <xsl:when test="$axis = 'previous'">
 
489
      <xsl:variable name="divs"
 
490
                    select="$node/preceding-sibling::*
 
491
                             [contains($db.chunk.chunks_,
 
492
                                concat(' ', local-name(.), ' '))]"/>
 
493
      <xsl:choose>
 
494
        <xsl:when test="$divs and ($depth_of_chunk &lt; $db.chunk.max_depth)">
 
495
          <xsl:call-template name="db.chunk.chunk-id.axis">
 
496
            <xsl:with-param name="node" select="$divs[last()]"/>
 
497
            <xsl:with-param name="axis" select="'last-descendant'"/>
 
498
            <xsl:with-param name="depth_in_chunk" select="$depth_in_chunk"/>
 
499
            <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
 
500
          </xsl:call-template>
 
501
        </xsl:when>
 
502
        <xsl:when test="$divs">
 
503
          <xsl:call-template name="db.chunk.chunk-id">
 
504
            <xsl:with-param name="node" select="$divs[last()]"/>
 
505
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
506
            <xsl:with-param name="chunk" select="$divs[last()]"/>
 
507
          </xsl:call-template>
 
508
        </xsl:when>
 
509
        <xsl:when test="$node/..">
 
510
          <xsl:call-template name="db.chunk.chunk-id">
 
511
            <xsl:with-param name="node" select="$node"/>
 
512
            <xsl:with-param name="depth_in_chunk" select="0"/>
 
513
            <xsl:with-param name="chunk" select="$node"/>
 
514
          </xsl:call-template>
 
515
        </xsl:when>
 
516
      </xsl:choose>
 
517
    </xsl:when>
 
518
    <!-- unsupported -->
 
519
    <xsl:otherwise>
 
520
      <xsl:message>
 
521
        <xsl:text>Unsupported axis: </xsl:text>
 
522
        <xsl:value-of select="$axis"/>
 
523
      </xsl:message>
 
524
    </xsl:otherwise>
 
525
  </xsl:choose>
 
526
</xsl:template>
 
527
 
 
528
 
 
529
<!--%%==========================================================================
 
530
db.chunk.info.content.mode
 
531
Renders the contents of the title page
 
532
$depth_in_chunk: The depth of the element in the containing chunk
 
533
$depth_of_chunk: The depth of the containing chunk in the document
 
534
 
 
535
When processed in this mode, a division element should output the top-level
 
536
markup for the output page.
 
537
-->
 
538
<xsl:template mode="db.chunk.info.content.mode" match="*"/>
 
539
 
 
540
 
 
541
<!--%%==========================================================================
 
542
db.chunk.content.mode
 
543
Renders the entire contents of the chunk
 
544
$depth_in_chunk: The depth of the element in the containing chunk
 
545
$depth_of_chunk: The depth of the containing chunk in the document
 
546
 
 
547
When processed in this mode, a division element should output the top-level
 
548
markup for the output page.
 
549
-->
 
550
<xsl:template mode="db.chunk.content.mode" match="*"/>
 
551
 
 
552
 
 
553
<!-- == Matched Templates == -->
 
554
 
 
555
<xsl:template match="/false">
 
556
  <xsl:choose>
 
557
    <xsl:when test="$db.chunk.chunk_top">
 
558
      <xsl:call-template name="db.chunk">
 
559
        <xsl:with-param name="node" select="*[1]"/>
 
560
        <xsl:with-param name="depth_of_chunk" select="0"/>
 
561
      </xsl:call-template>
 
562
    </xsl:when>
 
563
    <xsl:otherwise>
 
564
      <xsl:apply-templates mode="db.chunk.content.mode" select="*">
 
565
        <xsl:with-param name="depth_in_chunk" select="0"/>
 
566
        <xsl:with-param name="depth_of_chunk" select="0"/>
 
567
      </xsl:apply-templates>
 
568
      <!-- DONE
 
569
      <xsl:call-template name="db.chunk.children">
 
570
        <xsl:with-param name="node" select="*[1]"/>
 
571
        <xsl:with-param name="depth_of_chunk" select="0"/>
 
572
      </xsl:call-template>
 
573
      -->
 
574
    </xsl:otherwise>
 
575
  </xsl:choose>
 
576
</xsl:template>
 
577
 
 
578
</xsl:stylesheet>