1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="d" version="1.0">
3 <!-- ********************************************************************
5 This file is part of the XSL DocBook Stylesheet distribution.
6 See ../README or http://cdn.docbook.org/release/xsl/current/ for
7 copyright and other information.
9 ******************************************************************** -->
11 <!-- These variables set the align attribute value for HTML output based on
12 the writing-mode specified in the gentext file for the document's lang. -->
14 <xsl:variable name="direction.align.start">
16 <xsl:when test="starts-with($writing.mode, 'lr')">left</xsl:when>
17 <xsl:when test="starts-with($writing.mode, 'rl')">right</xsl:when>
18 <xsl:otherwise>left</xsl:otherwise>
22 <xsl:variable name="direction.align.end">
24 <xsl:when test="starts-with($writing.mode, 'lr')">right</xsl:when>
25 <xsl:when test="starts-with($writing.mode, 'rl')">left</xsl:when>
26 <xsl:otherwise>right</xsl:otherwise>
30 <xsl:variable name="direction.mode">
32 <xsl:when test="starts-with($writing.mode, 'lr')">ltr</xsl:when>
33 <xsl:when test="starts-with($writing.mode, 'rl')">rtl</xsl:when>
34 <xsl:otherwise>ltr</xsl:otherwise>
38 <!-- Support switching to <section> for HTML5 stylesheet -->
39 <!-- This is an internal variable that does not need to be set by a user -->
40 <xsl:variable name="div.element">div</xsl:variable>
41 <!-- Support turning off table border with border="" for HTML5 -->
42 <xsl:variable name="table.border.off">0</xsl:variable>
44 <!-- The generate.html.title template is currently used for generating HTML -->
45 <!-- "title" attributes for some inline elements only, but not for any -->
46 <!-- block elements. It is called in eleven places in the inline.xsl -->
47 <!-- file. But it's called by all the inline.* templates (e.g., -->
48 <!-- inline.boldseq), which in turn are called by other (element) -->
49 <!-- templates, so it results, currently, in supporting generation of the -->
50 <!-- HTML "title" attribute for a total of about 92 elements. -->
51 <!-- You can use mode="html.title.attribute" to get a title for -->
52 <!-- an element specified by a param, including targets of cross references. -->
53 <xsl:template name="generate.html.title">
54 <xsl:apply-templates select="." mode="html.title.attribute"/>
57 <xsl:template match="d:acronym|d:abbrev" mode="html.title.attribute">
59 <xsl:attribute name="title">
60 <xsl:value-of select="normalize-space(d:alt)"/>
65 <!-- Generate a title attribute for the context node -->
66 <!-- This may be the target of an xref -->
67 <xsl:template match="*" mode="html.title.attribute">
68 <xsl:variable name="is.title">
69 <xsl:call-template name="gentext.template.exists">
70 <xsl:with-param name="context" select="'title'"/>
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-numbered">
79 <xsl:call-template name="gentext.template.exists">
80 <xsl:with-param name="context" select="'title-numbered'"/>
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="is.title-unnumbered">
89 <xsl:call-template name="gentext.template.exists">
90 <xsl:with-param name="context" select="'title-unnumbered'"/>
91 <xsl:with-param name="name" select="local-name(.)"/>
92 <xsl:with-param name="lang">
93 <xsl:call-template name="l10n.language"/>
98 <xsl:variable name="has.title.markup">
99 <xsl:apply-templates select="." mode="title.markup">
100 <xsl:with-param name="verbose" select="0"/>
101 </xsl:apply-templates>
104 <xsl:variable name="gentext.title">
105 <xsl:if test="$has.title.markup != '???TITLE???' and ($is.title != 0 or $is.title-numbered != 0 or $is.title-unnumbered != 0)">
106 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
111 <xsl:when test="string-length($gentext.title) != 0">
112 <xsl:attribute name="title">
113 <xsl:value-of select="$gentext.title"/>
116 <!-- Fall back to alt if available -->
117 <xsl:when test="d:alt">
118 <xsl:attribute name="title">
119 <xsl:value-of select="normalize-space(d:alt)"/>
125 <xsl:template match="d:qandaentry" mode="html.title.attribute">
126 <xsl:apply-templates select="d:question" mode="html.title.attribute"/>
129 <xsl:template match="d:question" mode="html.title.attribute">
130 <xsl:variable name="label.text">
131 <xsl:apply-templates select="." mode="qanda.label"/>
135 <xsl:when test="string-length($label.text) != 0">
136 <xsl:attribute name="title">
137 <xsl:value-of select="$label.text"/>
140 <!-- Fall back to alt if available -->
141 <xsl:when test="d:alt">
142 <xsl:attribute name="title">
143 <xsl:value-of select="normalize-space(d:alt)"/>
149 <xsl:template name="dir">
150 <xsl:param name="inherit" select="0"/>
152 <xsl:variable name="dir">
154 <xsl:when test="@dir">
155 <xsl:value-of select="@dir"/>
157 <xsl:when test="$inherit != 0">
158 <xsl:value-of select="ancestor::*/@dir[1]"/>
163 <xsl:if test="$dir != ''">
164 <xsl:attribute name="dir">
165 <xsl:value-of select="$dir"/>
170 <xsl:template name="anchor">
171 <xsl:param name="node" select="."/>
172 <xsl:param name="conditional" select="1"/>
175 <xsl:when test="$generate.id.attributes != 0">
176 <!-- No named anchors output when this param is set -->
178 <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
180 <xsl:attribute name="id">
181 <xsl:call-template name="object.id">
182 <xsl:with-param name="object" select="$node"/>
190 <xsl:template name="id.attribute">
191 <xsl:param name="node" select="."/>
192 <xsl:param name="conditional" select="1"/>
194 <xsl:when test="$generate.id.attributes = 0">
195 <!-- No id attributes when this param is zero -->
197 <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
198 <xsl:attribute name="id">
199 <xsl:call-template name="object.id">
200 <xsl:with-param name="object" select="$node"/>
207 <xsl:template name="href.target.uri">
208 <xsl:param name="context" select="."/>
209 <xsl:param name="object" select="."/>
210 <xsl:text>#</xsl:text>
211 <xsl:call-template name="object.id">
212 <xsl:with-param name="object" select="$object"/>
216 <xsl:template name="href.target">
217 <xsl:param name="context" select="."/>
218 <xsl:param name="object" select="."/>
219 <xsl:text>#</xsl:text>
220 <xsl:call-template name="object.id">
221 <xsl:with-param name="object" select="$object"/>
225 <xsl:template name="href.target.with.base.dir">
226 <xsl:param name="context" select="."/>
227 <xsl:param name="object" select="."/>
228 <xsl:if test="$manifest.in.base.dir = 0">
229 <xsl:value-of select="$chunk.base.dir"/>
231 <xsl:call-template name="href.target">
232 <xsl:with-param name="context" select="$context"/>
233 <xsl:with-param name="object" select="$object"/>
237 <xsl:template name="dingbat">
238 <xsl:param name="dingbat">bullet</xsl:param>
239 <xsl:call-template name="dingbat.characters">
240 <xsl:with-param name="dingbat" select="$dingbat"/>
244 <xsl:template name="dingbat.characters">
245 <!-- now that I'm using the real serializer, all that dingbat malarky -->
246 <!-- isn't necessary anymore... -->
247 <xsl:param name="dingbat">bullet</xsl:param>
249 <xsl:when test="$dingbat='bullet'">•</xsl:when>
250 <xsl:when test="$dingbat='copyright'">©</xsl:when>
251 <xsl:when test="$dingbat='trademark'">™</xsl:when>
252 <xsl:when test="$dingbat='trade'">™</xsl:when>
253 <xsl:when test="$dingbat='registered'">®</xsl:when>
254 <xsl:when test="$dingbat='service'">(SM)</xsl:when>
255 <xsl:when test="$dingbat='nbsp'"> </xsl:when>
256 <xsl:when test="$dingbat='ldquo'">“</xsl:when>
257 <xsl:when test="$dingbat='rdquo'">”</xsl:when>
258 <xsl:when test="$dingbat='lsquo'">‘</xsl:when>
259 <xsl:when test="$dingbat='rsquo'">’</xsl:when>
260 <xsl:when test="$dingbat='em-dash'">—</xsl:when>
261 <xsl:when test="$dingbat='mdash'">—</xsl:when>
262 <xsl:when test="$dingbat='en-dash'">–</xsl:when>
263 <xsl:when test="$dingbat='ndash'">–</xsl:when>
265 <xsl:text>•</xsl:text>
270 <xsl:template name="id.warning">
271 <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
272 <xsl:variable name="title">
274 <xsl:when test="d:title">
275 <xsl:value-of select="d:title[1]"/>
277 <xsl:when test="substring(local-name(*[1]), string-length(local-name(*[1])-3) = 'info') and *[1]/d:title">
278 <xsl:value-of select="*[1]/d:title[1]"/>
280 <xsl:when test="d:refmeta/d:refentrytitle">
281 <xsl:value-of select="d:refmeta/d:refentrytitle"/>
283 <xsl:when test="d:refnamediv/d:refname">
284 <xsl:value-of select="d:refnamediv/d:refname[1]"/>
290 <xsl:text>ID recommended on </xsl:text>
291 <xsl:value-of select="local-name(.)"/>
292 <xsl:if test="$title != ''">
293 <xsl:text>: </xsl:text>
295 <xsl:when test="string-length($title) > 40">
296 <xsl:value-of select="substring($title,1,40)"/>
297 <xsl:text>...</xsl:text>
300 <xsl:value-of select="$title"/>
308 <xsl:template name="generate.class.attribute">
309 <xsl:param name="class" select="local-name(.)"/>
310 <xsl:apply-templates select="." mode="class.attribute">
311 <xsl:with-param name="class" select="$class"/>
312 </xsl:apply-templates>
315 <xsl:template match="*" mode="class.attribute">
316 <xsl:param name="class" select="local-name(.)"/>
317 <!-- permit customization of class attributes -->
318 <!-- Use element name by default -->
319 <xsl:variable name="class.value">
320 <xsl:apply-templates select="." mode="class.value">
321 <xsl:with-param name="class" select="$class"/>
322 </xsl:apply-templates>
325 <xsl:if test="string-length(normalize-space($class.value)) != 0">
326 <xsl:attribute name="class">
327 <xsl:value-of select="$class.value"/>
332 <xsl:template match="*" mode="class.value">
333 <xsl:param name="class" select="local-name(.)"/>
334 <!-- permit customization of class value only -->
335 <!-- Use element name by default -->
336 <xsl:value-of select="$class"/>
339 <!-- Apply common attributes such as class, lang, dir -->
340 <xsl:template name="common.html.attributes">
341 <xsl:param name="inherit" select="0"/>
342 <xsl:param name="class" select="local-name(.)"/>
343 <xsl:apply-templates select="." mode="common.html.attributes">
344 <xsl:with-param name="class" select="$class"/>
345 <xsl:with-param name="inherit" select="$inherit"/>
346 </xsl:apply-templates>
349 <xsl:template match="*" mode="common.html.attributes">
350 <xsl:param name="class" select="local-name(.)"/>
351 <xsl:param name="inherit" select="0"/>
352 <xsl:call-template name="generate.html.lang"/>
353 <xsl:call-template name="dir">
354 <xsl:with-param name="inherit" select="$inherit"/>
356 <xsl:apply-templates select="." mode="class.attribute">
357 <xsl:with-param name="class" select="$class"/>
358 </xsl:apply-templates>
359 <xsl:call-template name="its.attributes">
360 <xsl:with-param name="inherit" select="$inherit"/>
364 <!-- Apply common attributes not including class -->
365 <xsl:template name="locale.html.attributes">
366 <xsl:apply-templates select="." mode="locale.html.attributes"/>
369 <xsl:template match="*" mode="locale.html.attributes">
370 <xsl:call-template name="generate.html.lang"/>
371 <xsl:call-template name="dir"/>
372 <xsl:call-template name="its.attributes"/>
375 <!-- Pass through any lang attributes -->
376 <xsl:template name="generate.html.lang">
377 <xsl:apply-templates select="." mode="html.lang.attribute"/>
380 <xsl:template match="*" mode="html.lang.attribute">
381 <!-- match the attribute name to the output type -->
383 <xsl:when test="@lang and $stylesheet.result.type = 'html'">
384 <xsl:attribute name="lang">
385 <xsl:value-of select="@lang"/>
388 <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
389 <xsl:attribute name="xml:lang">
390 <xsl:value-of select="@lang"/>
393 <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
394 <xsl:attribute name="lang">
395 <xsl:value-of select="@xml:lang"/>
398 <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
399 <xsl:attribute name="xml:lang">
400 <xsl:value-of select="@xml:lang"/>
406 <!-- ==================================================================== -->
407 <!-- Insert link to css or insert literal CSS in head element -->
408 <xsl:template name="generate.css">
410 <xsl:when test="$generate.css.header = 0">
411 <xsl:call-template name="generate.css.links"/>
414 <xsl:call-template name="generate.css.headers"/>
419 <xsl:template name="generate.css.headers">
420 <xsl:call-template name="generate.default.css.header"/>
421 <xsl:call-template name="generate.custom.css.header"/>
424 <xsl:template name="generate.default.css.header">
425 <xsl:if test="$make.clean.html != 0 and $docbook.css.source != ''">
426 <!-- Select default file relative to stylesheet -->
427 <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
429 <xsl:call-template name="output.css.header">
430 <xsl:with-param name="css.node" select="$css.node"/>
435 <xsl:template name="generate.custom.css.header">
436 <xsl:if test="$custom.css.source != ''">
437 <!-- Select custom file relative to document -->
438 <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
440 <xsl:call-template name="output.css.header">
441 <xsl:with-param name="css.node" select="$css.node"/>
446 <xsl:template name="output.css.header">
447 <xsl:param name="css.node"/>
450 <xsl:when test="count($css.node) = 0">
453 <style type="text/css">
454 <xsl:copy-of select="$css.node/text()"/>
460 <!-- ==================================================================== -->
461 <xsl:template name="generate.css.links">
462 <xsl:call-template name="generate.default.css.link"/>
463 <xsl:call-template name="generate.custom.css.link"/>
466 <xsl:template name="generate.default.css.link">
467 <xsl:if test="$make.clean.html != 0 and $docbook.css.link != 0 and $docbook.css.source != ''">
468 <xsl:variable name="filename">
469 <xsl:call-template name="css.output.filename">
470 <xsl:with-param name="src" select="$docbook.css.source"/>
474 <xsl:call-template name="make.css.link">
475 <xsl:with-param name="css.filename" select="$filename"/>
480 <xsl:template name="generate.custom.css.link">
481 <xsl:if test="$custom.css.source != ''">
482 <xsl:variable name="filename">
483 <xsl:call-template name="css.output.filename">
484 <xsl:with-param name="src" select="$custom.css.source"/>
488 <xsl:call-template name="make.css.link">
489 <xsl:with-param name="css.filename" select="$filename"/>
494 <!-- a CSS link reference must take into account the relative
495 path to a CSS file when chunked HTML is output to more than one directory -->
496 <xsl:template name="make.css.link">
497 <xsl:param name="css.filename" select="''"/>
499 <xsl:variable name="href">
500 <xsl:call-template name="relative.path.link">
501 <xsl:with-param name="target.pathname" select="$css.filename"/>
505 <xsl:if test="string-length($css.filename) != 0">
506 <link rel="stylesheet" type="text/css" href="{$href}"/>
510 <!-- And the same applies to script links -->
511 <xsl:template name="make.script.link">
512 <xsl:param name="script.filename" select="''"/>
514 <xsl:variable name="src">
515 <xsl:call-template name="relative.path.link">
516 <xsl:with-param name="target.pathname" select="$script.filename"/>
520 <xsl:if test="string-length($script.filename) != 0">
522 <xsl:attribute name="src">
523 <xsl:value-of select="$src"/>
525 <xsl:attribute name="type">
526 <xsl:value-of select="$html.script.type"/>
528 <xsl:call-template name="other.script.attributes">
529 <xsl:with-param name="script.filename" select="$script.filename"/>
535 <xsl:template name="other.script.attributes">
536 <xsl:param name="script.filename"/>
537 <!-- Placeholder template to allow customization to
538 insert additional script element attributes if needed -->
541 <xsl:template name="relative.path.link">
542 <xsl:param name="target.pathname"/>
544 <xsl:variable name="href.to.uri" select="$target.pathname"/>
546 <xsl:variable name="href.from.uri">
547 <xsl:call-template name="href.target.uri">
548 <xsl:with-param name="object" select="."/>
552 <xsl:variable name="href.to">
553 <xsl:call-template name="trim.common.uri.paths">
554 <xsl:with-param name="uriA" select="$href.to.uri"/>
555 <xsl:with-param name="uriB" select="$href.from.uri"/>
556 <xsl:with-param name="return" select="'A'"/>
560 <xsl:variable name="href.from">
561 <xsl:call-template name="trim.common.uri.paths">
562 <xsl:with-param name="uriA" select="$href.to.uri"/>
563 <xsl:with-param name="uriB" select="$href.from.uri"/>
564 <xsl:with-param name="return" select="'B'"/>
567 <xsl:variable name="depth">
568 <xsl:call-template name="count.uri.path.depth">
569 <xsl:with-param name="filename" select="$href.from"/>
572 <xsl:variable name="href">
573 <xsl:call-template name="copy-string">
574 <xsl:with-param name="string" select="'../'"/>
575 <xsl:with-param name="count" select="$depth"/>
577 <xsl:value-of select="$href.to"/>
580 <xsl:value-of select="$href"/>
583 <!-- ==================================================================== -->
585 <xsl:template name="generate.css.files">
586 <xsl:call-template name="generate.default.css.file"/>
587 <xsl:call-template name="generate.custom.css.file"/>
590 <xsl:template name="generate.default.css.file">
591 <xsl:if test="$make.clean.html != 0 and $generate.css.header = 0 and $docbook.css.source != ''">
592 <!-- Select default file relative to stylesheet -->
593 <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
595 <xsl:call-template name="generate.css.file">
596 <xsl:with-param name="src" select="$docbook.css.source"/>
597 <xsl:with-param name="css.node" select="$css.node"/>
602 <xsl:template name="generate.custom.css.file">
603 <xsl:if test="$custom.css.source != '' and $generate.css.header = 0">
604 <!-- Select custom file relative to document -->
605 <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
607 <xsl:call-template name="generate.css.file">
608 <xsl:with-param name="src" select="$custom.css.source"/>
609 <xsl:with-param name="css.node" select="$css.node"/>
614 <xsl:template name="generate.css.file">
615 <xsl:param name="css.node"/>
616 <xsl:param name="src" select="''"/>
618 <xsl:variable name="css.text" select="$css.node/text()"/>
621 <xsl:when test="count($css.node) = 0">
623 <xsl:text>ERROR: no root element for CSS source file'</xsl:text>
624 <xsl:value-of select="$src"/>
625 <xsl:text>'.</xsl:text>
629 <xsl:variable name="filename">
630 <xsl:call-template name="css.output.pathname">
631 <xsl:with-param name="src" select="$src"/>
632 <xsl:with-param name="content" select="$css.node"/>
636 <xsl:call-template name="write.text.chunk">
637 <xsl:with-param name="filename" select="$filename"/>
638 <xsl:with-param name="content" select="$css.text"/>
645 <xsl:template name="css.output.filename">
646 <xsl:param name="content"/>
647 <xsl:param name="src" select="''"/>
649 <xsl:variable name="candidate">
651 <xsl:when test="string-length($src) = 0">
653 <xsl:text>ERROR: missing CSS input filename.</xsl:text>
656 <xsl:when test="substring($src,string-length($src)-3) = '.xml'">
657 <xsl:value-of select="substring($src, 1, string-length($src) - 4)"/>
660 <xsl:value-of select="$src"/>
664 <xsl:value-of select="$candidate"/>
667 <xsl:template name="css.output.pathname">
668 <xsl:param name="content"/>
669 <xsl:param name="src" select="''"/>
671 <xsl:variable name="file">
672 <xsl:call-template name="css.output.filename">
673 <xsl:with-param name="content" select="$content"/>
674 <xsl:with-param name="src" select="$src"/>
678 <xsl:variable name="path" select="concat($chunk.base.dir, $file)"/>
679 <xsl:value-of select="$path"/>