19
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
xmlns:db="http://docbook.org/ns/docbook"
21
xmlns:msg="http://projects.gnome.org/yelp/gettext/"
20
22
xmlns:set="http://exslt.org/sets"
21
xmlns:msg="http://projects.gnome.org/yelp/gettext/"
22
xmlns:db="http://docbook.org/ns/docbook"
23
23
xmlns="http://www.w3.org/1999/xhtml"
24
24
exclude-result-prefixes="db msg set"
27
27
<!--!!==========================================================================
28
28
DocBook to HTML - Block Elements
29
:Requires: db-common db-xref db2html-xref gettext
29
:Revision:version="3.4" date="2011-11-12" status="final"
31
This module handles most simple block-level elements, turning them into the
32
appropriate HTML tags. It does not handle tables, lists, and various other
31
This stylesheet handles most simple block-level elements, turning them into
32
the appropriate HTML tags. It does not handle tables, lists, and various other
33
33
complex block-level elements.
37
37
<!--**==========================================================================
39
Renders a block-level element to an HTML #{div} tag
40
$node: The block-level element to render
41
$class: An extra string to insert in the #{class} attribute
42
$indent: Whether this block should be indented
43
$verbatim: Whether to maintain whitespace as written
44
$formal: Whether this is a formal block element
45
$title: When ${formal} is true, an element to use for the title
46
$caption: When ${formal} is true, an element to use for the caption
47
$lang: The locale of the text in ${node}
48
$dir: The text direction, either #{ltr} or #{rtl}
49
$ltr: Whether to default to #{ltr} if neither ${lang} nor ${dir} is specified
39
Output an HTML #{div} element for a block-level element.
40
:Revision:version="3.4" date="2011-11-12" status="final"
41
$node: The block-level element to render.
42
$class: The value of the HTML #{class} attribute.
51
44
This template creates an HTML #{div} element for the given DocBook element.
52
This template uses the parameters to construct the #{class} attribute, which
53
is then used by the CSS for styling.
45
If the ${class} parameter is not provided, it uses the local name of ${node}.
55
47
<xsl:template name="db2html.block">
56
48
<xsl:param name="node" select="."/>
57
<xsl:param name="class" select="''"/>
58
<xsl:param name="verbatim" select="$node[@xml:space = 'preserve']"/>
59
<xsl:param name="formal" select="false()"/>
60
<xsl:param name="title" select="$node/title | $node/db:title |
61
$node/db:info/db:title"/>
49
<xsl:param name="class" select="local-name($node)"/>
50
<div class="{$class}">
51
<xsl:call-template name="html.lang.attrs">
52
<xsl:with-param name="node" select="$node"/>
54
<xsl:call-template name="db2html.anchor">
55
<xsl:with-param name="node" select="$node"/>
57
<xsl:apply-templates select="$node/node()"/>
62
<!--**==========================================================================
64
Output HTML for a block-level element with an optional title and caption.
65
:Revision:version="3.4" date="2011-11-12" status="final"
66
$node: The block-level element to render.
67
$class: The value of the HTML #{class} attribute.
68
$title: An element to use for the title.
69
$caption: An element to use for the caption.
70
$titleattr: An optional value for the HTML #{title} attribute.
72
This template outputs HTML for a formal DocBook element, one that can have
73
a title or caption. If the ${class} parameter is not provided, it uses the
74
local name of ${node}. Even if ${title} and ${caption} are both empty, this
75
template still outputs the extra wrapper elements for formal elements. If
76
${titleattr} is provided, it is used for the value of the HTML #{title}
77
attribute on the outermost #{div} element.
79
<xsl:template name="db2html.block.formal">
80
<xsl:param name="node" select="."/>
81
<xsl:param name="class" select="local-name($node)"/>
82
<xsl:param name="title" select="$node/title | $node/blockinfo/title |
83
$node/db:title | $node/db:info/db:title"/>
62
84
<xsl:param name="caption" select="$node/caption | $node/db:caption"/>
63
<xsl:param name="lang" select="$node/@lang|$node/@xml:lang"/>
64
<xsl:param name="dir" select="false()"/>
65
<xsl:param name="ltr" select="false()"/>
85
<xsl:param name="titleattr" select="''"/>
68
<xsl:attribute name="class">
69
<xsl:value-of select="concat($class, ' ', local-name($node))"/>
70
<xsl:if test="$verbatim">
71
<xsl:text> verbatim</xsl:text>
75
<xsl:when test="$dir = 'ltr' or $dir = 'rtl'">
76
<xsl:attribute name="dir">
77
<xsl:value-of select="$dir"/>
80
<xsl:when test="$lang">
81
<xsl:attribute name="dir">
82
<xsl:call-template name="l10n.direction">
83
<xsl:with-param name="lang" select="$lang"/>
87
<xsl:when test="$ltr">
88
<xsl:attribute name="dir">
89
<xsl:text>ltr</xsl:text>
87
<div class="{$class}">
88
<xsl:if test="$titleattr != ''">
89
<xsl:attribute name="title">
90
<xsl:value-of select="$titleattr"/>
93
<xsl:call-template name="html.lang.attrs">
94
<xsl:with-param name="node" select="$node"/>
93
96
<xsl:call-template name="db2html.anchor">
94
97
<xsl:with-param name="node" select="$node"/>
95
98
</xsl:call-template>
97
<xsl:when test="$formal">
99
<xsl:if test="$node/self::figure or $node/self::db:figure">
100
<a href="#" class="zoom">
101
<xsl:attribute name="data-zoom-in-title">
102
<xsl:call-template name="l10n.gettext">
103
<xsl:with-param name="msgid" select="'View images at normal size'"/>
106
<xsl:attribute name="data-zoom-out-title">
107
<xsl:call-template name="l10n.gettext">
108
<xsl:with-param name="msgid" select="'Scale images down'"/>
113
<xsl:if test="$title">
114
<xsl:call-template name="db2html.block.title">
115
<xsl:with-param name="node" select="$node"/>
116
<xsl:with-param name="title" select="$title"/>
119
<div class="contents">
120
<xsl:apply-templates select="$node/node()[not(set:has-same-node(., $title | $caption))]"/>
122
<xsl:apply-templates select="$caption"/>
100
<xsl:if test="$node/self::figure or $node/self::db:figure">
101
<a href="#" class="zoom">
102
<xsl:attribute name="data-zoom-in-title">
103
<xsl:call-template name="l10n.gettext">
104
<xsl:with-param name="msgid" select="'View images at normal size'"/>
107
<xsl:attribute name="data-zoom-out-title">
108
<xsl:call-template name="l10n.gettext">
109
<xsl:with-param name="msgid" select="'Scale images down'"/>
114
<xsl:if test="$title">
115
<xsl:call-template name="db2html.block.title">
116
<xsl:with-param name="node" select="$node"/>
117
<xsl:with-param name="title" select="$title"/>
121
<div class="contents">
122
<xsl:apply-templates select="$node/node()[not(set:has-same-node(., $title | $caption))]"/>
126
<xsl:apply-templates select="$node/node()"/>
124
<xsl:apply-templates select="$caption"/>
133
131
<!--**==========================================================================
134
132
db2html.block.title
135
Renders a formal title for a block-level element
136
$node: The block-level element being processed
137
$title: The element containing the title
138
$lang: The locale of the text in ${title}
139
$dir: The text direction, either #{ltr} or #{rtl}
140
$ltr: Whether to default to #{ltr} if neither ${lang} nor ${dir} is specified
133
Output a formal title for a block-level element.
134
:Revision:version="3.4" date="2011-11-12" status="final"
135
$node: The block-level element being processed.
136
$title: The element containing the title.
142
138
This template formats the contents of ${title} as a title for a block-level
143
element. It is called by *{db2html.block} for formal block elements.
139
element. It is called by *{db2html.block.formal}.
145
141
<xsl:template name="db2html.block.title">
146
142
<xsl:param name="node" select="."/>
147
143
<xsl:param name="title" select="$node/title | $node/db:title"/>
148
<xsl:param name="lang" select="$title/@lang|$title/@xml:lang"/>
149
<xsl:param name="dir" select="false()"/>
150
<xsl:param name="ltr" select="false()"/>
151
144
<xsl:variable name="depth">
152
145
<xsl:call-template name="db.chunk.depth-in-chunk">
153
146
<xsl:with-param name="node" select="$node"/>
199
175
<!--**==========================================================================
200
176
db2html.blockquote
201
Renders a #{blockquote} element to HTML
202
$node: The #{blockquote} element to render
203
$lang: The locale of the text in ${node}
204
$dir: The text direction, either #{ltr} or #{rtl}
205
$ltr: Whether to default to #{ltr} if neither ${lang} nor ${dir} is specified
177
Output an HTML #{blockquote} element.
178
:Revision:version="3.4" date="2011-11-12" status="final"
179
$node: The DocBook element ot render as a quote.
207
181
This template creates an HTML #{blockquote} element for the given DocBook
182
element. It's used for the DocBook #{blockquote} and #{epigraph} elements.
210
184
<xsl:template name="db2html.blockquote">
211
185
<xsl:param name="node" select="."/>
212
<xsl:param name="lang" select="$node/@lang|node/@xml:lang"/>
213
<xsl:param name="dir" select="false()"/>
214
<xsl:param name="ltr" select="false()"/>
218
<xsl:when test="$dir = 'ltr' or $dir = 'rtl'">
219
<xsl:attribute name="dir">
220
<xsl:value-of select="$dir"/>
223
<xsl:when test="$lang">
224
<xsl:attribute name="dir">
225
<xsl:call-template name="l10n.direction">
226
<xsl:with-param name="lang" select="$lang"/>
230
<xsl:when test="$ltr">
231
<xsl:attribute name="dir">
232
<xsl:text>ltr</xsl:text>
236
187
<xsl:attribute name="class">
237
188
<xsl:text>quote </xsl:text>
238
189
<xsl:value-of select="local-name($node)"/>
191
<xsl:call-template name="html.lang.attrs">
192
<xsl:with-param name="node" select="$node"/>
240
194
<xsl:call-template name="db2html.anchor">
241
195
<xsl:with-param name="node" select="$node"/>
242
196
</xsl:call-template>
243
197
<div class="inner">
244
198
<xsl:apply-templates select="$node/title | $node/db:title |
245
199
$node/db:info/db:title"/>
246
<blockquote class="{local-name($node)}">
247
<xsl:apply-templates select="$node/node()[not(self::title) and not(self::attribution) and not(self::db:title) and not(self::db:attribution)]"/>
249
<xsl:apply-templates select="$node/attribution | $node/db:attribution"/>
201
<blockquote class="{local-name($node)}">
202
<xsl:apply-templates select="$node/node()[not(self::title) and not(self::attribution) and
203
not(self::db:title) and not(self::db:attribution)]"/>
205
<xsl:apply-templates select="$node/attribution | $node/db:attribution"/>
255
212
<!--**==========================================================================
257
Renders a block-level element as an HTML #{p} element
258
$node: The block-level element to render
259
$lang: The locale of the text in ${node}
260
$dir: The text direction, either #{ltr} or #{rtl}
261
$ltr: Whether to default to #{ltr} if neither ${lang} nor ${dir} is specified
262
$class: The value of the generated class attribute
214
Output an HTML #{p} element for a block-level element.
215
:Revision:version="3.4" date="2011-11-12" status="final"
216
$node: The block-level element to render.
217
$class: The value of the HTML #{class} attribute.
264
219
This template creates an HTML #{p} element for the given DocBook element.
220
If the ${class} parameter is not provided, it uses the local name of ${node}.
266
222
<xsl:template name="db2html.para">
267
223
<xsl:param name="node" select="."/>
268
<xsl:param name="lang" select="$node/@lang|$node/@xml:lang"/>
269
<xsl:param name="dir" select="false()"/>
270
<xsl:param name="ltr" select="false()"/>
271
224
<xsl:param name="class" select="local-name($node)"/>
274
<xsl:attribute name="class">
275
<xsl:value-of select="$class"/>
278
<xsl:when test="$dir = 'ltr' or $dir = 'rtl'">
279
<xsl:attribute name="dir">
280
<xsl:value-of select="$dir"/>
283
<xsl:when test="$lang">
284
<xsl:attribute name="dir">
285
<xsl:call-template name="l10n.direction">
286
<xsl:with-param name="lang" select="$lang"/>
290
<xsl:when test="$ltr">
291
<xsl:attribute name="dir">
292
<xsl:text>ltr</xsl:text>
226
<xsl:call-template name="html.lang.attrs">
227
<xsl:with-param name="node" select="$node"/>
296
229
<xsl:call-template name="db2html.anchor">
297
230
<xsl:with-param name="node" select="$node"/>
298
231
</xsl:call-template>
304
237
<!--**==========================================================================
306
Renders a block-level element as an HTML #{pre} element
307
$node: The block-level element to render
308
$class: An extra string to insert in the #{class} attribute
309
$children: The child elements to process
310
$lang: The locale of the text in ${node}
311
$dir: The text direction, either #{ltr} or #{rtl}
312
$ltr: Whether to default to #{ltr} if neither ${lang} nor ${dir} is specified
239
Output an HTML #{pre} element for a block-level element.
240
:Revision:version="3.4" date="2011-11-12" status="final"
241
$node: The block-level element to render.
242
$class: The value of the HTML #{class} attribute.
243
$children: The child elements to process.
314
245
This template creates an HTML #{pre} element for the given DocBook element.
315
This template uses the parameters to construct the #{class} attribute, which
316
is then used by the CSS for styling.
246
If the ${class} parameter is not provided, it uses the local name of ${node}.
318
248
If ${node} has the #{linenumbering} attribute set to #{"numbered"}, then this
319
249
template will create line numbers for each line, using the *{utils.linenumbering}
252
By default, this template applies templates to all child nodes. Pass child
253
nodes in the ${children} parameter to override this behavior.
255
If @{html.syntax.highlight} is #{true}, this template automatically outputs
256
syntax highlighting support based on the #{language} attribute of ${node}.
322
258
<xsl:template name="db2html.pre">
323
259
<xsl:param name="node" select="."/>
324
<xsl:param name="class" select="''"/>
260
<xsl:param name="class" select="local-name($node)"/>
325
261
<xsl:param name="children" select="$node/node()"/>
326
<xsl:param name="lang" select="$node/@lang|$node/@xml:lang"/>
327
<xsl:param name="dir" select="false()"/>
328
<xsl:param name="ltr" select="true()"/>
331
<xsl:attribute name="class">
332
<xsl:value-of select="concat($class, ' ', local-name($node))"/>
335
<xsl:when test="$dir = 'ltr' or $dir = 'rtl'">
336
<xsl:attribute name="dir">
337
<xsl:value-of select="$dir"/>
340
<xsl:when test="$lang">
341
<xsl:attribute name="dir">
342
<xsl:call-template name="l10n.direction">
343
<xsl:with-param name="lang" select="$lang"/>
347
<xsl:when test="$ltr">
348
<xsl:attribute name="dir">
349
<xsl:text>ltr</xsl:text>
262
<div class="{$class}">
263
<xsl:call-template name="html.lang.attrs">
264
<xsl:with-param name="node" select="$node"/>
353
266
<xsl:call-template name="db2html.anchor">
354
267
<xsl:with-param name="node" select="$node"/>
355
268
</xsl:call-template>
536
478
<!-- = formalpara = -->
537
479
<xsl:template match="formalpara | db:formalpara">
538
<xsl:call-template name="db2html.block">
539
<xsl:with-param name="formal" select="true()"/>
543
<!-- = glossdef = -->
544
<xsl:template match="glossdef | db:glossdef">
545
<dd class="glossdef">
546
<xsl:apply-templates select="*[not(self::glossseealso) and not(self::db:glossseealso)]"/>
548
<xsl:apply-templates select="glossseealso[1] | db:glossseealso[1]"/>
551
<!-- = glossentry = -->
552
<xsl:template match="glossentry | db:glossentry">
554
<xsl:attribute name="class">
555
<xsl:text>glossterm</xsl:text>
557
<xsl:apply-templates select="glossterm | db:glossterm"/>
558
<xsl:if test="acronym or abbrev or db:acronym or db:abbrev">
559
<xsl:text> </xsl:text>
560
<xsl:call-template name="l10n.gettext">
561
<xsl:with-param name="msgid" select="'glossentry.abbrev.format'"/>
562
<xsl:with-param name="node" select="(acronym | abbrev | db:acronym | db:abbrev)[1]"/>
563
<xsl:with-param name="format" select="true()"/>
567
<xsl:apply-templates select="glossdef | glosssee[1] | db:glossdef | db:glosssee[1]"/>
570
<!-- = glosssee(also) = -->
571
<xsl:template match="glosssee | glossseealso | db:glosssee | db:glossseealso">
572
<dd class="{local-name(.)}">
574
<xsl:call-template name="l10n.gettext">
575
<xsl:with-param name="msgid" select="concat(local-name(.), '.format')"/>
576
<xsl:with-param name="node" select="."/>
577
<xsl:with-param name="format" select="true()"/>
583
<!--#% l10n.format.mode -->
584
<xsl:template mode="l10n.format.mode" match="msg:glosssee">
585
<xsl:param name="node"/>
586
<xsl:for-each select="$node |
587
$node/following-sibling::*[name(.) = name($node)]">
588
<xsl:if test="position() != 1">
589
<xsl:call-template name="l10n.gettext">
590
<xsl:with-param name="msgid" select="', '"/>
594
<xsl:when test="@otherterm">
596
<xsl:attribute name="href">
597
<xsl:call-template name="db.xref.target">
598
<xsl:with-param name="linkend" select="@otherterm"/>
601
<xsl:attribute name="title">
602
<xsl:call-template name="db.xref.tooltip">
603
<xsl:with-param name="linkend" select="@otherterm"/>
607
<xsl:when test="normalize-space(.) != ''">
608
<xsl:apply-templates/>
611
<xsl:call-template name="db.xref.content">
612
<xsl:with-param name="linkend" select="@otherterm"/>
613
<xsl:with-param name="role" select="'glosssee'"/>
620
<xsl:apply-templates/>
480
<xsl:call-template name="db2html.block.formal"/>
626
483
<!-- = highlights = -->