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">
6
<!-- ********************************************************************
7
$Id: html.xsl 8556 2009-12-11 00:05:45Z bobstayton $
8
********************************************************************
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.
14
******************************************************************** -->
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. -->
19
<xsl:variable name="direction.align.start">
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>
27
<xsl:variable name="direction.align.end">
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>
35
<xsl:variable name="direction.mode">
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>
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"/>
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"/>
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"/>
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"/>
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>
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"/>
101
<xsl:when test="string-length($gentext.title) != 0">
102
<xsl:attribute name="title">
103
<xsl:value-of select="$gentext.title"/>
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)"/>
115
<xsl:template match="qandaentry" mode="html.title.attribute">
116
<xsl:apply-templates select="question" mode="html.title.attribute"/>
119
<xsl:template match="question" mode="html.title.attribute">
120
<xsl:variable name="label.text">
121
<xsl:apply-templates select="." mode="qanda.label"/>
125
<xsl:when test="string-length($label.text) != 0">
126
<xsl:attribute name="title">
127
<xsl:value-of select="$label.text"/>
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)"/>
139
<xsl:template name="dir">
140
<xsl:param name="inherit" select="0"/>
142
<xsl:variable name="dir">
144
<xsl:when test="@dir">
145
<xsl:value-of select="@dir"/>
147
<xsl:when test="$inherit != 0">
148
<xsl:value-of select="ancestor::*/@dir[1]"/>
153
<xsl:if test="$dir != ''">
154
<xsl:attribute name="dir">
155
<xsl:value-of select="$dir"/>
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"/>
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">
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"/>
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"/>
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"/>
197
<xsl:call-template name="href.target">
198
<xsl:with-param name="context" select="$context"/>
199
<xsl:with-param name="object" select="$object"/>
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"/>
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>
215
<xsl:when test="$dingbat='bullet'">•</xsl:when>
216
<xsl:when test="$dingbat='copyright'">©</xsl:when>
217
<xsl:when test="$dingbat='trademark'">™</xsl:when>
218
<xsl:when test="$dingbat='trade'">™</xsl:when>
219
<xsl:when test="$dingbat='registered'">®</xsl:when>
220
<xsl:when test="$dingbat='service'">(SM)</xsl:when>
221
<xsl:when test="$dingbat='nbsp'"> </xsl:when>
222
<xsl:when test="$dingbat='ldquo'">“</xsl:when>
223
<xsl:when test="$dingbat='rdquo'">”</xsl:when>
224
<xsl:when test="$dingbat='lsquo'">‘</xsl:when>
225
<xsl:when test="$dingbat='rsquo'">’</xsl:when>
226
<xsl:when test="$dingbat='em-dash'">—</xsl:when>
227
<xsl:when test="$dingbat='mdash'">—</xsl:when>
228
<xsl:when test="$dingbat='en-dash'">–</xsl:when>
229
<xsl:when test="$dingbat='ndash'">–</xsl:when>
231
<xsl:text>•</xsl:text>
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">
240
<xsl:when test="title">
241
<xsl:value-of select="title[1]"/>
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]"/>
246
<xsl:when test="refmeta/refentrytitle">
247
<xsl:value-of select="refmeta/refentrytitle"/>
249
<xsl:when test="refnamediv/refname">
250
<xsl:value-of select="refnamediv/refname[1]"/>
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>
261
<xsl:when test="string-length($title) > 40">
262
<xsl:value-of select="substring($title,1,40)"/>
263
<xsl:text>...</xsl:text>
266
<xsl:value-of select="$title"/>
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>
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>
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"/>
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>
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"/>
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"/>
322
<!-- Apply common attributes not including class -->
323
<xsl:template name="locale.html.attributes">
324
<xsl:apply-templates select="." mode="locale.html.attributes"/>
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"/>
333
<!-- Pass through any lang attributes -->
334
<xsl:template name="generate.html.lang">
335
<xsl:apply-templates select="." mode="html.lang.attribute"/>
338
<xsl:template match="*" mode="html.lang.attribute">
339
<!-- match the attribute name to the output type -->
341
<xsl:when test="@lang and $stylesheet.result.type = 'html'">
342
<xsl:attribute name="lang">
343
<xsl:value-of select="@lang"/>
346
<xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
347
<xsl:attribute name="xml:lang">
348
<xsl:value-of select="@lang"/>
351
<xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
352
<xsl:attribute name="lang">
353
<xsl:value-of select="@xml:lang"/>
356
<xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
357
<xsl:attribute name="xml:lang">
358
<xsl:value-of select="@xml:lang"/>
364
<!-- ==================================================================== -->
365
<!-- Insert link to css or insert literal CSS in head element -->
366
<xsl:template name="generate.css">
368
<xsl:when test="$generate.css.header = 0">
369
<xsl:call-template name="generate.css.links"/>
372
<xsl:call-template name="generate.css.headers"/>
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"/>
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]"/>
387
<xsl:call-template name="output.css.header">
388
<xsl:with-param name="css.node" select="$css.node"/>
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]"/>
398
<xsl:call-template name="output.css.header">
399
<xsl:with-param name="css.node" select="$css.node"/>
404
<xsl:template name="output.css.header">
405
<xsl:param name="css.node"/>
408
<xsl:when test="count($css.node) = 0">
411
<style type="text/css">
412
<xsl:copy-of select="$css.node/text()"/>
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"/>
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"/>
432
<xsl:call-template name="make.css.link">
433
<xsl:with-param name="css.filename" select="$filename"/>
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"/>
446
<xsl:call-template name="make.css.link">
447
<xsl:with-param name="css.filename" select="$filename"/>
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="''"/>
457
<xsl:variable name="href.to.uri" select="$css.filename"/>
459
<xsl:variable name="href.from.uri">
460
<xsl:call-template name="href.target.uri">
461
<xsl:with-param name="object" select="."/>
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'"/>
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'"/>
480
<xsl:variable name="depth">
481
<xsl:call-template name="count.uri.path.depth">
482
<xsl:with-param name="filename" select="$href.from"/>
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"/>
490
<xsl:value-of select="$href.to"/>
493
<xsl:if test="string-length($css.filename) != 0">
494
<link rel="stylesheet" type="text/css" href="{$href}"/>
498
<!-- ==================================================================== -->
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"/>
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]"/>
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"/>
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]"/>
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"/>
529
<xsl:template name="generate.css.file">
530
<xsl:param name="css.node"/>
531
<xsl:param name="src" select="''"/>
533
<xsl:variable name="css.text" select="$css.node/text()"/>
536
<xsl:when test="count($css.node) = 0">
538
<xsl:text>ERROR: no root element for CSS source file'</xsl:text>
539
<xsl:value-of select="$src"/>
540
<xsl:text>'.</xsl:text>
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"/>
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"/>
560
<xsl:template name="css.output.filename">
561
<xsl:param name="content"/>
562
<xsl:param name="src" select="''"/>
564
<xsl:variable name="candidate">
566
<xsl:when test="string-length($src) = 0">
568
<xsl:text>ERROR: missing CSS input filename.</xsl:text>
571
<xsl:when test="substring($src,string-length($src)-3) = '.xml'">
572
<xsl:value-of select="substring($src, 1, string-length($src) - 4)"/>
575
<xsl:value-of select="$src"/>
579
<xsl:value-of select="$candidate"/>
582
<xsl:template name="css.output.pathname">
583
<xsl:param name="content"/>
584
<xsl:param name="src" select="''"/>
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"/>
593
<xsl:variable name="path" select="concat($base.dir, $file)"/>
594
<xsl:value-of select="$path"/>