~todd-deshane/openstack-manuals/working

« back to all changes in this revision

Viewing changes to doc/build/docbook-xsl-1.76.1/xhtml-1_1/html.xsl

  • Committer: Anne Gentle
  • Date: 2011-04-04 17:54:52 UTC
  • Revision ID: anne@openstack.org-20110404175452-gtth3hfrniqhpp5o
Switching from Ant builds to Maven, still working out kinks but should be functional

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="ASCII"?>
2
 
<!--This file was created automatically by html2xhtml-->
3
 
<!--from the HTML stylesheets.-->
4
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
5
 
 
6
 
<!-- ********************************************************************
7
 
     $Id: html.xsl 8556 2009-12-11 00:05:45Z bobstayton $
8
 
     ********************************************************************
9
 
 
10
 
     This file is part of the XSL DocBook Stylesheet distribution.
11
 
     See ../README or http://docbook.sf.net/release/xsl/current/ for
12
 
     copyright and other information.
13
 
 
14
 
     ******************************************************************** -->
15
 
 
16
 
<!-- These variables set the align attribute value for HTML output based on
17
 
     the writing-mode specified in the gentext file for the document's lang. -->
18
 
 
19
 
<xsl:variable name="direction.align.start">
20
 
  <xsl:choose>
21
 
    <xsl:when test="starts-with($writing.mode, 'lr')">left</xsl:when>
22
 
    <xsl:when test="starts-with($writing.mode, 'rl')">right</xsl:when>
23
 
    <xsl:otherwise>left</xsl:otherwise>
24
 
  </xsl:choose>
25
 
</xsl:variable>
26
 
 
27
 
<xsl:variable name="direction.align.end">
28
 
  <xsl:choose>
29
 
    <xsl:when test="starts-with($writing.mode, 'lr')">right</xsl:when>
30
 
    <xsl:when test="starts-with($writing.mode, 'rl')">left</xsl:when>
31
 
    <xsl:otherwise>right</xsl:otherwise>
32
 
  </xsl:choose>
33
 
</xsl:variable>
34
 
 
35
 
<xsl:variable name="direction.mode">
36
 
  <xsl:choose>
37
 
    <xsl:when test="starts-with($writing.mode, 'lr')">ltr</xsl:when>
38
 
    <xsl:when test="starts-with($writing.mode, 'rl')">rtl</xsl:when>
39
 
    <xsl:otherwise>ltr</xsl:otherwise>
40
 
  </xsl:choose>
41
 
</xsl:variable>
42
 
 
43
 
<!-- The generate.html.title template is currently used for generating HTML -->
44
 
<!-- "title" attributes for some inline elements only, but not for any -->
45
 
<!-- block elements. It is called in eleven places in the inline.xsl -->
46
 
<!-- file. But it's called by all the inline.* templates (e.g., -->
47
 
<!-- inline.boldseq), which in turn are called by other (element) -->
48
 
<!-- templates, so it results, currently, in supporting generation of the -->
49
 
<!-- HTML "title" attribute for a total of about 92 elements. -->
50
 
<!-- You can use mode="html.title.attribute" to get a title for -->
51
 
<!-- an element specified by a param, including targets of cross references. -->
52
 
<xsl:template name="generate.html.title">
53
 
  <xsl:apply-templates select="." mode="html.title.attribute"/>
54
 
</xsl:template>
55
 
 
56
 
<!-- Generate a title attribute for the context node -->
57
 
<xsl:template match="*" mode="html.title.attribute">
58
 
  <xsl:variable name="is.title">
59
 
    <xsl:call-template name="gentext.template.exists">
60
 
      <xsl:with-param name="context" select="'title'"/>
61
 
      <xsl:with-param name="name" select="local-name(.)"/>
62
 
      <xsl:with-param name="lang">
63
 
        <xsl:call-template name="l10n.language"/>
64
 
      </xsl:with-param>
65
 
    </xsl:call-template>
66
 
  </xsl:variable>
67
 
 
68
 
  <xsl:variable name="is.title-numbered">
69
 
    <xsl:call-template name="gentext.template.exists">
70
 
      <xsl:with-param name="context" select="'title-numbered'"/>
71
 
      <xsl:with-param name="name" select="local-name(.)"/>
