| 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 6910 2007-06-28 23:23:30Z xmldoc $ |
| 7 |
******************************************************************** |
| 8 |
|
| 9 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 10 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 11 |
copyright 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 |
<!-- 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"/> |
| 26 |
</xsl:template> |
| 27 |
|
| 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"/> |
| 36 |
</xsl:with-param> |
| 37 |
</xsl:call-template> |
| 38 |
</xsl:variable> |
| 39 |
|
| 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"/> |
| 46 |
</xsl:with-param> |
| 47 |
</xsl:call-template> |
| 48 |
</xsl:variable> |
| 49 |
|
| 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"/> |
| 56 |
</xsl:with-param> |
| 57 |
</xsl:call-template> |
| 58 |
</xsl:variable> |
| 59 |
|
| 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"/> |
| 66 |
</xsl:if> |
| 67 |
</xsl:variable> |
| 68 |
|
| 69 |
<xsl:choose> |
| 70 |
<xsl:when test="string-length($gentext.title) != 0"> |
| 71 |
<xsl:attribute name="title"> |
| 72 |
<xsl:value-of select="$gentext.title"/> |
| 73 |
</xsl:attribute> |
| 74 |
</xsl:when> |
| 75 |
<!-- Fall back to alt if available --> |
| 76 |
<xsl:when test="alt"> |
| 77 |
<xsl:attribute name="title"> |
| 78 |
<xsl:value-of select="normalize-space(alt)"/> |
| 79 |
</xsl:attribute> |
| 80 |
</xsl:when> |
| 81 |
</xsl:choose> |
| 82 |
|
| 83 |
</xsl:template> |
| 84 |
|
| 85 |
<xsl:template name="dir"> |
| 86 |
<xsl:param name="inherit" select="0"/> |
| 87 |
|
| 88 |
<xsl:variable name="dir"> |
| 89 |
<xsl:choose> |
| 90 |
<xsl:when test="@dir"> |
| 91 |
<xsl:value-of select="@dir"/> |
| 92 |
</xsl:when> |
| 93 |
<xsl:when test="$inherit != 0"> |
| 94 |
<xsl:value-of select="ancestor::*/@dir[1]"/> |
| 95 |
</xsl:when> |
| 96 |
</xsl:choose> |
| 97 |
</xsl:variable> |
| 98 |
|
| 99 |
<xsl:if test="$dir != ''"> |
| 100 |
<xsl:attribute name="dir"> |
| 101 |
<xsl:value-of select="$dir"/> |
| 102 |
</xsl:attribute> |
| 103 |
</xsl:if> |
| 104 |
</xsl:template> |
| 105 |
|
| 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"/> |
| 112 |
</xsl:call-template> |
| 113 |
</xsl:variable> |
| 114 |
<xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id"> |
| 115 |
<a name="{$id}"/> |
| 116 |
</xsl:if> |
| 117 |
</xsl:template> |
| 118 |
|
| 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"/> |
| 125 |
</xsl:call-template> |
| 126 |
</xsl:template> |
| 127 |
|
| 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"/> |
| 134 |
</xsl:call-template> |
| 135 |
</xsl:template> |
| 136 |
|
| 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"/> |
| 142 |
</xsl:if> |
| 143 |
<xsl:call-template name="href.target"> |
| 144 |
<xsl:with-param name="context" select="$context"/> |
| 145 |
<xsl:with-param name="object" select="$object"/> |
| 146 |
</xsl:call-template> |
| 147 |
</xsl:template> |
| 148 |
|
| 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"/> |
| 153 |
</xsl:call-template> |
| 154 |
</xsl:template> |
| 155 |
|
| 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> |
| 160 |
<xsl:choose> |
| 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> |
| 176 |
<xsl:otherwise> |
| 177 |
<xsl:text>•</xsl:text> |
| 178 |
</xsl:otherwise> |
| 179 |
</xsl:choose> |
| 180 |
</xsl:template> |
| 181 |
|
| 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"> |
| 185 |
<xsl:choose> |
| 186 |
<xsl:when test="title"> |
| 187 |
<xsl:value-of select="title[1]"/> |
| 188 |
</xsl:when> |
| 189 |
<xsl:when test="substring(local-name(*[1]), |
| 190 |
string-length(local-name(*[1])-3) = 'info') |
| 191 |
and *[1]/title"> |
| 192 |
<xsl:value-of select="*[1]/title[1]"/> |
| 193 |
</xsl:when> |
| 194 |
<xsl:when test="refmeta/refentrytitle"> |
| 195 |
<xsl:value-of select="refmeta/refentrytitle"/> |
| 196 |
</xsl:when> |
| 197 |
<xsl:when test="refnamediv/refname"> |
| 198 |
<xsl:value-of select="refnamediv/refname[1]"/> |
| 199 |
</xsl:when> |
| 200 |
</xsl:choose> |
| 201 |
</xsl:variable> |
| 202 |
|
| 203 |
<xsl:message> |
| 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> |
| 208 |
<xsl:choose> |
| 209 |
<xsl:when test="string-length($title) > 40"> |
| 210 |
<xsl:value-of select="substring($title,1,40)"/> |
| 211 |
<xsl:text>...</xsl:text> |
| 212 |
</xsl:when> |
| 213 |
<xsl:otherwise> |
| 214 |
<xsl:value-of select="$title"/> |
| 215 |
</xsl:otherwise> |
| 216 |
</xsl:choose> |
| 217 |
</xsl:if> |
| 218 |
</xsl:message> |
| 219 |
</xsl:if> |
| 220 |
</xsl:template> |
| 221 |
|
| 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> |
| 230 |
</xsl:attribute> |
| 231 |
</xsl:template> |
| 232 |
|
| 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"/> |
| 238 |
</xsl:template> |
| 239 |
|
| 240 |
</xsl:stylesheet> |
| 241 |
|