1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<!-- ********************************************************************
$Id$
********************************************************************
This file is part of the XSL DocBook Stylesheet distribution.
See ../README or http://nwalsh.com/docbook/xsl/ for copyright
and other information.
******************************************************************** -->
<!-- The generate.html.title template is currently used for generating HTML -->
<!-- "title" attributes for some inline elements only, but not for any -->
<!-- block elements. It is called in eleven places in the inline.xsl -->
<!-- file. But it's called by all the inline.* templates (e.g., -->
<!-- inline.boldseq), which in turn are called by other (element) -->
<!-- templates, so it results, currently, in supporting generation of the -->
<!-- HTML "title" attribute for a total of about 92 elements. -->
<!-- You can use mode="html.title.attribute" to get a title for -->
<!-- an element specified by a param, including targets of cross references. -->
<xsl:template name="generate.html.title">
<xsl:apply-templates select="." mode="html.title.attribute"/>
</xsl:template>
<!-- Generate a title attribute for the context node -->
<xsl:template match="*" mode="html.title.attribute">
<xsl:variable name="is.title">
<xsl:call-template name="gentext.template.exists">
<xsl:with-param name="context" select="'title'"/>
<xsl:with-param name="name" select="local-name(.)"/>
<xsl:with-param name="lang">
<xsl:call-template name="l10n.language"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="is.title-numbered">
<xsl:call-template name="gentext.template.exists">
<xsl:with-param name="context" select="'title-numbered'"/>
<xsl:with-param name="name" select="local-name(.)"/>
<xsl:with-param name="lang">
<xsl:call-template name="l10n.language"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="is.title-unnumbered">
<xsl:call-template name="gentext.template.exists">
<xsl:with-param name="context" select="'title-unnumbered'"/>
<xsl:with-param name="name" select="local-name(.)"/>
<xsl:with-param name="lang">
<xsl:call-template name="l10n.language"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="gentext.title">
<xsl:if test="$is.title != 0 or
$is.title-numbered != 0 or
$is.title-unnumbered != 0">
<xsl:apply-templates select="."
mode="object.title.markup.textonly"/>
</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($gentext.title) != 0">
<xsl:attribute name="title">
<xsl:value-of select="$gentext.title"/>
</xsl:attribute>
</xsl:when>
<!-- Fall back to alt if available -->
<xsl:when test="alt">
<xsl:attribute name="title">
<xsl:value-of select="normalize-space(alt)"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="dir">
<xsl:param name="inherit" select="0"/>
<xsl:variable name="dir">
<xsl:choose>
<xsl:when test="@dir">
<xsl:value-of select="@dir"/>
</xsl:when>
<xsl:when test="$inherit != 0">
<xsl:value-of select="ancestor::*/@dir[1]"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$dir != ''">
<xsl:attribute name="dir">
<xsl:value-of select="$dir"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
<xsl:template name="anchor">
<xsl:param name="node" select="."/>
<xsl:param name="conditional" select="1"/>
<xsl:variable name="id">
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="$node"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id">
<a name="{$id}"/>
</xsl:if>
</xsl:template>
<xsl:template name="href.target.uri">
<xsl:param name="context" select="."/>
<xsl:param name="object" select="."/>
<xsl:text>#</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="$object"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="href.target">
<xsl:param name="context" select="."/>
<xsl:param name="object" select="."/>
<xsl:text>#</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="$object"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="href.target.with.base.dir">
<xsl:param name="context" select="."/>
<xsl:param name="object" select="."/>
<xsl:if test="$manifest.in.base.dir = 0">
<xsl:value-of select="$base.dir"/>
</xsl:if>
<xsl:call-template name="href.target">
<xsl:with-param name="context" select="$context"/>
<xsl:with-param name="object" select="$object"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="dingbat">
<xsl:param name="dingbat">bullet</xsl:param>
<xsl:call-template name="dingbat.characters">
<xsl:with-param name="dingbat" select="$dingbat"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="dingbat.characters">
<!-- now that I'm using the real serializer, all that dingbat malarky -->
<!-- isn't necessary anymore... -->
<xsl:param name="dingbat">bullet</xsl:param>
<xsl:choose>
<xsl:when test="$dingbat='bullet'">•</xsl:when>
<xsl:when test="$dingbat='copyright'">©</xsl:when>
<xsl:when test="$dingbat='trademark'">™</xsl:when>
<xsl:when test="$dingbat='trade'">™</xsl:when>
<xsl:when test="$dingbat='registered'">®</xsl:when>
<xsl:when test="$dingbat='service'">(SM)</xsl:when>
<xsl:when test="$dingbat='nbsp'"> </xsl:when>
<xsl:when test="$dingbat='ldquo'">“</xsl:when>
<xsl:when test="$dingbat='rdquo'">”</xsl:when>
<xsl:when test="$dingbat='lsquo'">‘</xsl:when>
<xsl:when test="$dingbat='rsquo'">’</xsl:when>
<xsl:when test="$dingbat='em-dash'">—</xsl:when>
<xsl:when test="$dingbat='mdash'">—</xsl:when>
<xsl:when test="$dingbat='en-dash'">–</xsl:when>
<xsl:when test="$dingbat='ndash'">–</xsl:when>
<xsl:otherwise>
<xsl:text>•</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="id.warning">
<xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="title">
<xsl:value-of select="title[1]"/>
</xsl:when>
<xsl:when test="substring(local-name(*[1]),
string-length(local-name(*[1])-3) = 'info')
and *[1]/title">
<xsl:value-of select="*[1]/title[1]"/>
</xsl:when>
<xsl:when test="refmeta/refentrytitle">
<xsl:value-of select="refmeta/refentrytitle"/>
</xsl:when>
<xsl:when test="refnamediv/refname">
<xsl:value-of select="refnamediv/refname[1]"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:message>
<xsl:text>ID recommended on </xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:if test="$title != ''">
<xsl:text>: </xsl:text>
<xsl:choose>
<xsl:when test="string-length($title) > 40">
<xsl:value-of select="substring($title,1,40)"/>
<xsl:text>...</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:message>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="class.attribute">
<xsl:param name="class" select="local-name(.)"/>
<!-- permit customization of class attributes -->
<!-- Use element name by default -->
<xsl:attribute name="class">
<xsl:apply-templates select="." mode="class.value">
<xsl:with-param name="class" select="$class"/>
</xsl:apply-templates>
</xsl:attribute>
</xsl:template>
<xsl:template match="*" mode="class.value">
<xsl:param name="class" select="local-name(.)"/>
<!-- permit customization of class value only -->
<!-- Use element name by default -->
<xsl:value-of select="$class"/>
</xsl:template>
</xsl:stylesheet>
|