72
 
      <xsl:with-param name="lang">
73
 
        <xsl:call-template name="l10n.language"/>
74
 
      </xsl:with-param>
75
 
    </xsl:call-template>
76
 
  </xsl:variable>
77
 
 
78
 
  <xsl:variable name="is.title-unnumbered">
79
 
    <xsl:call-template name="gentext.template.exists">
80
 
      <xsl:with-param name="context" select="'title-unnumbered'"/>
81
 
      <xsl:with-param name="name" select="local-name(.)"/>
82
 
      <xsl:with-param name="lang">
83
 
        <xsl:call-template name="l10n.language"/>
84
 
      </xsl:with-param>
85
 
    </xsl:call-template>
86
 
  </xsl:variable>
87
 
 
88
 
  <xsl:variable name="has.title.markup">
89
 
    <xsl:apply-templates select="." mode="title.markup">
90
 
      <xsl:with-param name="verbose" select="0"/>
91
 
    </xsl:apply-templates>
92
 
  </xsl:variable>
93
 
 
94
 
  <xsl:variable name="gentext.title">
95
 
    <xsl:if test="$has.title.markup != '???TITLE???' and                   ($is.title != 0 or                   $is.title-numbered != 0 or                   $is.title-unnumbered != 0)">
96
 
      <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
97
 
    </xsl:if>
98
 
  </xsl:variable>
99
 
 
100
 
  <xsl:choose>
101
 
    <xsl:when test="string-length($gentext.title) != 0">
102
 
      <xsl:attribute name="title">
103
 
        <xsl:value-of select="$gentext.title"/>
104
 
      </xsl:attribute>
105
 
    </xsl:when>
106
 
    <!-- Fall back to alt if available -->
107
 
    <xsl:when test="alt">
108
 
      <xsl:attribute name="title">
109
 
        <xsl:value-of select="normalize-space(alt)"/>
110
 
      </xsl:attribute>
111
 
    </xsl:when>
112
 
  </xsl:choose>
113
 
</xsl:template>
114
 
 
115
 
<xsl:template match="qandaentry" mode="html.title.attribute">
116
 
  <xsl:apply-templates select="question" mode="html.title.attribute"/>
117
 
</xsl:template>
118
 
 
119
 
<xsl:template match="question" mode="html.title.attribute">
120
 
  <xsl:variable name="label.text">
121
 
    <xsl:apply-templates select="." mode="qanda.label"/>
122
 
  </xsl:variable>
123
 
 
124
 
  <xsl:choose>
125
 
    <xsl:when test="string-length($label.text) != 0">
126
 
      <xsl:attribute name="title">
127
 
        <xsl:value-of select="$label.text"/>
128
 
      </xsl:attribute>
129
 
    </xsl:when>
130
 
    <!-- Fall back to alt if available -->
131
 
    <xsl:when test="alt">
132
 
      <xsl:attribute name="title">
133
 
        <xsl:value-of select="normalize-space(alt)"/>
134
 
      </xsl:attribute>
135
 
    </xsl:when>
136
 
  </xsl:choose>
137
 
</xsl:template>
138
 
 
139
 
<xsl:template name="dir">
140
 
  <xsl:param name="inherit" select="0"/>
141
 
 
142
 
  <xsl:variable name="dir">
143
 
    <xsl:choose>
144
 
      <xsl:when test="@dir">
145
 
        <xsl:value-of select="@dir"/>
146
 
      </xsl:when>
147
 
      <xsl:when test="$inherit != 0">
148
 
        <xsl:value-of select="ancestor::*/@dir[1]"/>
149
 
      </xsl:when>
150
 
    </xsl:choose>
151
 
  </xsl:variable>
152
 
 
153
 
  <xsl:if test="$dir != ''">
154
 
    <xsl:attribute name="dir">
155
 
      <xsl:value-of select="$dir"/>
156
 
    </xsl:attribute>
157
 
  </xsl:if>
158
 
</xsl:template>
159
 
 
160
 
<xsl:template name="anchor">
161
 
  <xsl:param name="node" select="."/>
162
 
  <xsl:param name="conditional" select="1"/>
163
 
  <xsl:variable name="id">
