~ubuntu-branches/ubuntu/natty/kde4libs/natty-proposed

« back to all changes in this revision

Viewing changes to kdoctools/docbook/xsl/html/profile-chunk-code.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Jonathan Riddell, Scott Kitterman
  • Date: 2011-01-21 11:32:24 UTC
  • mfrom: (1.14.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110121113224-c9tebdkklj5u3awu
Tags: 4:4.6.0-0ubuntu1~ppa1
[ Jonathan Riddell ]
* New upstream release
* Reluctantly add kcm_ssl to kdelibs5-plugins, this should be in kdebase

[ Scott Kitterman ]
* Update libkatepartinterfaces4.symbols and libkdecore5.symbols for 4.5.95
  and confirm symbols on all architectures with pkgkde-symbolshelper
  - Thanks to Jonathan Thomas for verifying the missing symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="US-ASCII"?>
2
 
<!--This file was created automatically by xsl2profile-->
3
 
<!--from the DocBook XSL stylesheets. Do not edit this file.-->
4
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" exslt:dummy="dummy" extension-element-prefixes="exslt" version="1.0" exclude-result-prefixes="exsl exslt">
5
 
 
6
 
<!-- ********************************************************************
7
 
     $Id: profile-chunk-code.xsl 922431 2009-02-07 01:12:28Z schwarzer $
8
 
     ********************************************************************
9
 
 
10
 
     This file is part of the XSL DocBook Stylesheet distribution.
11
 
     See ../README or http://nwalsh.com/docbook/xsl/ for copyright
12
 
     and other information.
13
 
 
14
 
     ******************************************************************** -->
15
 
 
16
 
<!-- ==================================================================== -->
17
 
 
18
 
<xsl:param name="onechunk" select="0"/>
19
 
<xsl:param name="refentry.separator" select="0"/>
20
 
<xsl:param name="chunk.fast" select="0"/>
21
 
 
22
 
<xsl:key name="genid" match="*" use="generate-id()"/>
23
 
 
24
 
<!-- ==================================================================== -->
25
 
 
26
 
<xsl:variable name="chunk.hierarchy">
27
 
  <xsl:if test="$chunk.fast != 0">
28
 
    <xsl:choose>
29
 
      <xsl:when test="function-available('exsl:node-set')">
30
 
        <xsl:message>Computing chunks...</xsl:message>
31
 
        <xsl:apply-templates select="/*" mode="find.chunks"/>
32
 
      </xsl:when>
33
 
      <xsl:otherwise>
34
 
        <xsl:message>
35
 
          <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
36
 
          <xsl:text>Using "slow" chunking.</xsl:text>
37
 
        </xsl:message>
38
 
      </xsl:otherwise>
39
 
    </xsl:choose>
40
 
  </xsl:if>
41
 
</xsl:variable>
42
 
 
43
 
<xsl:template match="*" mode="find.chunks">
44
 
  <xsl:variable name="chunk">
45
 
    <xsl:call-template name="chunk"/>
46
 
  </xsl:variable>
47
 
 
48
 
  <xsl:choose>
49
 
    <xsl:when test="$chunk != 0">
50
 
      <div class="{local-name(.)}" id="{generate-id()}">
51
 
        <xsl:apply-templates select="*" mode="find.chunks"/>
52
 
      </div>
53
 
    </xsl:when>
54
 
    <xsl:otherwise>
55
 
      <xsl:apply-templates select="*" mode="find.chunks"/>
56
 
    </xsl:otherwise>
57
 
  </xsl:choose>
58
 
</xsl:template>
59
 
 
60
 
<!-- ==================================================================== -->
61
 
 
62
 
<xsl:template name="process-chunk-element">
63
 
  <xsl:param name="content">
64
 
    <xsl:apply-imports/>
65
 
  </xsl:param>
66
 
 
67
 
  <xsl:choose>
68
 
    <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
69
 
      <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//div"/>
70
 
      <xsl:variable name="genid" select="generate-id()"/>
71
 
 
72
 
      <xsl:variable name="div" select="$chunks[@id=$genid]"/>
73
 
 
74
 
      <xsl:variable name="prevdiv" select="($div/preceding-sibling::div|$div/preceding::div|$div/parent::div)[last()]"/>
75
 
      <xsl:variable name="prev" select="key('genid', $prevdiv/@id)"/>
76
 
 
77
 
      <xsl:variable name="nextdiv" select="($div/following-sibling::div|$div/following::div|$div/div)[1]"/>
78
 
      <xsl:variable name="next" select="key('genid', $nextdiv/@id)"/>
79
 
 
80
 
      <xsl:choose>
81
 
        <xsl:when test="$onechunk != 0 and parent::*">
82
 
          <xsl:copy-of select="$content"/>
83
 
        </xsl:when>
84
 
        <xsl:otherwise>
85
 
          <xsl:call-template name="process-chunk">
86
 
            <xsl:with-param name="prev" select="$prev"/>
87
 
            <xsl:with-param name="next" select="$next"/>
88
 
            <xsl:with-param name="content" select="$content"/>
89
 
          </xsl:call-template>
90
 
        </xsl:otherwise>
91
 
      </xsl:choose>
92
 
    </xsl:when>
93
 
    <xsl:otherwise>
94
 
      <xsl:choose>
95
 
        <xsl:when test="$onechunk != 0 and not(parent::*)">
96
 
          <xsl:call-template name="chunk-all-sections">
97
 
            <xsl:with-param name="content" select="$content"/>
98
 
          </xsl:call-template>
99
 
        </xsl:when>
100
 
        <xsl:when test="$onechunk != 0">
101
 
          <xsl:copy-of select="$content"/>
102
 
        </xsl:when>
103
 
        <xsl:when test="$chunk.first.sections = 0">
104
 
          <xsl:call-template name="chunk-first-section-with-parent">
105
 
            <xsl:with-param name="content" select="$content"/>
106
 
          </xsl:call-template>
107
 
        </xsl:when>
108
 
        <xsl:otherwise>
109
 
          <xsl:call-template name="chunk-all-sections">
110
 
            <xsl:with-param name="content" select="$content"/>
111
 
          </xsl:call-template>
112
 
        </xsl:otherwise>
113
 
      </xsl:choose>
114
 
    </xsl:otherwise>
115
 
  </xsl:choose>
116
 
</xsl:template>
117
 
 
118
 
<xsl:template name="process-chunk">
119
 
  <xsl:param name="prev" select="."/>
120
 
  <xsl:param name="next" select="."/>
121
 
  <xsl:param name="content">
122
 
    <xsl:apply-imports/>
123
 
  </xsl:param>
124
 
 
125
 
  <xsl:variable name="ischunk">
126
 
    <xsl:call-template name="chunk"/>
127
 
  </xsl:variable>
128
 
 
129
 
  <xsl:variable name="chunkfn">
130
 
    <xsl:if test="$ischunk='1'">
131
 
      <xsl:apply-templates mode="chunk-filename" select="."/>
132
 
    </xsl:if>
133
 
  </xsl:variable>
134
 
 
135
 
  <xsl:if test="$ischunk='0'">
136
 
    <xsl:message>
137
 
      <xsl:text>Error </xsl:text>
138
 
      <xsl:value-of select="name(.)"/>
139
 
      <xsl:text> is not a chunk!</xsl:text>
140
 
    </xsl:message>
141
 
  </xsl:if>
142
 
 
143
 
  <xsl:variable name="filename">
144
 
    <xsl:call-template name="make-relative-filename">
145
 
      <xsl:with-param name="base.dir" select="$base.dir"/>
146
 
      <xsl:with-param name="base.name" select="$chunkfn"/>
147
 
    </xsl:call-template>
148
 
  </xsl:variable>
149
 
 
150
 
  <xsl:call-template name="write.chunk">
151
 
    <xsl:with-param name="filename" select="$filename"/>
152
 
    <xsl:with-param name="content">
153
 
      <xsl:call-template name="chunk-element-content">
154
 
        <xsl:with-param name="prev" select="$prev"/>
155
 
        <xsl:with-param name="next" select="$next"/>
156
 
        <xsl:with-param name="content" select="$content"/>
157
 
      </xsl:call-template>
158
 
    </xsl:with-param>
159
 
    <xsl:with-param name="quiet" select="$chunk.quietly"/>
160
 
  </xsl:call-template>
161
 
</xsl:template>
162
 
 
163
 
<xsl:template name="chunk-first-section-with-parent">
164
 
  <xsl:param name="content">
165
 
    <xsl:apply-imports/>
166
 
  </xsl:param>
167
 
 
168
 
  <!-- These xpath expressions are really hairy. The trick is to pick sections -->
169
 
  <!-- that are not first children and are not the children of first children -->
170
 
 
171
 
  <!-- Break these variables into pieces to work around
172
 
       http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
173
 
 
174
 
  <xsl:variable name="prev-v1" select="(ancestor::sect1[$chunk.section.depth &gt; 0                                and preceding-sibling::sect1][1]               |ancestor::sect2[$chunk.section.depth &gt; 1                                and preceding-sibling::sect2                                and parent::sect1[preceding-sibling::sect1]][1]               |ancestor::sect3[$chunk.section.depth &gt; 2                                and preceding-sibling::sect3                                and parent::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |ancestor::sect4[$chunk.section.depth &gt; 3                                and preceding-sibling::sect4                                and parent::sect3[preceding-sibling::sect2]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |ancestor::sect5[$chunk.section.depth &gt; 4                                and preceding-sibling::sect5                                and parent::sect4[preceding-sibling::sect4]                                and ancestor::sect3[preceding-sibling::sect3]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |ancestor::section[$chunk.section.depth &gt; count(ancestor::section)                                 and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
175
 
 
176
 
  <xsl:variable name="prev-v2" select="(preceding::sect1[$chunk.section.depth &gt; 0                                and preceding-sibling::sect1][1]               |preceding::sect2[$chunk.section.depth &gt; 1                                and preceding-sibling::sect2                                and parent::sect1[preceding-sibling::sect1]][1]               |preceding::sect3[$chunk.section.depth &gt; 2                                and preceding-sibling::sect3                                and parent::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |preceding::sect4[$chunk.section.depth &gt; 3                                and preceding-sibling::sect4                                and parent::sect3[preceding-sibling::sect2]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |preceding::sect5[$chunk.section.depth &gt; 4                                and preceding-sibling::sect5                                and parent::sect4[preceding-sibling::sect4]                                and ancestor::sect3[preceding-sibling::sect3]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |preceding::section[$chunk.section.depth &gt; count(ancestor::section)                                  and preceding-sibling::section                                  and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
177
 
 
178
 
  <xsl:variable name="prev" select="(preceding::book[1]              |preceding::preface[1]              |preceding::chapter[1]              |preceding::appendix[1]              |preceding::part[1]              |preceding::reference[1]              |preceding::refentry[1]              |preceding::colophon[1]              |preceding::article[1]              |preceding::bibliography[parent::article or parent::book or parent::part][1]              |preceding::glossary[parent::article or parent::book or parent::part][1]              |preceding::index[$generate.index != 0]                         [parent::article or parent::book or parent::part][1]              |preceding::setindex[$generate.index != 0][1]              |ancestor::set              |ancestor::book[1]              |ancestor::preface[1]              |ancestor::chapter[1]              |ancestor::appendix[1]              |ancestor::part[1]              |ancestor::reference[1]              |ancestor::article[1]              |$prev-v1              |$prev-v2)[last()]"/>
179
 
 
180
 
  <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth &gt; 0                                and preceding-sibling::sect1][1]               |following::sect2[$chunk.section.depth &gt; 1                                and preceding-sibling::sect2                                and parent::sect1[preceding-sibling::sect1]][1]               |following::sect3[$chunk.section.depth &gt; 2                                and preceding-sibling::sect3                                and parent::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |following::sect4[$chunk.section.depth &gt; 3                                and preceding-sibling::sect4                                and parent::sect3[preceding-sibling::sect2]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |following::sect5[$chunk.section.depth &gt; 4                                and preceding-sibling::sect5                                and parent::sect4[preceding-sibling::sect4]                                and ancestor::sect3[preceding-sibling::sect3]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |following::section[$chunk.section.depth &gt; count(ancestor::section)                                  and preceding-sibling::section                                  and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
181
 
 
182
 
  <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth &gt; 0                                and preceding-sibling::sect1][1]               |descendant::sect2[$chunk.section.depth &gt; 1                                and preceding-sibling::sect2                                and parent::sect1[preceding-sibling::sect1]][1]               |descendant::sect3[$chunk.section.depth &gt; 2                                and preceding-sibling::sect3                                and parent::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |descendant::sect4[$chunk.section.depth &gt; 3                                and preceding-sibling::sect4                                and parent::sect3[preceding-sibling::sect2]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |descendant::sect5[$chunk.section.depth &gt; 4                                and preceding-sibling::sect5                                and parent::sect4[preceding-sibling::sect4]                                and ancestor::sect3[preceding-sibling::sect3]                                and ancestor::sect2[preceding-sibling::sect2]                                and ancestor::sect1[preceding-sibling::sect1]][1]               |descendant::section[$chunk.section.depth &gt; count(ancestor::section)                                  and preceding-sibling::section                                  and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
183
 
 
184
 
  <xsl:variable name="next" select="(following::book[1]              |following::preface[1]              |following::chapter[1]              |following::appendix[1]              |following::part[1]              |following::reference[1]              |following::refentry[1]              |following::colophon[1]              |following::bibliography[parent::article or parent::book or parent::part][1]              |following::glossary[parent::article or parent::book or parent::part][1]              |following::index[$generate.index != 0]                         [parent::article or parent::book or parent::part][1]              |following::article[1]              |following::setindex[$generate.index != 0][1]              |descendant::book[1]              |descendant::preface[1]              |descendant::chapter[1]              |descendant::appendix[1]              |descendant::article[1]              |descendant::bibliography[parent::article or parent::book or parent::part][1]              |descendant::glossary[parent::article or parent::book or parent::part][1]              |descendant::index[$generate.index != 0]                         [parent::article or parent::book or parent::part][1]              |descendant::colophon[1]              |descendant::setindex[$generate.index != 0][1]              |descendant::part[1]              |descendant::reference[1]              |descendant::refentry[1]              |$next-v1              |$next-v2)[1]"/>
185
 
 
186
 
  <xsl:call-template name="process-chunk">
187
 
    <xsl:with-param name="prev" select="$prev"/>
188
 
    <xsl:with-param name="next" select="$next"/>
189
 
    <xsl:with-param name="content" select="$content"/>
190
 
  </xsl:call-template>
191
 
</xsl:template>
192
 
 
193
 
<xsl:template name="chunk-all-sections">
194
 
  <xsl:param name="content">
195
 
    <xsl:apply-imports/>
196
 
  </xsl:param>
197
 
 
198
 
  <xsl:variable name="prev-v1" select="(preceding::sect1[$chunk.section.depth &gt; 0][1]              |preceding::sect2[$chunk.section.depth &gt; 1][1]              |preceding::sect3[$chunk.section.depth &gt; 2][1]              |preceding::sect4[$chunk.section.depth &gt; 3][1]              |preceding::sect5[$chunk.section.depth &gt; 4][1]              |preceding::section[$chunk.section.depth &gt; count(ancestor::section)][1])[last()]"/>
199
 
 
200
 
  <xsl:variable name="prev-v2" select="(ancestor::sect1[$chunk.section.depth &gt; 0][1]              |ancestor::sect2[$chunk.section.depth &gt; 1][1]              |ancestor::sect3[$chunk.section.depth &gt; 2][1]              |ancestor::sect4[$chunk.section.depth &gt; 3][1]              |ancestor::sect5[$chunk.section.depth &gt; 4][1]              |ancestor::section[$chunk.section.depth &gt; count(ancestor::section)][1])[last()]"/>
201
 
 
202
 
  <xsl:variable name="prev" select="(preceding::book[1]              |preceding::preface[1]              |preceding::chapter[1]              |preceding::appendix[1]              |preceding::part[1]              |preceding::reference[1]              |preceding::refentry[1]              |preceding::colophon[1]              |preceding::article[1]              |preceding::bibliography[parent::article or parent::book or parent::part][1]              |preceding::glossary[parent::article or parent::book or parent::part][1]              |preceding::index[$generate.index != 0]                         [parent::article or parent::book or parent::part][1]              |preceding::setindex[$generate.index != 0][1]              |ancestor::set              |ancestor::book[1]              |ancestor::preface[1]              |ancestor::chapter[1]              |ancestor::appendix[1]              |ancestor::part[1]              |ancestor::reference[1]              |ancestor::article[1]              |$prev-v1              |$prev-v2)[last()]"/>
203
 
 
204
 
  <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth &gt; 0][1]              |following::sect2[$chunk.section.depth &gt; 1][1]              |following::sect3[$chunk.section.depth &gt; 2][1]              |following::sect4[$chunk.section.depth &gt; 3][1]              |following::sect5[$chunk.section.depth &gt; 4][1]              |following::section[$chunk.section.depth &gt; count(ancestor::section)][1])[1]"/>
205
 
 
206
 
  <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth &gt; 0][1]              |descendant::sect2[$chunk.section.depth &gt; 1][1]              |descendant::sect3[$chunk.section.depth &gt; 2][1]              |descendant::sect4[$chunk.section.depth &gt; 3][1]              |descendant::sect5[$chunk.section.depth &gt; 4][1]              |descendant::section[$chunk.section.depth                                    &gt; count(ancestor::section)][1])[1]"/>
207
 
 
208
 
  <xsl:variable name="next" select="(following::book[1]              |following::preface[1]              |following::chapter[1]              |following::appendix[1]              |following::part[1]              |following::reference[1]              |following::refentry[1]              |following::colophon[1]              |following::bibliography[parent::article or parent::book or parent::part][1]              |following::glossary[parent::article or parent::book or parent::part][1]              |following::index[$generate.index != 0]                         [parent::article or parent::book][1]              |following::article[1]              |following::setindex[$generate.index != 0][1]              |descendant::book[1]              |descendant::preface[1]              |descendant::chapter[1]              |descendant::appendix[1]              |descendant::article[1]              |descendant::bibliography[parent::article or parent::book][1]              |descendant::glossary[parent::article or parent::book or parent::part][1]              |descendant::index[$generate.index != 0]                         [parent::article or parent::book][1]              |descendant::colophon[1]              |descendant::setindex[$generate.index != 0][1]              |descendant::part[1]              |descendant::reference[1]              |descendant::refentry[1]              |$next-v1              |$next-v2)[1]"/>
209
 
 
210
 
  <xsl:call-template name="process-chunk">
211
 
    <xsl:with-param name="prev" select="$prev"/>
212
 
    <xsl:with-param name="next" select="$next"/>
213
 
    <xsl:with-param name="content" select="$content"/>
214
 
  </xsl:call-template>
215
 
</xsl:template>
216
 
 
217
 
<!-- ==================================================================== -->
218
 
 
219
 
<xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xsl:template match="/"><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:apply-templates select="." mode="profile"/></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/>
220
 
  <xsl:choose>
221
 
    <xsl:when test="$rootid != ''">
222
 
      <xsl:choose>
223
 
        <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0">
224
 
          <xsl:message terminate="yes">
225
 
            <xsl:text>ID '</xsl:text>
226
 
            <xsl:value-of select="$rootid"/>
227
 
            <xsl:text>' not found in document.</xsl:text>
228
 
          </xsl:message>
229
 
        </xsl:when>
230
 
        <xsl:otherwise>
231
 
          <xsl:if test="$collect.xref.targets = 'yes' or                         $collect.xref.targets = 'only'">
232
 
            <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
233
 
          </xsl:if>
234
 
          <xsl:if test="$collect.xref.targets != 'only'">
235
 
            <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
236
 
            <xsl:if test="$tex.math.in.alt != ''">
237
 
              <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="collect.tex.math"/>
238
 
            </xsl:if>
239
 
            <xsl:if test="$generate.manifest != 0">
240
 
              <xsl:call-template name="generate.manifest">
241
 
                <xsl:with-param name="node" select="key('id',$rootid)"/>
242
 
              </xsl:call-template>
243
 
            </xsl:if>
244
 
          </xsl:if>
245
 
        </xsl:otherwise>
246
 
      </xsl:choose>
247
 
    </xsl:when>
248
 
    <xsl:otherwise>
249
 
      <xsl:if test="$collect.xref.targets = 'yes' or                     $collect.xref.targets = 'only'">
250
 
        <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
251
 
      </xsl:if>
252
 
      <xsl:if test="$collect.xref.targets != 'only'">
253
 
        <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
254
 
        <xsl:if test="$tex.math.in.alt != ''">
255
 
          <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
256
 
        </xsl:if>
257
 
        <xsl:if test="$generate.manifest != 0">
258
 
          <xsl:call-template name="generate.manifest"/>
259
 
        </xsl:if>
260
 
      </xsl:if>
261
 
    </xsl:otherwise>
262
 
  </xsl:choose>
263
 
</xsl:template>
264
 
 
265
 
<xsl:template match="*" mode="process.root">
266
 
  <xsl:apply-templates select="."/>
267
 
</xsl:template>
268
 
 
269
 
<!-- ====================================================================== -->
270
 
 
271
 
<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">
272
 
  <xsl:choose>
273
 
    <xsl:when test="$onechunk != 0 and parent::*">
274
 
      <xsl:apply-imports/>
275
 
    </xsl:when>
276
 
    <xsl:otherwise>
277
 
      <xsl:call-template name="process-chunk-element"/>
278
 
    </xsl:otherwise>
279
 
  </xsl:choose>
280
 
</xsl:template>
281
 
 
282
 
<xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
283
 
  <xsl:variable name="ischunk">
284
 
    <xsl:call-template name="chunk"/>
285
 
  </xsl:variable>
286
 
 
287
 
  <xsl:choose>
288
 
    <xsl:when test="not(parent::*)">
289
 
      <xsl:call-template name="process-chunk-element"/>
290
 
    </xsl:when>
291
 
    <xsl:when test="$ischunk = 0">
292
 
      <xsl:apply-imports/>
293
 
    </xsl:when>
294
 
    <xsl:otherwise>
295
 
      <xsl:call-template name="process-chunk-element"/>
296
 
    </xsl:otherwise>
297
 
  </xsl:choose>
298
 
</xsl:template>
299
 
 
300
 
<xsl:template match="setindex                      |book/index                      |article/index                      |part/index">
301
 
  <!-- some implementations use completely empty index tags to indicate -->
302
 
  <!-- where an automatically generated index should be inserted. so -->
303
 
  <!-- if the index is completely empty, skip it. -->
304
 
  <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
305
 
    <xsl:call-template name="process-chunk-element"/>
306
 
  </xsl:if>
307
 
</xsl:template>
308
 
 
309
 
<!-- ==================================================================== -->
310
 
 
311
 
<xsl:template name="make.lots">
312
 
  <xsl:param name="toc.params" select="''"/>
313
 
  <xsl:param name="toc"/>
314
 
 
315
 
  <xsl:variable name="lots">
316
 
    <xsl:if test="contains($toc.params, 'toc')">
317
 
      <xsl:copy-of select="$toc"/>
318
 
    </xsl:if>
319
 
 
320
 
    <xsl:if test="contains($toc.params, 'figure')">
321
 
      <xsl:choose>
322
 
        <xsl:when test="$chunk.separate.lots != '0'">
323
 
          <xsl:call-template name="make.lot.chunk">
324
 
            <xsl:with-param name="type" select="'figure'"/>
325
 
            <xsl:with-param name="lot">
326
 
              <xsl:call-template name="list.of.titles">
327
 
                <xsl:with-param name="titles" select="'figure'"/>
328
 
                <xsl:with-param name="nodes" select=".//figure"/>
329
 
              </xsl:call-template>
330
 
            </xsl:with-param>
331
 
          </xsl:call-template>
332
 
        </xsl:when>
333
 
        <xsl:otherwise>
334
 
          <xsl:call-template name="list.of.titles">
335
 
            <xsl:with-param name="titles" select="'figure'"/>
336
 
            <xsl:with-param name="nodes" select=".//figure"/>
337
 
          </xsl:call-template>
338
 
        </xsl:otherwise>
339
 
      </xsl:choose>
340
 
    </xsl:if>
341
 
 
342
 
    <xsl:if test="contains($toc.params, 'table')">
343
 
      <xsl:choose>
344
 
        <xsl:when test="$chunk.separate.lots != '0'">
345
 
          <xsl:call-template name="make.lot.chunk">
346
 
            <xsl:with-param name="type" select="'table'"/>
347
 
            <xsl:with-param name="lot">
348
 
              <xsl:call-template name="list.of.titles">
349
 
                <xsl:with-param name="titles" select="'table'"/>
350
 
                <xsl:with-param name="nodes" select=".//table"/>
351
 
              </xsl:call-template>
352
 
            </xsl:with-param>
353
 
          </xsl:call-template>
354
 
        </xsl:when>
355
 
        <xsl:otherwise>
356
 
          <xsl:call-template name="list.of.titles">
357
 
            <xsl:with-param name="titles" select="'table'"/>
358
 
            <xsl:with-param name="nodes" select=".//table"/>
359
 
          </xsl:call-template>
360
 
        </xsl:otherwise>
361
 
      </xsl:choose>
362
 
    </xsl:if>
363
 
 
364
 
    <xsl:if test="contains($toc.params, 'example')">
365
 
      <xsl:choose>
366
 
        <xsl:when test="$chunk.separate.lots != '0'">
367
 
          <xsl:call-template name="make.lot.chunk">
368
 
            <xsl:with-param name="type" select="'example'"/>
369
 
            <xsl:with-param name="lot">
370
 
              <xsl:call-template name="list.of.titles">
371
 
                <xsl:with-param name="titles" select="'example'"/>
372
 
                <xsl:with-param name="nodes" select=".//example"/>
373
 
              </xsl:call-template>
374
 
            </xsl:with-param>
375
 
          </xsl:call-template>
376
 
        </xsl:when>
377
 
        <xsl:otherwise>
378
 
          <xsl:call-template name="list.of.titles">
379
 
            <xsl:with-param name="titles" select="'example'"/>
380
 
            <xsl:with-param name="nodes" select=".//example"/>
381
 
          </xsl:call-template>
382
 
        </xsl:otherwise>
383
 
      </xsl:choose>
384
 
    </xsl:if>
385
 
 
386
 
    <xsl:if test="contains($toc.params, 'equation')">
387
 
      <xsl:choose>
388
 
        <xsl:when test="$chunk.separate.lots != '0'">
389
 
          <xsl:call-template name="make.lot.chunk">
390
 
            <xsl:with-param name="type" select="'equation'"/>
391
 
            <xsl:with-param name="lot">
392
 
              <xsl:call-template name="list.of.titles">
393
 
                <xsl:with-param name="titles" select="'equation'"/>
394
 
                <xsl:with-param name="nodes" select=".//equation"/>
395
 
              </xsl:call-template>
396
 
            </xsl:with-param>
397
 
          </xsl:call-template>
398
 
        </xsl:when>
399
 
        <xsl:otherwise>
400
 
          <xsl:call-template name="list.of.titles">
401
 
            <xsl:with-param name="titles" select="'equation'"/>
402
 
            <xsl:with-param name="nodes" select=".//equation"/>
403
 
          </xsl:call-template>
404
 
        </xsl:otherwise>
405
 
      </xsl:choose>
406
 
    </xsl:if>
407
 
 
408
 
    <xsl:if test="contains($toc.params, 'procedure')">
409
 
      <xsl:choose>
410
 
        <xsl:when test="$chunk.separate.lots != '0'">
411
 
          <xsl:call-template name="make.lot.chunk">
412
 
            <xsl:with-param name="type" select="'procedure'"/>
413
 
            <xsl:with-param name="lot">
414
 
              <xsl:call-template name="list.of.titles">
415
 
                <xsl:with-param name="titles" select="'procedure'"/>
416
 
                <xsl:with-param name="nodes" select=".//procedure[title]"/>
417
 
              </xsl:call-template>
418
 
            </xsl:with-param>
419
 
          </xsl:call-template>
420
 
        </xsl:when>
421
 
        <xsl:otherwise>
422
 
          <xsl:call-template name="list.of.titles">
423
 
            <xsl:with-param name="titles" select="'procedure'"/>
424
 
            <xsl:with-param name="nodes" select=".//procedure[title]"/>
425
 
          </xsl:call-template>
426
 
        </xsl:otherwise>
427
 
      </xsl:choose>
428
 
    </xsl:if>
429
 
  </xsl:variable>
430
 
 
431
 
  <xsl:if test="string($lots) != ''">
432
 
    <xsl:choose>
433
 
      <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
434
 
        <xsl:call-template name="write.chunk">
435
 
          <xsl:with-param name="filename">
436
 
            <xsl:call-template name="make-relative-filename">
437
 
              <xsl:with-param name="base.dir" select="$base.dir"/>
438
 
              <xsl:with-param name="base.name">
439
 
                <xsl:call-template name="dbhtml-dir"/>
440
 
                <xsl:apply-templates select="." mode="recursive-chunk-filename">
441
 
                  <xsl:with-param name="recursive" select="true()"/>
442
 
                </xsl:apply-templates>
443
 
                <xsl:text>-toc</xsl:text>
444
 
                <xsl:value-of select="$html.ext"/>
445
 
              </xsl:with-param>
446
 
            </xsl:call-template>
447
 
          </xsl:with-param>
448
 
          <xsl:with-param name="content">
449
 
            <xsl:call-template name="chunk-element-content">
450
 
              <xsl:with-param name="prev" select="/foo"/>
451
 
              <xsl:with-param name="next" select="/foo"/>
452
 
              <xsl:with-param name="nav.context" select="'toc'"/>
453
 
              <xsl:with-param name="content">
454
 
                <h1>
455
 
                  <xsl:apply-templates select="." mode="object.title.markup"/>
456
 
                </h1>
457
 
                <xsl:copy-of select="$lots"/>
458
 
              </xsl:with-param>
459
 
            </xsl:call-template>
460
 
          </xsl:with-param>
461
 
          <xsl:with-param name="quiet" select="$chunk.quietly"/>
462
 
        </xsl:call-template>
463
 
      </xsl:when>
464
 
      <xsl:otherwise>
465
 
        <xsl:copy-of select="$lots"/>
466
 
      </xsl:otherwise>
467
 
    </xsl:choose>
468
 
  </xsl:if>
469
 
</xsl:template>
470
 
 
471
 
<xsl:template name="make.lot.chunk">
472
 
  <xsl:param name="type" select="''"/>
473
 
  <xsl:param name="lot"/>
474
 
 
475
 
  <xsl:if test="string($lot) != ''">
476
 
    <xsl:variable name="filename">
477
 
      <xsl:call-template name="make-relative-filename">
478
 
        <xsl:with-param name="base.dir" select="$base.dir"/>
479
 
        <xsl:with-param name="base.name">
480
 
          <xsl:call-template name="dbhtml-dir"/>
481
 
          <xsl:value-of select="$type"/>
482
 
          <xsl:text>-toc</xsl:text>
483
 
          <xsl:value-of select="$html.ext"/>
484
 
        </xsl:with-param>
485
 
      </xsl:call-template>
486
 
    </xsl:variable>
487
 
 
488
 
    <xsl:variable name="href">
489
 
      <xsl:call-template name="make-relative-filename">
490
 
        <xsl:with-param name="base.name">
491
 
          <xsl:call-template name="dbhtml-dir"/>
492
 
          <xsl:value-of select="$type"/>
493
 
          <xsl:text>-toc</xsl:text>
494
 
          <xsl:value-of select="$html.ext"/>
495
 
        </xsl:with-param>
496
 
      </xsl:call-template>
497
 
    </xsl:variable>
498
 
 
499
 
    <xsl:call-template name="write.chunk">
500
 
      <xsl:with-param name="filename" select="$filename"/>
501
 
      <xsl:with-param name="content">
502
 
        <xsl:call-template name="chunk-element-content">
503
 
          <xsl:with-param name="prev" select="/foo"/>
504
 
          <xsl:with-param name="next" select="/foo"/>
505
 
          <xsl:with-param name="nav.context" select="'toc'"/>
506
 
          <xsl:with-param name="content">
507
 
            <xsl:copy-of select="$lot"/>
508
 
          </xsl:with-param>
509
 
        </xsl:call-template>
510
 
      </xsl:with-param>
511
 
      <xsl:with-param name="quiet" select="$chunk.quietly"/>
512
 
    </xsl:call-template>
513
 
    <!-- And output a link to this file -->
514
 
    <div>
515
 
      <xsl:attribute name="class">
516
 
        <xsl:text>ListofTitles</xsl:text>
517
 
      </xsl:attribute>
518
 
      <a href="{$href}">
519
 
        <xsl:call-template name="gentext">
520
 
          <xsl:with-param name="key">
521
 
            <xsl:choose>
522
 
              <xsl:when test="$type='table'">ListofTables</xsl:when>
523
 
              <xsl:when test="$type='figure'">ListofFigures</xsl:when>
524
 
              <xsl:when test="$type='equation'">ListofEquations</xsl:when>
525
 
              <xsl:when test="$type='example'">ListofExamples</xsl:when>
526
 
              <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
527
 
              <xsl:otherwise>ListofUnknown</xsl:otherwise>
528
 
            </xsl:choose>
529
 
          </xsl:with-param>
530
 
        </xsl:call-template>
531
 
      </a>
532
 
    </div>
533
 
  </xsl:if>
534
 
</xsl:template>
535
 
 
536
 
<!-- ==================================================================== -->
537
 
 
538
 
<xsl:template name="in.other.chunk">
539
 
  <xsl:param name="chunk" select="."/>
540
 
  <xsl:param name="node" select="."/>
541
 
 
542
 
  <xsl:variable name="is.chunk">
543
 
    <xsl:call-template name="chunk">
544
 
      <xsl:with-param name="node" select="$node"/>
545
 
    </xsl:call-template>
546
 
  </xsl:variable>
547
 
 
548
 
<!--
549
 
  <xsl:message>
550
 
    <xsl:text>in.other.chunk: </xsl:text>
551
 
    <xsl:value-of select="name($chunk)"/>
552
 
    <xsl:text> </xsl:text>
553
 
    <xsl:value-of select="name($node)"/>
554
 
    <xsl:text> </xsl:text>
555
 
    <xsl:value-of select="$chunk = $node"/>
556
 
    <xsl:text> </xsl:text>
557
 
    <xsl:value-of select="$is.chunk"/>
558
 
  </xsl:message>
559
 
-->
560
 
 
561
 
  <xsl:choose>
562
 
    <xsl:when test="$chunk = $node">0</xsl:when>
563
 
    <xsl:when test="$is.chunk = 1">1</xsl:when>
564
 
    <xsl:when test="count($node) = 0">0</xsl:when>
565
 
    <xsl:otherwise>
566
 
      <xsl:call-template name="in.other.chunk">
567
 
        <xsl:with-param name="chunk" select="$chunk"/>
568
 
        <xsl:with-param name="node" select="$node/parent::*"/>
569
 
      </xsl:call-template>
570
 
    </xsl:otherwise>
571
 
  </xsl:choose>
572
 
</xsl:template>
573
 
 
574
 
<xsl:template name="count.footnotes.in.this.chunk">
575
 
  <xsl:param name="node" select="."/>
576
 
  <xsl:param name="footnotes" select="$node//footnote"/>
577
 
  <xsl:param name="count" select="0"/>
578
 
 
579
 
<!--
580
 
  <xsl:message>
581
 
    <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
582
 
    <xsl:value-of select="name($node)"/>
583
 
  </xsl:message>
584
 
-->
585
 
 
586
 
  <xsl:variable name="in.other.chunk">
587
 
    <xsl:call-template name="in.other.chunk">
588
 
      <xsl:with-param name="chunk" select="$node"/>
589
 
      <xsl:with-param name="node" select="$footnotes[1]"/>
590
 
    </xsl:call-template>
591
 
  </xsl:variable>
592
 
 
593
 
  <xsl:choose>
594
 
    <xsl:when test="count($footnotes) = 0">
595
 
      <xsl:value-of select="$count"/>
596
 
    </xsl:when>
597
 
    <xsl:otherwise>
598
 
      <xsl:choose>
599
 
        <xsl:when test="$in.other.chunk != 0">
600
 
          <xsl:call-template name="count.footnotes.in.this.chunk">
601
 
            <xsl:with-param name="node" select="$node"/>
602
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
603
 
            <xsl:with-param name="count" select="$count"/>
604
 
          </xsl:call-template>
605
 
        </xsl:when>
606
 
        <xsl:when test="$footnotes[1]/ancestor::table                         |$footnotes[1]/ancestor::informaltable">
607
 
          <xsl:call-template name="count.footnotes.in.this.chunk">
608
 
            <xsl:with-param name="node" select="$node"/>
609
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
610
 
            <xsl:with-param name="count" select="$count"/>
611
 
          </xsl:call-template>
612
 
        </xsl:when>
613
 
        <xsl:otherwise>
614
 
          <xsl:call-template name="count.footnotes.in.this.chunk">
615
 
            <xsl:with-param name="node" select="$node"/>
616
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
617
 
            <xsl:with-param name="count" select="$count + 1"/>
618
 
          </xsl:call-template>
619
 
        </xsl:otherwise>
620
 
      </xsl:choose>
621
 
    </xsl:otherwise>
622
 
  </xsl:choose>
623
 
</xsl:template>
624
 
 
625
 
<xsl:template name="process.footnotes.in.this.chunk">
626
 
  <xsl:param name="node" select="."/>
627
 
  <xsl:param name="footnotes" select="$node//footnote"/>
628
 
 
629
 
<!--
630
 
  <xsl:message>process.footnotes.in.this.chunk</xsl:message>
631
 
-->
632
 
 
633
 
  <xsl:variable name="in.other.chunk">
634
 
    <xsl:call-template name="in.other.chunk">
635
 
      <xsl:with-param name="chunk" select="$node"/>
636
 
      <xsl:with-param name="node" select="$footnotes[1]"/>
637
 
    </xsl:call-template>
638
 
  </xsl:variable>
639
 
 
640
 
  <xsl:choose>
641
 
    <xsl:when test="count($footnotes) = 0">
642
 
      <!-- nop -->
643
 
    </xsl:when>
644
 
    <xsl:otherwise>
645
 
      <xsl:choose>
646
 
        <xsl:when test="$in.other.chunk != 0">
647
 
          <xsl:call-template name="process.footnotes.in.this.chunk">
648
 
            <xsl:with-param name="node" select="$node"/>
649
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
650
 
          </xsl:call-template>
651
 
        </xsl:when>
652
 
        <xsl:when test="$footnotes[1]/ancestor::table                         |$footnotes[1]/ancestor::informaltable">
653
 
          <xsl:call-template name="process.footnotes.in.this.chunk">
654
 
            <xsl:with-param name="node" select="$node"/>
655
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
656
 
          </xsl:call-template>
657
 
        </xsl:when>
658
 
        <xsl:otherwise>
659
 
          <xsl:apply-templates select="$footnotes[1]" mode="process.footnote.mode"/>
660
 
          <xsl:call-template name="process.footnotes.in.this.chunk">
661
 
            <xsl:with-param name="node" select="$node"/>
662
 
            <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
663
 
          </xsl:call-template>
664
 
        </xsl:otherwise>
665
 
      </xsl:choose>
666
 
    </xsl:otherwise>
667
 
  </xsl:choose>
668
 
</xsl:template>
669
 
 
670
 
<xsl:template name="process.footnotes">
671
 
  <xsl:variable name="footnotes" select=".//footnote"/>
672
 
  <xsl:variable name="fcount">
673
 
    <xsl:call-template name="count.footnotes.in.this.chunk">
674
 
      <xsl:with-param name="node" select="."/>
675
 
      <xsl:with-param name="footnotes" select="$footnotes"/>
676
 
    </xsl:call-template>
677
 
  </xsl:variable>
678
 
 
679
 
<!--
680
 
  <xsl:message>
681
 
    <xsl:value-of select="name(.)"/>
682
 
    <xsl:text> fcount: </xsl:text>
683
 
    <xsl:value-of select="$fcount"/>
684
 
  </xsl:message>
685
 
-->
686
 
 
687
 
  <!-- Only bother to do this if there's at least one non-table footnote -->
688
 
  <xsl:if test="$fcount &gt; 0">
689
 
    <div class="footnotes">
690
 
      <br/>
691
 
      <hr width="100" align="left"/>
692
 
      <xsl:call-template name="process.footnotes.in.this.chunk">
693
 
        <xsl:with-param name="node" select="."/>
694
 
        <xsl:with-param name="footnotes" select="$footnotes"/>
695
 
      </xsl:call-template>
696
 
    </div>
697
 
  </xsl:if>
698
 
</xsl:template>
699
 
 
700
 
<xsl:template name="process.chunk.footnotes">
701
 
  <xsl:variable name="is.chunk">
702
 
    <xsl:call-template name="chunk"/>
703
 
  </xsl:variable>
704
 
  <xsl:if test="$is.chunk = 1">
705
 
    <xsl:call-template name="process.footnotes"/>
706
 
  </xsl:if>
707
 
</xsl:template>
708
 
 
709
 
<!-- ====================================================================== -->
710
 
 
711
 
<!-- Resolve xml:base attributes -->
712
 
<xsl:template match="@fileref">
713
 
  <!-- need a check for absolute urls -->
714
 
  <xsl:choose>
715
 
    <xsl:when test="contains(., ':')">
716
 
      <!-- it has a uri scheme so it is an absolute uri -->
717
 
      <xsl:value-of select="."/>
718
 
    </xsl:when>
719
 
    <xsl:otherwise>
720
 
      <!-- it is a relative uri -->
721
 
      <xsl:call-template name="relative-uri">
722
 
        <xsl:with-param name="destdir">
723
 
          <xsl:call-template name="dbhtml-dir">
724
 
            <xsl:with-param name="context" select=".."/>
725
 
          </xsl:call-template>
726
 
        </xsl:with-param>
727
 
      </xsl:call-template>
728
 
    </xsl:otherwise>
729
 
  </xsl:choose>
730
 
</xsl:template>
731
 
 
732
 
</xsl:stylesheet>