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 8421 2009-05-04 07:49:49Z 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" xmlns:saxon="http://icl.com/saxon" 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"/>