164
 
    <xsl:call-template name="object.id">
165
 
      <xsl:with-param name="object" select="$node"/>
166
 
    </xsl:call-template>
167
 
  </xsl:variable>
168
 
  <xslo:if xmlns:xslo="http://www.w3.org/1999/XSL/Transform" test="not($node[parent::blockquote])"><xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id">
169
 
    <a id="{$id}"/>
170
 
  </xsl:if></xslo:if>
171
 
</xsl:template>
172
 
 
173
 
<xsl:template name="href.target.uri">
174
 
  <xsl:param name="context" select="."/>
175
 
  <xsl:param name="object" select="."/>
176
 
  <xsl:text>#</xsl:text>
177
 
  <xsl:call-template name="object.id">
178
 
    <xsl:with-param name="object" select="$object"/>
179
 
  </xsl:call-template>
180
 
</xsl:template>
181
 
 
182
 
<xsl:template name="href.target">
183
 
  <xsl:param name="context" select="."/>
184
 
  <xsl:param name="object" select="."/>
185
 
  <xsl:text>#</xsl:text>
186
 
  <xsl:call-template name="object.id">
187
 
    <xsl:with-param name="object" select="$object"/>
188
 
  </xsl:call-template>
189
 
</xsl:template>
190
 
 
191
 
<xsl:template name="href.target.with.base.dir">
192
 
  <xsl:param name="context" select="."/>
193
 
  <xsl:param name="object" select="."/>
194
 
  <xsl:if test="$manifest.in.base.dir = 0">
195
 
    <xsl:value-of select="$base.dir"/>
196
 
  </xsl:if>
197
 
  <xsl:call-template name="href.target">
198
 
    <xsl:with-param name="context" select="$context"/>
199
 
    <xsl:with-param name="object" select="$object"/>
200
 
  </xsl:call-template>
201
 
</xsl:template>
202
 
 
203
 
<xsl:template name="dingbat">
204
 
  <xsl:param name="dingbat">bullet</xsl:param>
205
 
  <xsl:call-template name="dingbat.characters">
206
 
    <xsl:with-param name="dingbat" select="$dingbat"/>
207
 
  </xsl:call-template>
208
 
</xsl:template>
209
 
 
210
 
<xsl:template name="dingbat.characters">
211
 
  <!-- now that I'm using the real serializer, all that dingbat malarky -->
212
 
  <!-- isn't necessary anymore... -->
213
 
  <xsl:param name="dingbat">bullet</xsl:param>
214
 
  <xsl:choose>
215
 
    <xsl:when test="$dingbat='bullet'">&#8226;</xsl:when>
216
 
    <xsl:when test="$dingbat='copyright'">&#169;</xsl:when>
217
 
    <xsl:when test="$dingbat='trademark'">&#8482;</xsl:when>
218
 
    <xsl:when test="$dingbat='trade'">&#8482;</xsl:when>
219
 
    <xsl:when test="$dingbat='registered'">&#174;</xsl:when>
220
 
    <xsl:when test="$dingbat='service'">(SM)</xsl:when>
221
 
    <xsl:when test="$dingbat='nbsp'">&#160;</xsl:when>
222
 
    <xsl:when test="$dingbat='ldquo'">&#8220;</xsl:when>
223
 
    <xsl:when test="$dingbat='rdquo'">&#8221;</xsl:when>
224
 
    <xsl:when test="$dingbat='lsquo'">&#8216;</xsl:when>
225
 
    <xsl:when test="$dingbat='rsquo'">&#8217;</xsl:when>
226
 
    <xsl:when test="$dingbat='em-dash'">&#8212;</xsl:when>
227
 
    <xsl:when test="$dingbat='mdash'">&#8212;</xsl:when>
228
 
    <xsl:when test="$dingbat='en-dash'">&#8211;</xsl:when>
229
 
    <xsl:when test="$dingbat='ndash'">&#8211;</xsl:when>
230
 
    <xsl:otherwise>
231
 
      <xsl:text>&#8226;</xsl:text>
232
 
    </xsl:otherwise>
233
 
  </xsl:choose>
234
 
</xsl:template>
235
 
 
236
 
<xsl:template name="id.warning">
237
 
  <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
238
 
    <xsl:variable name="title">
