]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/xhtml-1_1/html.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / xhtml-1_1 / html.xsl
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">
5
6 <!-- ********************************************************************
7      $Id: html.xsl 8421 2009-05-04 07:49:49Z bobstayton $
8      ********************************************************************
9
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.
13
14      ******************************************************************** -->
15
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. -->
18
19 <xsl:variable name="direction.align.start">
20   <xsl:choose>
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>
24   </xsl:choose>
25 </xsl:variable>
26
27 <xsl:variable name="direction.align.end">
28   <xsl:choose>
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>
32   </xsl:choose>
33 </xsl:variable>
34
35 <xsl:variable name="direction.mode">
36   <xsl:choose>
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>
40   </xsl:choose>
41 </xsl:variable>
42
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"/>
54 </xsl:template>
55
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"/>
64       </xsl:with-param>
65     </xsl:call-template>
66   </xsl:variable>
67
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"/>
74       </xsl:with-param>
75     </xsl:call-template>
76   </xsl:variable>
77
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"/>
84       </xsl:with-param>
85     </xsl:call-template>
86   </xsl:variable>
87
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>
92   </xsl:variable>
93
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"/>
97     </xsl:if>
98   </xsl:variable>
99
100   <xsl:choose>
101     <xsl:when test="string-length($gentext.title) != 0">
102       <xsl:attribute name="title">
103         <xsl:value-of select="$gentext.title"/>
104       </xsl:attribute>
105     </xsl:when>
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)"/>
110       </xsl:attribute>
111     </xsl:when>
112   </xsl:choose>
113 </xsl:template>
114
115 <xsl:template match="qandaentry" mode="html.title.attribute">
116   <xsl:apply-templates select="question" mode="html.title.attribute"/>
117 </xsl:template>
118
119 <xsl:template match="question" mode="html.title.attribute">
120   <xsl:variable name="label.text">
121     <xsl:apply-templates select="." mode="qanda.label"/>
122   </xsl:variable>
123
124   <xsl:choose>
125     <xsl:when test="string-length($label.text) != 0">
126       <xsl:attribute name="title">
127         <xsl:value-of select="$label.text"/>
128       </xsl:attribute>
129     </xsl:when>
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)"/>
134       </xsl:attribute>
135     </xsl:when>
136   </xsl:choose>
137 </xsl:template>
138
139 <xsl:template name="dir">
140   <xsl:param name="inherit" select="0"/>
141
142   <xsl:variable name="dir">
143     <xsl:choose>
144       <xsl:when test="@dir">
145         <xsl:value-of select="@dir"/>
146       </xsl:when>
147       <xsl:when test="$inherit != 0">
148         <xsl:value-of select="ancestor::*/@dir[1]"/>
149       </xsl:when>
150     </xsl:choose>
151   </xsl:variable>
152
153   <xsl:if test="$dir != ''">
154     <xsl:attribute name="dir">
155       <xsl:value-of select="$dir"/>
156     </xsl:attribute>
157   </xsl:if>
158 </xsl:template>
159
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"/>
166     </xsl:call-template>
167   </xsl:variable>
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">
169     <a id="{$id}"/>
170   </xsl:if></xslo:if>
171 </xsl:template>
172
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"/>
179   </xsl:call-template>
180 </xsl:template>
181
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"/>
188   </xsl:call-template>
189 </xsl:template>
190
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"/>
196   </xsl:if>
197   <xsl:call-template name="href.target">
198     <xsl:with-param name="context" select="$context"/>
199     <xsl:with-param name="object" select="$object"/>
200   </xsl:call-template>
201 </xsl:template>
202
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"/>
207   </xsl:call-template>
208 </xsl:template>
209
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>
214   <xsl:choose>
215     <xsl:when test="$dingbat='bullet'">&#8226;</xsl:when>
216     <xsl:when test="$dingbat='copyright'">&#169;</xsl:when>
217     <xsl:when test="$dingbat='trademark'">&#8482;</xsl:when>
218     <xsl:when test="$dingbat='trade'">&#8482;</xsl:when>
219     <xsl:when test="$dingbat='registered'">&#174;</xsl:when>
220     <xsl:when test="$dingbat='service'">(SM)</xsl:when>
221     <xsl:when test="$dingbat='nbsp'">&#160;</xsl:when>
222     <xsl:when test="$dingbat='ldquo'">&#8220;</xsl:when>
223     <xsl:when test="$dingbat='rdquo'">&#8221;</xsl:when>
224     <xsl:when test="$dingbat='lsquo'">&#8216;</xsl:when>
225     <xsl:when test="$dingbat='rsquo'">&#8217;</xsl:when>
226     <xsl:when test="$dingbat='em-dash'">&#8212;</xsl:when>
227     <xsl:when test="$dingbat='mdash'">&#8212;</xsl:when>
228     <xsl:when test="$dingbat='en-dash'">&#8211;</xsl:when>
229     <xsl:when test="$dingbat='ndash'">&#8211;</xsl:when>
230     <xsl:otherwise>
231       <xsl:text>&#8226;</xsl:text>
232     </xsl:otherwise>
233   </xsl:choose>
234 </xsl:template>
235
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">
239       <xsl:choose>
240         <xsl:when test="title">
241           <xsl:value-of select="title[1]"/>
242         </xsl:when>
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]"/>
245         </xsl:when>
246         <xsl:when test="refmeta/refentrytitle">
247           <xsl:value-of select="refmeta/refentrytitle"/>
248         </xsl:when>
249         <xsl:when test="refnamediv/refname">
250           <xsl:value-of select="refnamediv/refname[1]"/>
251         </xsl:when>
252       </xsl:choose>
253     </xsl:variable>
254
255     <xsl:message>
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>
260         <xsl:choose>
261           <xsl:when test="string-length($title) &gt; 40">
262             <xsl:value-of select="substring($title,1,40)"/>
263             <xsl:text>...</xsl:text>
264           </xsl:when>
265           <xsl:otherwise>
266             <xsl:value-of select="$title"/>
267           </xsl:otherwise>
268         </xsl:choose>
269       </xsl:if>
270     </xsl:message>
271   </xsl:if>
272 </xsl:template>
273
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>
279 </xsl:template>
280
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>
289   </xsl:attribute>
290 </xsl:template>
291
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"/>
297 </xsl:template>
298
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>
307 </xsl:template>
308
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"/>
315   </xsl:call-template>
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"/>
320 </xsl:template>
321
322 <!-- Apply common attributes not including class -->
323 <xsl:template name="locale.html.attributes">
324   <xsl:apply-templates select="." mode="locale.html.attributes"/>
325 </xsl:template>
326
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"/>
331 </xsl:template>
332
333 <!-- Pass through any lang attributes -->
334 <xsl:template name="generate.html.lang">
335   <xsl:apply-templates select="." mode="html.lang.attribute"/>
336 </xsl:template>
337
338 <xsl:template match="*" mode="html.lang.attribute">
339   <!-- match the attribute name to the output type -->
340   <xsl:choose>
341     <xsl:when test="@lang and $stylesheet.result.type = 'html'">
342       <xsl:attribute name="lang">
343         <xsl:value-of select="@lang"/>
344       </xsl:attribute>
345     </xsl:when>
346     <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
347       <xsl:attribute name="xml:lang">
348         <xsl:value-of select="@lang"/>
349       </xsl:attribute>
350     </xsl:when>
351     <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
352       <xsl:attribute name="lang">
353         <xsl:value-of select="@xml:lang"/>
354       </xsl:attribute>
355     </xsl:when>
356     <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
357       <xsl:attribute name="xml:lang">
358         <xsl:value-of select="@xml:lang"/>
359       </xsl:attribute>
360     </xsl:when>
361   </xsl:choose>
362 </xsl:template>
363
364 </xsl:stylesheet>