1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version='1.0'>
4
5<!-- ********************************************************************
6     $Id: html.xsl,v 1.17 2005/12/14 11:50:56 nwalsh Exp $
7     ********************************************************************
8
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.
12
13     ******************************************************************** -->
14
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<xsl:template name="generate.html.title">
23  <xsl:if test="alt">
24    <xsl:attribute name="title">
25      <xsl:value-of select="normalize-space(alt)"/>
26    </xsl:attribute>
27  </xsl:if>
28</xsl:template>
29
30<xsl:template name="dir">
31  <xsl:param name="inherit" select="0"/>
32
33  <xsl:variable name="dir">
34    <xsl:choose>
35      <xsl:when test="@dir">
36	<xsl:value-of select="@dir"/>
37      </xsl:when>
38      <xsl:when test="$inherit != 0">
39	<xsl:value-of select="ancestor::*/@dir[1]"/>
40      </xsl:when>
41    </xsl:choose>
42  </xsl:variable>
43
44  <xsl:if test="$dir != ''">
45    <xsl:attribute name="dir">
46      <xsl:value-of select="$dir"/>
47    </xsl:attribute>
48  </xsl:if>
49</xsl:template>
50
51<xsl:template name="anchor">
52  <xsl:param name="node" select="."/>
53  <xsl:param name="conditional" select="1"/>
54  <xsl:variable name="id">
55    <xsl:call-template name="object.id">
56      <xsl:with-param name="object" select="$node"/>
57    </xsl:call-template>
58  </xsl:variable>
59  <xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id">
60    <a name="{$id}"/>
61  </xsl:if>
62</xsl:template>
63
64<xsl:template name="href.target.uri">
65  <xsl:param name="context" select="."/>
66  <xsl:param name="object" select="."/>
67  <xsl:text>#</xsl:text>
68  <xsl:call-template name="object.id">
69    <xsl:with-param name="object" select="$object"/>
70  </xsl:call-template>
71</xsl:template>
72
73<xsl:template name="href.target">
74  <xsl:param name="context" select="."/>
75  <xsl:param name="object" select="."/>
76  <xsl:text>#</xsl:text>
77  <xsl:call-template name="object.id">
78    <xsl:with-param name="object" select="$object"/>
79  </xsl:call-template>
80</xsl:template>
81
82<xsl:template name="href.target.with.base.dir">
83  <xsl:param name="object" select="."/>
84  <xsl:if test="$manifest.in.base.dir = 0">
85    <xsl:value-of select="$base.dir"/>
86  </xsl:if>
87  <xsl:call-template name="href.target">
88    <xsl:with-param name="object" select="$object"/>
89  </xsl:call-template>
90</xsl:template>
91
92<xsl:template name="dingbat">
93  <xsl:param name="dingbat">bullet</xsl:param>
94  <xsl:call-template name="dingbat.characters">
95    <xsl:with-param name="dingbat" select="$dingbat"/>
96  </xsl:call-template>
97</xsl:template>
98
99<xsl:template name="dingbat.characters">
100  <!-- now that I'm using the real serializer, all that dingbat malarky -->
101  <!-- isn't necessary anymore... -->
102  <xsl:param name="dingbat">bullet</xsl:param>
103  <xsl:choose>
104    <xsl:when test="$dingbat='bullet'">&#x2022;</xsl:when>
105    <xsl:when test="$dingbat='copyright'">&#x00A9;</xsl:when>
106    <xsl:when test="$dingbat='trademark'">&#x2122;</xsl:when>
107    <xsl:when test="$dingbat='trade'">&#x2122;</xsl:when>
108    <xsl:when test="$dingbat='registered'">&#x00AE;</xsl:when>
109    <xsl:when test="$dingbat='service'">(SM)</xsl:when>
110    <xsl:when test="$dingbat='nbsp'">&#x00A0;</xsl:when>
111    <xsl:when test="$dingbat='ldquo'">&#x201C;</xsl:when>
112    <xsl:when test="$dingbat='rdquo'">&#x201D;</xsl:when>
113    <xsl:when test="$dingbat='lsquo'">&#x2018;</xsl:when>
114    <xsl:when test="$dingbat='rsquo'">&#x2019;</xsl:when>
115    <xsl:when test="$dingbat='em-dash'">&#x2014;</xsl:when>
116    <xsl:when test="$dingbat='mdash'">&#x2014;</xsl:when>
117    <xsl:when test="$dingbat='en-dash'">&#x2013;</xsl:when>
118    <xsl:when test="$dingbat='ndash'">&#x2013;</xsl:when>
119    <xsl:otherwise>
120      <xsl:text>&#x2022;</xsl:text>
121    </xsl:otherwise>
122  </xsl:choose>
123</xsl:template>
124
125<xsl:template name="id.warning">
126  <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
127    <xsl:variable name="title">
128      <xsl:choose>
129	<xsl:when test="title">
130	  <xsl:value-of select="title[1]"/>
131	</xsl:when>
132	<xsl:when test="substring(local-name(*[1]),
133			          string-length(local-name(*[1])-3) = 'info')
134			and *[1]/title">
135	  <xsl:value-of select="*[1]/title[1]"/>
136	</xsl:when>
137	<xsl:when test="refmeta/refentrytitle">
138	  <xsl:value-of select="refmeta/refentrytitle"/>
139	</xsl:when>
140	<xsl:when test="refnamediv/refname">
141	  <xsl:value-of select="refnamediv/refname[1]"/>
142	</xsl:when>
143      </xsl:choose>
144    </xsl:variable>
145
146    <xsl:message>
147      <xsl:text>ID recommended on </xsl:text>
148      <xsl:value-of select="local-name(.)"/>
149      <xsl:if test="$title != ''">
150	<xsl:text>: </xsl:text>
151	<xsl:choose>
152	  <xsl:when test="string-length($title) &gt; 40">
153	    <xsl:value-of select="substring($title,1,40)"/>
154	    <xsl:text>...</xsl:text>
155	  </xsl:when>
156	  <xsl:otherwise>
157	    <xsl:value-of select="$title"/>
158	  </xsl:otherwise>
159	</xsl:choose>
160      </xsl:if>
161    </xsl:message>
162  </xsl:if>
163</xsl:template>
164
165</xsl:stylesheet>
166
167