239
 
      <xsl:choose>
240
 
        <xsl:when test="title">
241
 
          <xsl:value-of select="title[1]"/>
242
 
        </xsl:when>
243
 
        <xsl:when test="substring(local-name(*[1]),                                   string-length(local-name(*[1])-3) = 'info')                         and *[1]/title">
244
 
          <xsl:value-of select="*[1]/title[1]"/>
245
 
        </xsl:when>
246
 
        <xsl:when test="refmeta/refentrytitle">
247
 
          <xsl:value-of select="refmeta/refentrytitle"/>
248
 
        </xsl:when>
249
 
        <xsl:when test="refnamediv/refname">
250
 
          <xsl:value-of select="refnamediv/refname[1]"/>
251
 
        </xsl:when>
252
 
      </xsl:choose>
253
 
    </xsl:variable>
254
 
 
255
 
    <xsl:message>
256
 
      <xsl:text>ID recommended on </xsl:text>
257
 
      <xsl:value-of select="local-name(.)"/>
258
 
      <xsl:if test="$title != ''">
259
 
        <xsl:text>: </xsl:text>
260
 
        <xsl:choose>
261
 
          <xsl:when test="string-length($title) &gt; 40">
262
 
            <xsl:value-of select="substring($title,1,40)"/>
263
 
            <xsl:text>...</xsl:text>
264
 
          </xsl:when>
265
 
          <xsl:otherwise>
266
 
            <xsl:value-of select="$title"/>
267
 
          </xsl:otherwise>
268
 
        </xsl:choose>
269
 
      </xsl:if>
270
 
    </xsl:message>
271
 
  </xsl:if>
272
 
</xsl:template>
273
 
 
274
 
<xsl:template name="generate.class.attribute">
275
 
  <xsl:param name="class" select="local-name(.)"/>
276
 
  <xsl:apply-templates select="." mode="class.attribute">
277
 
    <xsl:with-param name="class" select="$class"/>
278
 
  </xsl:apply-templates>
279
 
</xsl:template>
280
 
 
281
 
<xsl:template match="*" mode="class.attribute">
282
 
  <xsl:param name="class" select="local-name(.)"/>
283
 
  <!-- permit customization of class attributes -->
284
 
  <!-- Use element name by default -->
285
 
  <xsl:attribute name="class">
286
 
    <xsl:apply-templates select="." mode="class.value">
287
 
      <xsl:with-param name="class" select="$class"/>
288
 
    </xsl:apply-templates>
289
 
  </xsl:attribute>
290
 
</xsl:template>
291
 
 
292
 
<xsl:template match="*" mode="class.value">
293
 
  <xsl:param name="class" select="local-name(.)"/>
294
 
  <!-- permit customization of class value only -->
295
 
  <!-- Use element name by default -->
296
 
  <xsl:value-of select="$class"/>
297
 
</xsl:template>
298
 
 
299
 
<!-- Apply common attributes such as class, lang, dir -->
300
 
<xsl:template name="common.html.attributes">
301
 
  <xsl:param name="inherit" select="0"/>
302
 
  <xsl:param name="class" select="local-name(.)"/>
303
 
  <xsl:apply-templates select="." mode="common.html.attributes">
304
 
    <xsl:with-param name="class" select="$class"/>
305
 
    <xsl:with-param name="inherit" select="$inherit"/>
306
 
  </xsl:apply-templates>
307
 
</xsl:template>
308
 
 
309
 
<xsl:template match="*" mode="common.html.attributes">
310
 
  <xsl:param name="class" select="local-name(.)"/>
311
 
  <xsl:param name="inherit" select="0"/>
312
 
  <xsl:call-template name="generate.html.lang"/>
313
 
  <xsl:call-template name="dir">
314
 
    <xsl:with-param name="inherit" select="$inherit"/>
315
 
  </xsl:call-template>
316
 
  <xsl:apply-templates select="." mode="class.attribute">
317
 
    <xsl:with-param name="class" select="$class"/>
318
 
  </xsl:apply-templates>
319
 
  <xsl:call-template name="generate.html.title"/>
320
 
</xsl:template>
321
 
 
322
 
<!-- Apply common attributes not including class -->
323
 
