2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: html.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <!-- The generate.html.title template is currently used for generating HTML -->
16 <!-- "title" attributes for some inline elements only, but not for any -->
17 <!-- block elements. It is called in eleven places in the inline.xsl -->
18 <!-- file. But it's called by all the inline.* templates (e.g., -->
19 <!-- inline.boldseq), which in turn are called by other (element) -->
20 <!-- templates, so it results, currently, in supporting generation of the -->
21 <!-- HTML "title" attribute for a total of about 92 elements. -->
22 <!-- You can use mode="html.title.attribute" to get a title for -->
23 <!-- an element specified by a param, including targets of cross references. -->
24 <xsl:template name=
"generate.html.title">
25 <xsl:apply-templates select=
"." mode=
"html.title.attribute"/>
28 <!-- Generate a title attribute for the context node -->
29 <xsl:template match=
"*" mode=
"html.title.attribute">
30 <xsl:variable name=
"is.title">
31 <xsl:call-template name=
"gentext.template.exists">
32 <xsl:with-param name=
"context" select=
"'title'"/>
33 <xsl:with-param name=
"name" select=
"local-name(.)"/>
34 <xsl:with-param name=
"lang">
35 <xsl:call-template name=
"l10n.language"/>
40 <xsl:variable name=
"is.title-numbered">
41 <xsl:call-template name=
"gentext.template.exists">
42 <xsl:with-param name=
"context" select=
"'title-numbered'"/>
43 <xsl:with-param name=
"name" select=
"local-name(.)"/>
44 <xsl:with-param name=
"lang">
45 <xsl:call-template name=
"l10n.language"/>
50 <xsl:variable name=
"is.title-unnumbered">
51 <xsl:call-template name=
"gentext.template.exists">
52 <xsl:with-param name=
"context" select=
"'title-unnumbered'"/>
53 <xsl:with-param name=
"name" select=
"local-name(.)"/>
54 <xsl:with-param name=
"lang">
55 <xsl:call-template name=
"l10n.language"/>
60 <xsl:variable name=
"gentext.title">
61 <xsl:if test=
"$is.title != 0 or
62 $is.title-numbered != 0 or
63 $is.title-unnumbered != 0">
64 <xsl:apply-templates select=
"."
65 mode=
"object.title.markup.textonly"/>
70 <xsl:when test=
"string-length($gentext.title) != 0">
71 <xsl:attribute name=
"title">
72 <xsl:value-of select=
"$gentext.title"/>
75 <!-- Fall back to alt if available -->
77 <xsl:attribute name=
"title">
78 <xsl:value-of select=
"normalize-space(alt)"/>
85 <xsl:template name=
"dir">
86 <xsl:param name=
"inherit" select=
"0"/>
88 <xsl:variable name=
"dir">
90 <xsl:when test=
"@dir">
91 <xsl:value-of select=
"@dir"/>
93 <xsl:when test=
"$inherit != 0">
94 <xsl:value-of select=
"ancestor::*/@dir[1]"/>
99 <xsl:if test=
"$dir != ''">
100 <xsl:attribute name=
"dir">
101 <xsl:value-of select=
"$dir"/>
106 <xsl:template name=
"anchor">
107 <xsl:param name=
"node" select=
"."/>
108 <xsl:param name=
"conditional" select=
"1"/>
109 <xsl:variable name=
"id">
110 <xsl:call-template name=
"object.id">
111 <xsl:with-param name=
"object" select=
"$node"/>
114 <xsl:if test=
"$conditional = 0 or $node/@id or $node/@xml:id">
119 <xsl:template name=
"href.target.uri">
120 <xsl:param name=
"context" select=
"."/>
121 <xsl:param name=
"object" select=
"."/>
122 <xsl:text>#
</xsl:text>
123 <xsl:call-template name=
"object.id">
124 <xsl:with-param name=
"object" select=
"$object"/>
128 <xsl:template name=
"href.target">
129 <xsl:param name=
"context" select=
"."/>
130 <xsl:param name=
"object" select=
"."/>
131 <xsl:text>#
</xsl:text>
132 <xsl:call-template name=
"object.id">
133 <xsl:with-param name=
"object" select=
"$object"/>
137 <xsl:template name=
"href.target.with.base.dir">
138 <xsl:param name=
"context" select=
"."/>
139 <xsl:param name=
"object" select=
"."/>
140 <xsl:if test=
"$manifest.in.base.dir = 0">
141 <xsl:value-of select=
"$base.dir"/>
143 <xsl:call-template name=
"href.target">
144 <xsl:with-param name=
"context" select=
"$context"/>
145 <xsl:with-param name=
"object" select=
"$object"/>
149 <xsl:template name=
"dingbat">
150 <xsl:param name=
"dingbat">bullet
</xsl:param>
151 <xsl:call-template name=
"dingbat.characters">
152 <xsl:with-param name=
"dingbat" select=
"$dingbat"/>
156 <xsl:template name=
"dingbat.characters">
157 <!-- now that I'm using the real serializer, all that dingbat malarky -->
158 <!-- isn't necessary anymore... -->
159 <xsl:param name=
"dingbat">bullet
</xsl:param>
161 <xsl:when test=
"$dingbat='bullet'">•</xsl:when>
162 <xsl:when test=
"$dingbat='copyright'">©</xsl:when>
163 <xsl:when test=
"$dingbat='trademark'">™</xsl:when>
164 <xsl:when test=
"$dingbat='trade'">™</xsl:when>
165 <xsl:when test=
"$dingbat='registered'">®</xsl:when>
166 <xsl:when test=
"$dingbat='service'">(SM)
</xsl:when>
167 <xsl:when test=
"$dingbat='nbsp'"> </xsl:when>
168 <xsl:when test=
"$dingbat='ldquo'">“</xsl:when>
169 <xsl:when test=
"$dingbat='rdquo'">”</xsl:when>
170 <xsl:when test=
"$dingbat='lsquo'">‘</xsl:when>
171 <xsl:when test=
"$dingbat='rsquo'">’</xsl:when>
172 <xsl:when test=
"$dingbat='em-dash'">—</xsl:when>
173 <xsl:when test=
"$dingbat='mdash'">—</xsl:when>
174 <xsl:when test=
"$dingbat='en-dash'">–</xsl:when>
175 <xsl:when test=
"$dingbat='ndash'">–</xsl:when>
177 <xsl:text>•</xsl:text>
182 <xsl:template name=
"id.warning">
183 <xsl:if test=
"$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
184 <xsl:variable name=
"title">
186 <xsl:when test=
"title">
187 <xsl:value-of select=
"title[1]"/>
189 <xsl:when test=
"substring(local-name(*[1]),
190 string-length(local-name(*[1])-3) = 'info')
192 <xsl:value-of select=
"*[1]/title[1]"/>
194 <xsl:when test=
"refmeta/refentrytitle">
195 <xsl:value-of select=
"refmeta/refentrytitle"/>
197 <xsl:when test=
"refnamediv/refname">
198 <xsl:value-of select=
"refnamediv/refname[1]"/>
204 <xsl:text>ID recommended on
</xsl:text>
205 <xsl:value-of select=
"local-name(.)"/>
206 <xsl:if test=
"$title != ''">
207 <xsl:text>:
</xsl:text>
209 <xsl:when test=
"string-length($title) > 40">
210 <xsl:value-of select=
"substring($title,1,40)"/>
211 <xsl:text>...
</xsl:text>
214 <xsl:value-of select=
"$title"/>
222 <xsl:template match=
"*" mode=
"class.attribute">
223 <xsl:param name=
"class" select=
"local-name(.)"/>
224 <!-- permit customization of class attributes -->
225 <!-- Use element name by default -->
226 <xsl:attribute name=
"class">
227 <xsl:apply-templates select=
"." mode=
"class.value">
228 <xsl:with-param name=
"class" select=
"$class"/>
229 </xsl:apply-templates>
233 <xsl:template match=
"*" mode=
"class.value">
234 <xsl:param name=
"class" select=
"local-name(.)"/>
235 <!-- permit customization of class value only -->
236 <!-- Use element name by default -->
237 <xsl:value-of select=
"$class"/>