[15c7d39] | 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 9306 2012-04-28 03:49:00Z bobstayton $
|
---|
| 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 | <!-- These variables set the align attribute value for HTML output based on
|
---|
| 16 | the writing-mode specified in the gentext file for the document's lang. -->
|
---|
| 17 |
|
---|
| 18 | <xsl:variable name="direction.align.start">
|
---|
| 19 | <xsl:choose>
|
---|
| 20 | <xsl:when test="starts-with($writing.mode, 'lr')">left</xsl:when>
|
---|
| 21 | <xsl:when test="starts-with($writing.mode, 'rl')">right</xsl:when>
|
---|
| 22 | <xsl:otherwise>left</xsl:otherwise>
|
---|
| 23 | </xsl:choose>
|
---|
| 24 | </xsl:variable>
|
---|
| 25 |
|
---|
| 26 | <xsl:variable name="direction.align.end">
|
---|
| 27 | <xsl:choose>
|
---|
| 28 | <xsl:when test="starts-with($writing.mode, 'lr')">right</xsl:when>
|
---|
| 29 | <xsl:when test="starts-with($writing.mode, 'rl')">left</xsl:when>
|
---|
| 30 | <xsl:otherwise>right</xsl:otherwise>
|
---|
| 31 | </xsl:choose>
|
---|
| 32 | </xsl:variable>
|
---|
| 33 |
|
---|
| 34 | <xsl:variable name="direction.mode">
|
---|
| 35 | <xsl:choose>
|
---|
| 36 | <xsl:when test="starts-with($writing.mode, 'lr')">ltr</xsl:when>
|
---|
| 37 | <xsl:when test="starts-with($writing.mode, 'rl')">rtl</xsl:when>
|
---|
| 38 | <xsl:otherwise>ltr</xsl:otherwise>
|
---|
| 39 | </xsl:choose>
|
---|
| 40 | </xsl:variable>
|
---|
| 41 |
|
---|
| 42 | <!-- Support switching to <section> for HTML5 stylesheet -->
|
---|
| 43 | <!-- This is an internal variable that does not need to be set by a user -->
|
---|
| 44 | <xsl:variable name="div.element">div</xsl:variable>
|
---|
| 45 | <!-- Support turning off table border with border="" for HTML5 -->
|
---|
| 46 | <xsl:variable name="table.border.off">0</xsl:variable>
|
---|
| 47 |
|
---|
| 48 | <!-- The generate.html.title template is currently used for generating HTML -->
|
---|
| 49 | <!-- "title" attributes for some inline elements only, but not for any -->
|
---|
| 50 | <!-- block elements. It is called in eleven places in the inline.xsl -->
|
---|
| 51 | <!-- file. But it's called by all the inline.* templates (e.g., -->
|
---|
| 52 | <!-- inline.boldseq), which in turn are called by other (element) -->
|
---|
| 53 | <!-- templates, so it results, currently, in supporting generation of the -->
|
---|
| 54 | <!-- HTML "title" attribute for a total of about 92 elements. -->
|
---|
| 55 | <!-- You can use mode="html.title.attribute" to get a title for -->
|
---|
| 56 | <!-- an element specified by a param, including targets of cross references. -->
|
---|
| 57 | <xsl:template name="generate.html.title">
|
---|
| 58 | <xsl:apply-templates select="." mode="html.title.attribute"/>
|
---|
| 59 | </xsl:template>
|
---|
| 60 |
|
---|
| 61 | <xsl:template match="acronym|abbrev" mode="html.title.attribute">
|
---|
| 62 | <xsl:if test="alt">
|
---|
| 63 | <xsl:attribute name="title">
|
---|
| 64 | <xsl:value-of select="normalize-space(alt)"/>
|
---|
| 65 | </xsl:attribute>
|
---|
| 66 | </xsl:if>
|
---|
| 67 | </xsl:template>
|
---|
| 68 |
|
---|
| 69 | <!-- Generate a title attribute for the context node -->
|
---|
| 70 | <!-- This may be the target of an xref -->
|
---|
| 71 | <xsl:template match="*" mode="html.title.attribute">
|
---|
| 72 | <xsl:variable name="is.title">
|
---|
| 73 | <xsl:call-template name="gentext.template.exists">
|
---|
| 74 | <xsl:with-param name="context" select="'title'"/>
|
---|
| 75 | <xsl:with-param name="name" select="local-name(.)"/>
|
---|
| 76 | <xsl:with-param name="lang">
|
---|
| 77 | <xsl:call-template name="l10n.language"/>
|
---|
| 78 | </xsl:with-param>
|
---|
| 79 | </xsl:call-template>
|
---|
| 80 | </xsl:variable>
|
---|
| 81 |
|
---|
| 82 | <xsl:variable name="is.title-numbered">
|
---|
| 83 | <xsl:call-template name="gentext.template.exists">
|
---|
| 84 | <xsl:with-param name="context" select="'title-numbered'"/>
|
---|
| 85 | <xsl:with-param name="name" select="local-name(.)"/>
|
---|
| 86 | <xsl:with-param name="lang">
|
---|
| 87 | <xsl:call-template name="l10n.language"/>
|
---|
| 88 | </xsl:with-param>
|
---|
| 89 | </xsl:call-template>
|
---|
| 90 | </xsl:variable>
|
---|
| 91 |
|
---|
| 92 | <xsl:variable name="is.title-unnumbered">
|
---|
| 93 | <xsl:call-template name="gentext.template.exists">
|
---|
| 94 | <xsl:with-param name="context" select="'title-unnumbered'"/>
|
---|
| 95 | <xsl:with-param name="name" select="local-name(.)"/>
|
---|
| 96 | <xsl:with-param name="lang">
|
---|
| 97 | <xsl:call-template name="l10n.language"/>
|
---|
| 98 | </xsl:with-param>
|
---|
| 99 | </xsl:call-template>
|
---|
| 100 | </xsl:variable>
|
---|
| 101 |
|
---|
| 102 | <xsl:variable name="has.title.markup">
|
---|
| 103 | <xsl:apply-templates select="." mode="title.markup">
|
---|
| 104 | <xsl:with-param name="verbose" select="0"/>
|
---|
| 105 | </xsl:apply-templates>
|
---|
| 106 | </xsl:variable>
|
---|
| 107 |
|
---|
| 108 | <xsl:variable name="gentext.title">
|
---|
| 109 | <xsl:if test="$has.title.markup != '???TITLE???' and
|
---|
| 110 | ($is.title != 0 or
|
---|
| 111 | $is.title-numbered != 0 or
|
---|
| 112 | $is.title-unnumbered != 0)">
|
---|
| 113 | <xsl:apply-templates select="."
|
---|
| 114 | mode="object.title.markup.textonly"/>
|
---|
| 115 | </xsl:if>
|
---|
| 116 | </xsl:variable>
|
---|
| 117 |
|
---|
| 118 | <xsl:choose>
|
---|
| 119 | <xsl:when test="string-length($gentext.title) != 0">
|
---|
| 120 | <xsl:attribute name="title">
|
---|
| 121 | <xsl:value-of select="$gentext.title"/>
|
---|
| 122 | </xsl:attribute>
|
---|
| 123 | </xsl:when>
|
---|
| 124 | <!-- Fall back to alt if available -->
|
---|
| 125 | <xsl:when test="alt">
|
---|
| 126 | <xsl:attribute name="title">
|
---|
| 127 | <xsl:value-of select="normalize-space(alt)"/>
|
---|
| 128 | </xsl:attribute>
|
---|
| 129 | </xsl:when>
|
---|
| 130 | </xsl:choose>
|
---|
| 131 | </xsl:template>
|
---|
| 132 |
|
---|
| 133 | <xsl:template match="qandaentry" mode="html.title.attribute">
|
---|
| 134 | <xsl:apply-templates select="question" mode="html.title.attribute"/>
|
---|
| 135 | </xsl:template>
|
---|
| 136 |
|
---|
| 137 | <xsl:template match="question" mode="html.title.attribute">
|
---|
| 138 | <xsl:variable name="label.text">
|
---|
| 139 | <xsl:apply-templates select="." mode="qanda.label"/>
|
---|
| 140 | </xsl:variable>
|
---|
| 141 |
|
---|
| 142 | <xsl:choose>
|
---|
| 143 | <xsl:when test="string-length($label.text) != 0">
|
---|
| 144 | <xsl:attribute name="title">
|
---|
| 145 | <xsl:value-of select="$label.text"/>
|
---|
| 146 | </xsl:attribute>
|
---|
| 147 | </xsl:when>
|
---|
| 148 | <!-- Fall back to alt if available -->
|
---|
| 149 | <xsl:when test="alt">
|
---|
| 150 | <xsl:attribute name="title">
|
---|
| 151 | <xsl:value-of select="normalize-space(alt)"/>
|
---|
| 152 | </xsl:attribute>
|
---|
| 153 | </xsl:when>
|
---|
| 154 | </xsl:choose>
|
---|
| 155 | </xsl:template>
|
---|
| 156 |
|
---|
| 157 | <xsl:template name="dir">
|
---|
| 158 | <xsl:param name="inherit" select="0"/>
|
---|
| 159 |
|
---|
| 160 | <xsl:variable name="dir">
|
---|
| 161 | <xsl:choose>
|
---|
| 162 | <xsl:when test="@dir">
|
---|
| 163 | <xsl:value-of select="@dir"/>
|
---|
| 164 | </xsl:when>
|
---|
| 165 | <xsl:when test="$inherit != 0">
|
---|
| 166 | <xsl:value-of select="ancestor::*/@dir[1]"/>
|
---|
| 167 | </xsl:when>
|
---|
| 168 | </xsl:choose>
|
---|
| 169 | </xsl:variable>
|
---|
| 170 |
|
---|
| 171 | <xsl:if test="$dir != ''">
|
---|
| 172 | <xsl:attribute name="dir">
|
---|
| 173 | <xsl:value-of select="$dir"/>
|
---|
| 174 | </xsl:attribute>
|
---|
| 175 | </xsl:if>
|
---|
| 176 | </xsl:template>
|
---|
| 177 |
|
---|
| 178 | <xsl:template name="anchor">
|
---|
| 179 | <xsl:param name="node" select="."/>
|
---|
| 180 | <xsl:param name="conditional" select="1"/>
|
---|
| 181 |
|
---|
| 182 | <xsl:choose>
|
---|
| 183 | <xsl:when test="$generate.id.attributes != 0">
|
---|
| 184 | <!-- No named anchors output when this param is set -->
|
---|
| 185 | </xsl:when>
|
---|
| 186 | <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
|
---|
| 187 | <a>
|
---|
| 188 | <xsl:attribute name="name">
|
---|
| 189 | <xsl:call-template name="object.id">
|
---|
| 190 | <xsl:with-param name="object" select="$node"/>
|
---|
| 191 | </xsl:call-template>
|
---|
| 192 | </xsl:attribute>
|
---|
| 193 | </a>
|
---|
| 194 | </xsl:when>
|
---|
| 195 | </xsl:choose>
|
---|
| 196 | </xsl:template>
|
---|
| 197 |
|
---|
| 198 | <xsl:template name="id.attribute">
|
---|
| 199 | <xsl:param name="node" select="."/>
|
---|
| 200 | <xsl:param name="conditional" select="1"/>
|
---|
| 201 | <xsl:choose>
|
---|
| 202 | <xsl:when test="$generate.id.attributes = 0">
|
---|
| 203 | <!-- No id attributes when this param is zero -->
|
---|
| 204 | </xsl:when>
|
---|
| 205 | <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
|
---|
| 206 | <xsl:attribute name="id">
|
---|
| 207 | <xsl:call-template name="object.id">
|
---|
| 208 | <xsl:with-param name="object" select="$node"/>
|
---|
| 209 | </xsl:call-template>
|
---|
| 210 | </xsl:attribute>
|
---|
| 211 | </xsl:when>
|
---|
| 212 | </xsl:choose>
|
---|
| 213 | </xsl:template>
|
---|
| 214 |
|
---|
| 215 | <xsl:template name="href.target.uri">
|
---|
| 216 | <xsl:param name="context" select="."/>
|
---|
| 217 | <xsl:param name="object" select="."/>
|
---|
| 218 | <xsl:text>#</xsl:text>
|
---|
| 219 | <xsl:call-template name="object.id">
|
---|
| 220 | <xsl:with-param name="object" select="$object"/>
|
---|
| 221 | </xsl:call-template>
|
---|
| 222 | </xsl:template>
|
---|
| 223 |
|
---|
| 224 | <xsl:template name="href.target">
|
---|
| 225 | <xsl:param name="context" select="."/>
|
---|
| 226 | <xsl:param name="object" select="."/>
|
---|
| 227 | <xsl:text>#</xsl:text>
|
---|
| 228 | <xsl:call-template name="object.id">
|
---|
| 229 | <xsl:with-param name="object" select="$object"/>
|
---|
| 230 | </xsl:call-template>
|
---|
| 231 | </xsl:template>
|
---|
| 232 |
|
---|
| 233 | <xsl:template name="href.target.with.base.dir">
|
---|
| 234 | <xsl:param name="context" select="."/>
|
---|
| 235 | <xsl:param name="object" select="."/>
|
---|
| 236 | <xsl:if test="$manifest.in.base.dir = 0">
|
---|
| 237 | <xsl:value-of select="$chunk.base.dir"/>
|
---|
| 238 | </xsl:if>
|
---|
| 239 | <xsl:call-template name="href.target">
|
---|
| 240 | <xsl:with-param name="context" select="$context"/>
|
---|
| 241 | <xsl:with-param name="object" select="$object"/>
|
---|
| 242 | </xsl:call-template>
|
---|
| 243 | </xsl:template>
|
---|
| 244 |
|
---|
| 245 | <xsl:template name="dingbat">
|
---|
| 246 | <xsl:param name="dingbat">bullet</xsl:param>
|
---|
| 247 | <xsl:call-template name="dingbat.characters">
|
---|
| 248 | <xsl:with-param name="dingbat" select="$dingbat"/>
|
---|
| 249 | </xsl:call-template>
|
---|
| 250 | </xsl:template>
|
---|
| 251 |
|
---|
| 252 | <xsl:template name="dingbat.characters">
|
---|
| 253 | <!-- now that I'm using the real serializer, all that dingbat malarky -->
|
---|
| 254 | <!-- isn't necessary anymore... -->
|
---|
| 255 | <xsl:param name="dingbat">bullet</xsl:param>
|
---|
| 256 | <xsl:choose>
|
---|
| 257 | <xsl:when test="$dingbat='bullet'">•</xsl:when>
|
---|
| 258 | <xsl:when test="$dingbat='copyright'">©</xsl:when>
|
---|
| 259 | <xsl:when test="$dingbat='trademark'">™</xsl:when>
|
---|
| 260 | <xsl:when test="$dingbat='trade'">™</xsl:when>
|
---|
| 261 | <xsl:when test="$dingbat='registered'">®</xsl:when>
|
---|
| 262 | <xsl:when test="$dingbat='service'">(SM)</xsl:when>
|
---|
| 263 | <xsl:when test="$dingbat='nbsp'"> </xsl:when>
|
---|
| 264 | <xsl:when test="$dingbat='ldquo'">“</xsl:when>
|
---|
| 265 | <xsl:when test="$dingbat='rdquo'">”</xsl:when>
|
---|
| 266 | <xsl:when test="$dingbat='lsquo'">‘</xsl:when>
|
---|
| 267 | <xsl:when test="$dingbat='rsquo'">’</xsl:when>
|
---|
| 268 | <xsl:when test="$dingbat='em-dash'">—</xsl:when>
|
---|
| 269 | <xsl:when test="$dingbat='mdash'">—</xsl:when>
|
---|
| 270 | <xsl:when test="$dingbat='en-dash'">–</xsl:when>
|
---|
| 271 | <xsl:when test="$dingbat='ndash'">–</xsl:when>
|
---|
| 272 | <xsl:otherwise>
|
---|
| 273 | <xsl:text>•</xsl:text>
|
---|
| 274 | </xsl:otherwise>
|
---|
| 275 | </xsl:choose>
|
---|
| 276 | </xsl:template>
|
---|
| 277 |
|
---|
| 278 | <xsl:template name="id.warning">
|
---|
| 279 | <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
|
---|
| 280 | <xsl:variable name="title">
|
---|
| 281 | <xsl:choose>
|
---|
| 282 | <xsl:when test="title">
|
---|
| 283 | <xsl:value-of select="title[1]"/>
|
---|
| 284 | </xsl:when>
|
---|
| 285 | <xsl:when test="substring(local-name(*[1]),
|
---|
| 286 | string-length(local-name(*[1])-3) = 'info')
|
---|
| 287 | and *[1]/title">
|
---|
| 288 | <xsl:value-of select="*[1]/title[1]"/>
|
---|
| 289 | </xsl:when>
|
---|
| 290 | <xsl:when test="refmeta/refentrytitle">
|
---|
| 291 | <xsl:value-of select="refmeta/refentrytitle"/>
|
---|
| 292 | </xsl:when>
|
---|
| 293 | <xsl:when test="refnamediv/refname">
|
---|
| 294 | <xsl:value-of select="refnamediv/refname[1]"/>
|
---|
| 295 | </xsl:when>
|
---|
| 296 | </xsl:choose>
|
---|
| 297 | </xsl:variable>
|
---|
| 298 |
|
---|
| 299 | <xsl:message>
|
---|
| 300 | <xsl:text>ID recommended on </xsl:text>
|
---|
| 301 | <xsl:value-of select="local-name(.)"/>
|
---|
| 302 | <xsl:if test="$title != ''">
|
---|
| 303 | <xsl:text>: </xsl:text>
|
---|
| 304 | <xsl:choose>
|
---|
| 305 | <xsl:when test="string-length($title) > 40">
|
---|
| 306 | <xsl:value-of select="substring($title,1,40)"/>
|
---|
| 307 | <xsl:text>...</xsl:text>
|
---|
| 308 | </xsl:when>
|
---|
| 309 | <xsl:otherwise>
|
---|
| 310 | <xsl:value-of select="$title"/>
|
---|
| 311 | </xsl:otherwise>
|
---|
| 312 | </xsl:choose>
|
---|
| 313 | </xsl:if>
|
---|
| 314 | </xsl:message>
|
---|
| 315 | </xsl:if>
|
---|
| 316 | </xsl:template>
|
---|
| 317 |
|
---|
| 318 | <xsl:template name="generate.class.attribute">
|
---|
| 319 | <xsl:param name="class" select="local-name(.)"/>
|
---|
| 320 | <xsl:apply-templates select="." mode="class.attribute">
|
---|
| 321 | <xsl:with-param name="class" select="$class"/>
|
---|
| 322 | </xsl:apply-templates>
|
---|
| 323 | </xsl:template>
|
---|
| 324 |
|
---|
| 325 | <xsl:template match="*" mode="class.attribute">
|
---|
| 326 | <xsl:param name="class" select="local-name(.)"/>
|
---|
| 327 | <!-- permit customization of class attributes -->
|
---|
| 328 | <!-- Use element name by default -->
|
---|
| 329 | <xsl:variable name="class.value">
|
---|
| 330 | <xsl:apply-templates select="." mode="class.value">
|
---|
| 331 | <xsl:with-param name="class" select="$class"/>
|
---|
| 332 | </xsl:apply-templates>
|
---|
| 333 | </xsl:variable>
|
---|
| 334 |
|
---|
| 335 | <xsl:if test="string-length(normalize-space($class.value)) != 0">
|
---|
| 336 | <xsl:attribute name="class">
|
---|
| 337 | <xsl:value-of select="$class.value"/>
|
---|
| 338 | </xsl:attribute>
|
---|
| 339 | </xsl:if>
|
---|
| 340 | </xsl:template>
|
---|
| 341 |
|
---|
| 342 | <xsl:template match="*" mode="class.value">
|
---|
| 343 | <xsl:param name="class" select="local-name(.)"/>
|
---|
| 344 | <!-- permit customization of class value only -->
|
---|
| 345 | <!-- Use element name by default -->
|
---|
| 346 | <xsl:value-of select="$class"/>
|
---|
| 347 | </xsl:template>
|
---|
| 348 |
|
---|
| 349 | <!-- Apply common attributes such as class, lang, dir -->
|
---|
| 350 | <xsl:template name="common.html.attributes">
|
---|
| 351 | <xsl:param name="inherit" select="0"/>
|
---|
| 352 | <xsl:param name="class" select="local-name(.)"/>
|
---|
| 353 | <xsl:apply-templates select="." mode="common.html.attributes">
|
---|
| 354 | <xsl:with-param name="class" select="$class"/>
|
---|
| 355 | <xsl:with-param name="inherit" select="$inherit"/>
|
---|
| 356 | </xsl:apply-templates>
|
---|
| 357 | </xsl:template>
|
---|
| 358 |
|
---|
| 359 | <xsl:template match="*" mode="common.html.attributes">
|
---|
| 360 | <xsl:param name="class" select="local-name(.)"/>
|
---|
| 361 | <xsl:param name="inherit" select="0"/>
|
---|
| 362 | <xsl:call-template name="generate.html.lang"/>
|
---|
| 363 | <xsl:call-template name="dir">
|
---|
| 364 | <xsl:with-param name="inherit" select="$inherit"/>
|
---|
| 365 | </xsl:call-template>
|
---|
| 366 | <xsl:apply-templates select="." mode="class.attribute">
|
---|
| 367 | <xsl:with-param name="class" select="$class"/>
|
---|
| 368 | </xsl:apply-templates>
|
---|
| 369 | </xsl:template>
|
---|
| 370 |
|
---|
| 371 | <!-- Apply common attributes not including class -->
|
---|
| 372 | <xsl:template name="locale.html.attributes">
|
---|
| 373 | <xsl:apply-templates select="." mode="locale.html.attributes"/>
|
---|
| 374 | </xsl:template>
|
---|
| 375 |
|
---|
| 376 | <xsl:template match="*" mode="locale.html.attributes">
|
---|
| 377 | <xsl:call-template name="generate.html.lang"/>
|
---|
| 378 | <xsl:call-template name="dir"/>
|
---|
| 379 | </xsl:template>
|
---|
| 380 |
|
---|
| 381 | <!-- Pass through any lang attributes -->
|
---|
| 382 | <xsl:template name="generate.html.lang">
|
---|
| 383 | <xsl:apply-templates select="." mode="html.lang.attribute"/>
|
---|
| 384 | </xsl:template>
|
---|
| 385 |
|
---|
| 386 | <xsl:template match="*" mode="html.lang.attribute">
|
---|
| 387 | <!-- match the attribute name to the output type -->
|
---|
| 388 | <xsl:choose>
|
---|
| 389 | <xsl:when test="@lang and $stylesheet.result.type = 'html'">
|
---|
| 390 | <xsl:attribute name="lang">
|
---|
| 391 | <xsl:value-of select="@lang"/>
|
---|
| 392 | </xsl:attribute>
|
---|
| 393 | </xsl:when>
|
---|
| 394 | <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
|
---|
| 395 | <xsl:attribute name="xml:lang">
|
---|
| 396 | <xsl:value-of select="@lang"/>
|
---|
| 397 | </xsl:attribute>
|
---|
| 398 | </xsl:when>
|
---|
| 399 | <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
|
---|
| 400 | <xsl:attribute name="lang">
|
---|
| 401 | <xsl:value-of select="@xml:lang"/>
|
---|
| 402 | </xsl:attribute>
|
---|
| 403 | </xsl:when>
|
---|
| 404 | <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
|
---|
| 405 | <xsl:attribute name="xml:lang">
|
---|
| 406 | <xsl:value-of select="@xml:lang"/>
|
---|
| 407 | </xsl:attribute>
|
---|
| 408 | </xsl:when>
|
---|
| 409 | </xsl:choose>
|
---|
| 410 | </xsl:template>
|
---|
| 411 |
|
---|
| 412 | <!-- ==================================================================== -->
|
---|
| 413 | <!-- Insert link to css or insert literal CSS in head element -->
|
---|
| 414 | <xsl:template name="generate.css">
|
---|
| 415 | <xsl:choose>
|
---|
| 416 | <xsl:when test="$generate.css.header = 0">
|
---|
| 417 | <xsl:call-template name="generate.css.links"/>
|
---|
| 418 | </xsl:when>
|
---|
| 419 | <xsl:otherwise>
|
---|
| 420 | <xsl:call-template name="generate.css.headers"/>
|
---|
| 421 | </xsl:otherwise>
|
---|
| 422 | </xsl:choose>
|
---|
| 423 | </xsl:template>
|
---|
| 424 |
|
---|
| 425 | <xsl:template name="generate.css.headers">
|
---|
| 426 | <xsl:call-template name="generate.default.css.header"/>
|
---|
| 427 | <xsl:call-template name="generate.custom.css.header"/>
|
---|
| 428 | </xsl:template>
|
---|
| 429 |
|
---|
| 430 | <xsl:template name="generate.default.css.header">
|
---|
| 431 | <xsl:if test="$make.clean.html != 0 and
|
---|
| 432 | $docbook.css.source != ''">
|
---|
| 433 | <!-- Select default file relative to stylesheet -->
|
---|
| 434 | <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
|
---|
| 435 |
|
---|
| 436 | <xsl:call-template name="output.css.header">
|
---|
| 437 | <xsl:with-param name="css.node" select="$css.node"/>
|
---|
| 438 | </xsl:call-template>
|
---|
| 439 | </xsl:if>
|
---|
| 440 | </xsl:template>
|
---|
| 441 |
|
---|
| 442 | <xsl:template name="generate.custom.css.header">
|
---|
| 443 | <xsl:if test="$custom.css.source != ''">
|
---|
| 444 | <!-- Select custom file relative to document -->
|
---|
| 445 | <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
|
---|
| 446 |
|
---|
| 447 | <xsl:call-template name="output.css.header">
|
---|
| 448 | <xsl:with-param name="css.node" select="$css.node"/>
|
---|
| 449 | </xsl:call-template>
|
---|
| 450 | </xsl:if>
|
---|
| 451 | </xsl:template>
|
---|
| 452 |
|
---|
| 453 | <xsl:template name="output.css.header">
|
---|
| 454 | <xsl:param name="css.node"/>
|
---|
| 455 |
|
---|
| 456 | <xsl:choose>
|
---|
| 457 | <xsl:when test="count($css.node) = 0">
|
---|
| 458 | </xsl:when>
|
---|
| 459 | <xsl:otherwise>
|
---|
| 460 | <style type="text/css">
|
---|
| 461 | <xsl:copy-of select="$css.node/text()"/>
|
---|
| 462 | </style>
|
---|
| 463 | </xsl:otherwise>
|
---|
| 464 | </xsl:choose>
|
---|
| 465 | </xsl:template>
|
---|
| 466 |
|
---|
| 467 | <!-- ==================================================================== -->
|
---|
| 468 | <xsl:template name="generate.css.links">
|
---|
| 469 | <xsl:call-template name="generate.default.css.link"/>
|
---|
| 470 | <xsl:call-template name="generate.custom.css.link"/>
|
---|
| 471 | </xsl:template>
|
---|
| 472 |
|
---|
| 473 | <xsl:template name="generate.default.css.link">
|
---|
| 474 | <xsl:if test="$make.clean.html != 0 and
|
---|
| 475 | $docbook.css.link != 0 and
|
---|
| 476 | $docbook.css.source != ''">
|
---|
| 477 | <xsl:variable name="filename">
|
---|
| 478 | <xsl:call-template name="css.output.filename">
|
---|
| 479 | <xsl:with-param name="src" select="$docbook.css.source"/>
|
---|
| 480 | </xsl:call-template>
|
---|
| 481 | </xsl:variable>
|
---|
| 482 |
|
---|
| 483 | <xsl:call-template name="make.css.link">
|
---|
| 484 | <xsl:with-param name="css.filename" select="$filename"/>
|
---|
| 485 | </xsl:call-template>
|
---|
| 486 | </xsl:if>
|
---|
| 487 | </xsl:template>
|
---|
| 488 |
|
---|
| 489 | <xsl:template name="generate.custom.css.link">
|
---|
| 490 | <xsl:if test="$custom.css.source != ''">
|
---|
| 491 | <xsl:variable name="filename">
|
---|
| 492 | <xsl:call-template name="css.output.filename">
|
---|
| 493 | <xsl:with-param name="src" select="$custom.css.source"/>
|
---|
| 494 | </xsl:call-template>
|
---|
| 495 | </xsl:variable>
|
---|
| 496 |
|
---|
| 497 | <xsl:call-template name="make.css.link">
|
---|
| 498 | <xsl:with-param name="css.filename" select="$filename"/>
|
---|
| 499 | </xsl:call-template>
|
---|
| 500 | </xsl:if>
|
---|
| 501 | </xsl:template>
|
---|
| 502 |
|
---|
| 503 | <!-- a CSS link reference must take into account the relative
|
---|
| 504 | path to a CSS file when chunked HTML is output to more than one directory -->
|
---|
| 505 | <xsl:template name="make.css.link">
|
---|
| 506 | <xsl:param name="css.filename" select="''"/>
|
---|
| 507 |
|
---|
| 508 | <xsl:variable name="href">
|
---|
| 509 | <xsl:call-template name="relative.path.link">
|
---|
| 510 | <xsl:with-param name="target.pathname" select="$css.filename"/>
|
---|
| 511 | </xsl:call-template>
|
---|
| 512 | </xsl:variable>
|
---|
| 513 |
|
---|
| 514 | <xsl:if test="string-length($css.filename) != 0">
|
---|
| 515 | <link rel="stylesheet"
|
---|
| 516 | type="text/css"
|
---|
| 517 | href="{$href}"/>
|
---|
| 518 | </xsl:if>
|
---|
| 519 | </xsl:template>
|
---|
| 520 |
|
---|
| 521 | <!-- And the same applies to script links -->
|
---|
| 522 | <xsl:template name="make.script.link">
|
---|
| 523 | <xsl:param name="script.filename" select="''"/>
|
---|
| 524 |
|
---|
| 525 | <xsl:variable name="src">
|
---|
| 526 | <xsl:call-template name="relative.path.link">
|
---|
| 527 | <xsl:with-param name="target.pathname" select="$script.filename"/>
|
---|
| 528 | </xsl:call-template>
|
---|
| 529 | </xsl:variable>
|
---|
| 530 |
|
---|
| 531 | <xsl:if test="string-length($script.filename) != 0">
|
---|
| 532 | <script>
|
---|
| 533 | <xsl:attribute name="src">
|
---|
| 534 | <xsl:value-of select="$src"/>
|
---|
| 535 | </xsl:attribute>
|
---|
| 536 | <xsl:attribute name="type">
|
---|
| 537 | <xsl:value-of select="$html.script.type"/>
|
---|
| 538 | </xsl:attribute>
|
---|
| 539 | <xsl:call-template name="other.script.attributes">
|
---|
| 540 | <xsl:with-param name="script.filename" select="$script.filename"/>
|
---|
| 541 | </xsl:call-template>
|
---|
| 542 | </script>
|
---|
| 543 | </xsl:if>
|
---|
| 544 | </xsl:template>
|
---|
| 545 |
|
---|
| 546 | <xsl:template name="other.script.attributes">
|
---|
| 547 | <xsl:param name="script.filename"/>
|
---|
| 548 | <!-- Placeholder template to allow customization to
|
---|
| 549 | insert additional script element attributes if needed -->
|
---|
| 550 | </xsl:template>
|
---|
| 551 |
|
---|
| 552 | <xsl:template name="relative.path.link">
|
---|
| 553 | <xsl:param name="target.pathname"/>
|
---|
| 554 |
|
---|
| 555 | <xsl:variable name="href.to.uri" select="$target.pathname"/>
|
---|
| 556 |
|
---|
| 557 | <xsl:variable name="href.from.uri">
|
---|
| 558 | <xsl:call-template name="href.target.uri">
|
---|
| 559 | <xsl:with-param name="object" select="."/>
|
---|
| 560 | </xsl:call-template>
|
---|
| 561 | </xsl:variable>
|
---|
| 562 |
|
---|
| 563 | <xsl:variable name="href.to">
|
---|
| 564 | <xsl:call-template name="trim.common.uri.paths">
|
---|
| 565 | <xsl:with-param name="uriA" select="$href.to.uri"/>
|
---|
| 566 | <xsl:with-param name="uriB" select="$href.from.uri"/>
|
---|
| 567 | <xsl:with-param name="return" select="'A'"/>
|
---|
| 568 | </xsl:call-template>
|
---|
| 569 | </xsl:variable>
|
---|
| 570 |
|
---|
| 571 | <xsl:variable name="href.from">
|
---|
| 572 | <xsl:call-template name="trim.common.uri.paths">
|
---|
| 573 | <xsl:with-param name="uriA" select="$href.to.uri"/>
|
---|
| 574 | <xsl:with-param name="uriB" select="$href.from.uri"/>
|
---|
| 575 | <xsl:with-param name="return" select="'B'"/>
|
---|
| 576 | </xsl:call-template>
|
---|
| 577 | </xsl:variable>
|
---|
| 578 | <xsl:variable name="depth">
|
---|
| 579 | <xsl:call-template name="count.uri.path.depth">
|
---|
| 580 | <xsl:with-param name="filename" select="$href.from"/>
|
---|
| 581 | </xsl:call-template>
|
---|
| 582 | </xsl:variable>
|
---|
| 583 | <xsl:variable name="href">
|
---|
| 584 | <xsl:call-template name="copy-string">
|
---|
| 585 | <xsl:with-param name="string" select="'../'"/>
|
---|
| 586 | <xsl:with-param name="count" select="$depth"/>
|
---|
| 587 | </xsl:call-template>
|
---|
| 588 | <xsl:value-of select="$href.to"/>
|
---|
| 589 | </xsl:variable>
|
---|
| 590 |
|
---|
| 591 | <xsl:value-of select="$href"/>
|
---|
| 592 | </xsl:template>
|
---|
| 593 |
|
---|
| 594 | <!-- ==================================================================== -->
|
---|
| 595 |
|
---|
| 596 | <xsl:template name="generate.css.files">
|
---|
| 597 | <xsl:call-template name="generate.default.css.file"/>
|
---|
| 598 | <xsl:call-template name="generate.custom.css.file"/>
|
---|
| 599 | </xsl:template>
|
---|
| 600 |
|
---|
| 601 | <xsl:template name="generate.default.css.file">
|
---|
| 602 | <xsl:if test="$make.clean.html != 0 and
|
---|
| 603 | $generate.css.header = 0 and
|
---|
| 604 | $docbook.css.source != ''">
|
---|
| 605 | <!-- Select default file relative to stylesheet -->
|
---|
| 606 | <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
|
---|
| 607 |
|
---|
| 608 | <xsl:call-template name="generate.css.file">
|
---|
| 609 | <xsl:with-param name="src" select="$docbook.css.source"/>
|
---|
| 610 | <xsl:with-param name="css.node" select="$css.node"/>
|
---|
| 611 | </xsl:call-template>
|
---|
| 612 | </xsl:if>
|
---|
| 613 | </xsl:template>
|
---|
| 614 |
|
---|
| 615 | <xsl:template name="generate.custom.css.file">
|
---|
| 616 | <xsl:if test="$custom.css.source != '' and
|
---|
| 617 | $generate.css.header = 0">
|
---|
| 618 | <!-- Select custom file relative to document -->
|
---|
| 619 | <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
|
---|
| 620 |
|
---|
| 621 | <xsl:call-template name="generate.css.file">
|
---|
| 622 | <xsl:with-param name="src" select="$custom.css.source"/>
|
---|
| 623 | <xsl:with-param name="css.node" select="$css.node"/>
|
---|
| 624 | </xsl:call-template>
|
---|
| 625 | </xsl:if>
|
---|
| 626 | </xsl:template>
|
---|
| 627 |
|
---|
| 628 | <xsl:template name="generate.css.file">
|
---|
| 629 | <xsl:param name="css.node"/>
|
---|
| 630 | <xsl:param name="src" select="''"/>
|
---|
| 631 |
|
---|
| 632 | <xsl:variable name="css.text" select="$css.node/text()"/>
|
---|
| 633 |
|
---|
| 634 | <xsl:choose>
|
---|
| 635 | <xsl:when test="count($css.node) = 0">
|
---|
| 636 | <xsl:message>
|
---|
| 637 | <xsl:text>ERROR: no root element for CSS source file'</xsl:text>
|
---|
| 638 | <xsl:value-of select="$src"/>
|
---|
| 639 | <xsl:text>'.</xsl:text>
|
---|
| 640 | </xsl:message>
|
---|
| 641 | </xsl:when>
|
---|
| 642 | <xsl:otherwise>
|
---|
| 643 | <xsl:variable name="filename">
|
---|
| 644 | <xsl:call-template name="css.output.pathname">
|
---|
| 645 | <xsl:with-param name="src" select="$src"/>
|
---|
| 646 | <xsl:with-param name="content" select="$css.node"/>
|
---|
| 647 | </xsl:call-template>
|
---|
| 648 | </xsl:variable>
|
---|
| 649 |
|
---|
| 650 | <xsl:call-template name="write.text.chunk">
|
---|
| 651 | <xsl:with-param name="filename" select="$filename"/>
|
---|
| 652 | <xsl:with-param name="content" select="$css.text"/>
|
---|
| 653 | </xsl:call-template>
|
---|
| 654 |
|
---|
| 655 | </xsl:otherwise>
|
---|
| 656 | </xsl:choose>
|
---|
| 657 | </xsl:template>
|
---|
| 658 |
|
---|
| 659 | <xsl:template name="css.output.filename">
|
---|
| 660 | <xsl:param name="content"/>
|
---|
| 661 | <xsl:param name="src" select="''"/>
|
---|
| 662 |
|
---|
| 663 | <xsl:variable name="candidate">
|
---|
| 664 | <xsl:choose>
|
---|
| 665 | <xsl:when test="string-length($src) = 0">
|
---|
| 666 | <xsl:message>
|
---|
| 667 | <xsl:text>ERROR: missing CSS input filename.</xsl:text>
|
---|
| 668 | </xsl:message>
|
---|
| 669 | </xsl:when>
|
---|
| 670 | <xsl:when test="substring($src,string-length($src)-3) = '.xml'">
|
---|
| 671 | <xsl:value-of select="substring($src, 1, string-length($src) - 4)"/>
|
---|
| 672 | </xsl:when>
|
---|
| 673 | <xsl:otherwise>
|
---|
| 674 | <xsl:value-of select="$src"/>
|
---|
| 675 | </xsl:otherwise>
|
---|
| 676 | </xsl:choose>
|
---|
| 677 | </xsl:variable>
|
---|
| 678 | <xsl:value-of select="$candidate"/>
|
---|
| 679 | </xsl:template>
|
---|
| 680 |
|
---|
| 681 | <xsl:template name="css.output.pathname">
|
---|
| 682 | <xsl:param name="content"/>
|
---|
| 683 | <xsl:param name="src" select="''"/>
|
---|
| 684 |
|
---|
| 685 | <xsl:variable name="file">
|
---|
| 686 | <xsl:call-template name="css.output.filename">
|
---|
| 687 | <xsl:with-param name="content" select="$content"/>
|
---|
| 688 | <xsl:with-param name="src" select="$src"/>
|
---|
| 689 | </xsl:call-template>
|
---|
| 690 | </xsl:variable>
|
---|
| 691 |
|
---|
| 692 | <xsl:variable name="path" select="concat($chunk.base.dir, $file)"/>
|
---|
| 693 | <xsl:value-of select="$path"/>
|
---|
| 694 |
|
---|
| 695 | </xsl:template>
|
---|
| 696 |
|
---|
| 697 | </xsl:stylesheet>
|
---|
| 698 |
|
---|