<xsl:template name="locale.html.attributes">
324
 
  <xsl:apply-templates select="." mode="locale.html.attributes"/>
325
 
</xsl:template>
326
 
 
327
 
<xsl:template match="*" mode="locale.html.attributes">
328
 
  <xsl:call-template name="generate.html.lang"/>
329
 
  <xsl:call-template name="dir"/>
330
 
  <xsl:call-template name="generate.html.title"/>
331
 
</xsl:template>
332
 
 
333
 
<!-- Pass through any lang attributes -->
334
 
<xsl:template name="generate.html.lang">
335
 
  <xsl:apply-templates select="." mode="html.lang.attribute"/>
336
 
</xsl:template>
337
 
 
338
 
<xsl:template match="*" mode="html.lang.attribute">
339
 
  <!-- match the attribute name to the output type -->
340
 
  <xsl:choose>
341
 
    <xsl:when test="@lang and $stylesheet.result.type = 'html'">
342
 
      <xsl:attribute name="lang">
343
 
        <xsl:value-of select="@lang"/>
344
 
      </xsl:attribute>
345
 
    </xsl:when>
346
 
    <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
347
 
      <xsl:attribute name="xml:lang">
348
 
        <xsl:value-of select="@lang"/>
349
 
      </xsl:attribute>
350
 
    </xsl:when>
351
 
    <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
352
 
      <xsl:attribute name="lang">
353
 
        <xsl:value-of select="@xml:lang"/>
354
 
      </xsl:attribute>
355
 
    </xsl:when>
356
 
    <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
357
 
      <xsl:attribute name="xml:lang">
358
 
        <xsl:value-of select="@xml:lang"/>
359
 
      </xsl:attribute>
360
 
    </xsl:when>
361
 
  </xsl:choose>
362
 
</xsl:template>
363
 
 
364
 
<!-- ==================================================================== -->
365
 
<!-- Insert link to css or insert literal CSS in head element -->
366
 
<xsl:template name="generate.css">
367
 
  <xsl:choose>
368
 
    <xsl:when test="$generate.css.header = 0">
369
 
      <xsl:call-template name="generate.css.links"/>
370
 
    </xsl:when>
371
 
    <xsl:otherwise>
372
 
      <xsl:call-template name="generate.css.headers"/>
373
 
    </xsl:otherwise>
374
 
  </xsl:choose>
375
 
</xsl:template>
376
 
 
377
 
<xsl:template name="generate.css.headers">
378
 
  <xsl:call-template name="generate.default.css.header"/>
379
 
  <xsl:call-template name="generate.custom.css.header"/>
380
 
</xsl:template>
381
 
 
382
 
<xsl:template name="generate.default.css.header">
383
 
  <xsl:if test="$make.clean.html != 0 and                  $docbook.css.source != ''">
384
 
    <!-- Select default file relative to stylesheet -->
385
 
    <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
386
 
 
387
 
    <xsl:call-template name="output.css.header">
388
 
      <xsl:with-param name="css.node" select="$css.node"/>
389
 
    </xsl:call-template>
390
 
  </xsl:if>
391
 
</xsl:template>
392
 
 
393
 
<xsl:template name="generate.custom.css.header">
394
 
  <xsl:if test="$custom.css.source != ''">
395
 
    <!-- Select custom file relative to document -->
396
 
    <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
397
 
 
398
 
    <xsl:call-template name="output.css.header">
399
 
      <xsl:with-param name="css.node" select="$css.node"/>
400
 
    </xsl:call-template>
401
 
  </xsl:if>
402
 
</xsl:template>
403
 
 
404
 
<xsl:template name="output.css.header">
405
 
  <xsl:param name="css.node"/> 
406
 
 
407
 
  <xsl:choose>
408
 
    <xsl:when test="count($css.node) = 0">
409
 
    </xsl:when>
410
 
    <xsl:otherwise>
411
 
      <style type="text/css">
412
 
        <xsl:copy-of select="$css.node/text()"/>
413
 
      </style>
414
 
    </xsl:otherwise>
415
 
  </xsl:choose>
416
 
</xsl:template>
417
 
 
418
 
<!-- ==================================================================== -->
419
 
<xsl:template name="generate.css.links">
420
 
  <xsl:call-template name="generate.default.css.link"/>
421
 
  <xsl:call-template name="generate.custom.css.link"/>
422
 
</xsl:template>
423
 
 
424
 
<xsl:template name="generate.default.css.link">
425
 
  <xsl:if test="$make.clean.html != 0 and                  $docbook.css.link != 0 and                 $docbook.css.source != ''">
426
 
    <xsl:variable name="filename">
427
 
      <xsl:call-template name="css.output.filename">
428
 
        <xsl:with-param name="src" select="$docbook.css.source"/>
429
 
      </xsl:call-template>
430
 
    </xsl:variable>
431
 
 
432
 
    <xsl:call-template name="make.css.link">
433
 
      <xsl:with-param name="css.filename" select="$filename"/>
434
 
    </xsl:call-template>
435
 
  </xsl:if>
436
 
</xsl:template>
437
 
 
438
 
<xsl:template name="generate.custom.css.link">
439
 
  <xsl:if test="$custom.css.source != ''">
440
 
    <xsl:variable name="filename">
441
 
      <xsl:call-template name="css.output.filename">
442
 
        <xsl:with-param name="src" select="$custom.css.source"/>
443
 
      </xsl:call-template>
444
 
    </xsl:variable>
445
 
 
446
 
    <xsl:call-template name="make.css.link">
447
 
      <xsl:with-param name="css.filename" select="$filename"/>
448
 
    </xsl:call-template>
449
 
  </xsl:if>
450
 
</xsl:template>
451
 
 
452
 
<!-- a CSS link reference must take into account the relative
453
 
     path to a CSS file when chunked HTML is output to more than one directory -->
454
 
<xsl:template name="make.css.link">
455
 
  <xsl:param name="css.filename" select="''"/>
456
 
 
457
 
  <xsl:variable name="href.to.uri" select="$css.filename"/>
458
 
 
459
 
  <xsl:variable name="href.from.uri">
460
 
    <xsl:call-template name="href.target.uri">
461
 
      <xsl:with-param name="object" select="."/>
462
 
    </xsl:call-template>
463
 
  </xsl:variable>
464
 
 
465
 
  <xsl:variable name="href.to">
466
 
    <xsl:call-template name="trim.common.uri.paths">
467
 
      <xsl:with-param name="uriA" select="$href.to.uri"/>
468
 
      <xsl:with-param name="uriB" select="$href.from.uri"/>
469
 
      <xsl:with-param name="return" select="'A'"/>
470
 
    </xsl:call-template>
471
 
  </xsl:variable>
472
 
 
473
 
  <xsl:variable name="href.from">
474
 
    <xsl:call-template name="trim.common.uri.paths">
475
 
      <xsl:with-param name="uriA" select="$href.to.uri"/>
476
 
      <xsl:with-param name="uriB" select="$href.from.uri"/>
477
 
      <xsl:with-param name="return" select="'B'"/>
478
 
    </xsl:call-template>
479
 
  </xsl:variable>
480
 
  <xsl:variable name="depth">
481
 
    <xsl:call-template name="count.uri.path.depth">
482
 
      <xsl:with-param name="filename" select="$href.from"/>
483
 
    </xsl:call-template>
484
 
  </xsl:variable>
485
 
  <xsl:variable name="href">
486
 
    <xsl:call-template name="copy-string">
487
 
      <xsl:with-param name="string" select="'../'"/>
488
 
      <xsl:with-param name="count" select="$depth"/>
489
 
    </xsl:call-template>
490
 
    <xsl:value-of select="$href.to"/>
491
 
  </xsl:variable>
492
 
 
493
 
  <xsl:if test="string-length($css.filename) != 0">
494
 
    <link rel="stylesheet" type="text/css" href="{$href}"/>
495
 
  </xsl:if>
496
 
</xsl:template>
497
 
 
498
 
<!-- ==================================================================== -->
499
 
 
500
 
<xsl:template name="generate.css.files">
501
 
  <xsl:call-template name="generate.default.css.file"/>
502
 
  <xsl:call-template name="generate.custom.css.file"/>
503
 
</xsl:template>
504
 
 
505
 
<xsl:template name="generate.default.css.file">
506
 
  <xsl:if test="$make.clean.html != 0 and                  $generate.css.header = 0 and                 $docbook.css.source != ''">
507
 
    <!-- Select default file relative to stylesheet -->
508
 
    <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
509
 
 
510
 
    <xsl:call-template name="generate.css.file">
511
 
      <xsl:with-param name="src" select="$docbook.css.source"/>
512
 
      <xsl:with-param name="css.node" select="$css.node"/>
513
 
    </xsl:call-template>
514
 
  </xsl:if>
515
 
</xsl:template>
516
 
 
517
 
<xsl:template name="generate.custom.css.file">
518
 
  <xsl:if test="$custom.css.source != '' and                 $generate.css.header = 0">
519
 
    <!-- Select custom file relative to document -->
520
 
    <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
521
 
 
522
 
    <xsl:call-template name="generate.css.file">
523
 
      <xsl:with-param name="src" select="$custom.css.source"/>
524
 
      <xsl:with-param name="css.node" select="$css.node"/>
525
 
    </xsl:call-template>
526
 
  </xsl:if>
527
 
</xsl:template>
528
 
 
529
 
<xsl:template name="generate.css.file">
530
 
  <xsl:param name="css.node"/> 
531
 
  <xsl:param name="src" select="''"/> 
532
 
 
533
 
  <xsl:variable name="css.text" select="$css.node/text()"/>
534
 
 
535
 
  <xsl:choose>
536
 
    <xsl:when test="count($css.node) = 0">
537
 
      <xsl:message>
538
 
        <xsl:text>ERROR: no root element for CSS source file'</xsl:text>
539
 
        <xsl:value-of select="$src"/>
540
 
        <xsl:text>'.</xsl:text>
541
 
      </xsl:message>
542
 
    </xsl:when>
543
 
    <xsl:otherwise>
544
 
      <xsl:variable name="filename">
545
 
        <xsl:call-template name="css.output.pathname">
546
 
          <xsl:with-param name="src" select="$src"/>
547
 
          <xsl:with-param name="content" select="$css.node"/>
548
 
        </xsl:call-template>
549
 
      </xsl:variable>
550
 
 
551
 
      <xsl:call-template name="write.text.chunk">
552
 
        <xsl:with-param name="filename" select="$filename"/>
553
 
        <xsl:with-param name="content" select="$css.text"/>
554
 
      </xsl:call-template>
555
 
 
556
 
    </xsl:otherwise>
557
 
  </xsl:choose>
558
 
</xsl:template>
559
 
 
560
 
<xsl:template name="css.output.filename">
561
 
  <xsl:param name="content"/>
562
 
  <xsl:param name="src" select="''"/>
563
 
  
564
 
  <xsl:variable name="candidate">
565
 
    <xsl:choose>
566
 
      <xsl:when test="string-length($src) = 0">
567
 
        <xsl:message>
568
 
          <xsl:text>ERROR: missing CSS input filename.</xsl:text>
569
 
        </xsl:message>
570
 
      </xsl:when>
571
 
      <xsl:when test="substring($src,string-length($src)-3) = '.xml'">
572
 
        <xsl:value-of select="substring($src, 1, string-length($src) - 4)"/>
573
 
      </xsl:when>
574
 
      <xsl:otherwise>
575
 
        <xsl:value-of select="$src"/>
576
 
      </xsl:otherwise>
577
 
    </xsl:choose>
578
 
  </xsl:variable>
579
 
  <xsl:value-of select="$candidate"/>
580
 
</xsl:template>
581
 
 
582
 
<xsl:template name="css.output.pathname">
583
 
  <xsl:param name="content"/>
584
 
  <xsl:param name="src" select="''"/>
585
 
 
586
 
  <xsl:variable name="file">
587
 
    <xsl:call-template name="css.output.filename">
588
 
      <xsl:with-param name="content" select="$content"/>
589
 
      <xsl:with-param name="src" select="$src"/>
590
 
    </xsl:call-template>
591
 
  </xsl:variable>
592
 
 
593
 
  <xsl:variable name="path" select="concat($base.dir, $file)"/>
594
 
  <xsl:value-of select="$path"/>
595
 
  
596
 
</xsl:template>
597
 
 
598
 
</xsl:stylesheet>