1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:ng="http://docbook.org/docbook-ng" 4 xmlns:db="http://docbook.org/ns/docbook" 5 xmlns:exsl="http://exslt.org/common" 6 exclude-result-prefixes="db ng exsl" 7 version='1.0'> 8 9<xsl:output method="html" 10 encoding="ISO-8859-1" 11 indent="no"/> 12 13<!-- ******************************************************************** 14 $Id: docbook.xsl,v 1.41 2006/04/21 14:37:19 nwalsh Exp $ 15 ******************************************************************** 16 17 This file is part of the XSL DocBook Stylesheet distribution. 18 See ../README or http://nwalsh.com/docbook/xsl/ for copyright 19 and other information. 20 21 ******************************************************************** --> 22 23<!-- ==================================================================== --> 24 25<xsl:include href="../VERSION"/> 26<xsl:include href="param.xsl"/> 27<xsl:include href="../lib/lib.xsl"/> 28<xsl:include href="../common/l10n.xsl"/> 29<xsl:include href="../common/common.xsl"/> 30<xsl:include href="../common/labels.xsl"/> 31<xsl:include href="../common/titles.xsl"/> 32<xsl:include href="../common/subtitles.xsl"/> 33<xsl:include href="../common/gentext.xsl"/> 34<xsl:include href="../common/targets.xsl"/> 35<xsl:include href="../common/olink.xsl"/> 36<xsl:include href="../common/pi.xsl"/> 37<xsl:include href="autotoc.xsl"/> 38<xsl:include href="autoidx.xsl"/> 39<xsl:include href="lists.xsl"/> 40<xsl:include href="callout.xsl"/> 41<xsl:include href="verbatim.xsl"/> 42<xsl:include href="graphics.xsl"/> 43<xsl:include href="xref.xsl"/> 44<xsl:include href="formal.xsl"/> 45<xsl:include href="table.xsl"/> 46<xsl:include href="htmltbl.xsl"/> 47<xsl:include href="sections.xsl"/> 48<xsl:include href="inline.xsl"/> 49<xsl:include href="footnote.xsl"/> 50<xsl:include href="html.xsl"/> 51<xsl:include href="info.xsl"/> 52<xsl:include href="keywords.xsl"/> 53<xsl:include href="division.xsl"/> 54<xsl:include href="toc.xsl"/> 55<xsl:include href="index.xsl"/> 56<xsl:include href="refentry.xsl"/> 57<xsl:include href="math.xsl"/> 58<xsl:include href="admon.xsl"/> 59<xsl:include href="component.xsl"/> 60<xsl:include href="biblio.xsl"/> 61<xsl:include href="glossary.xsl"/> 62<xsl:include href="block.xsl"/> 63<xsl:include href="task.xsl"/> 64<xsl:include href="qandaset.xsl"/> 65<xsl:include href="synop.xsl"/> 66<xsl:include href="titlepage.xsl"/> 67<xsl:include href="titlepage.templates.xsl"/> 68<xsl:include href="pi.xsl"/> 69<xsl:include href="ebnf.xsl"/> 70<xsl:include href="chunker.xsl"/> 71<xsl:include href="html-rtf.xsl"/> 72<xsl:include href="docbookng.xsl"/> 73<xsl:include href="annotations.xsl"/> 74<xsl:include href="../common/stripns.xsl"/> 75 76<xsl:param name="stylesheet.result.type" select="'html'"/> 77<xsl:param name="htmlhelp.output" select="0"/> 78 79<!-- ==================================================================== --> 80 81<xsl:key name="id" match="*" use="@id|@xml:id"/> 82<xsl:key name="gid" match="*" use="generate-id()"/> 83 84<!-- ==================================================================== --> 85 86<xsl:template match="*"> 87 <xsl:message> 88 <xsl:text>No template matches </xsl:text> 89 <xsl:value-of select="name(.)"/> 90 <xsl:if test="parent::*"> 91 <xsl:text> in </xsl:text> 92 <xsl:value-of select="name(parent::*)"/> 93 </xsl:if> 94 <xsl:text>.</xsl:text> 95 </xsl:message> 96 97 <font color="red"> 98 <xsl:text><</xsl:text> 99 <xsl:value-of select="name(.)"/> 100 <xsl:text>></xsl:text> 101 <xsl:apply-templates/> 102 <xsl:text></</xsl:text> 103 <xsl:value-of select="name(.)"/> 104 <xsl:text>></xsl:text> 105 </font> 106</xsl:template> 107 108<xsl:template match="text()"> 109 <xsl:value-of select="."/> 110</xsl:template> 111 112<xsl:template name="body.attributes"> 113 <xsl:attribute name="bgcolor">white</xsl:attribute> 114 <xsl:attribute name="text">black</xsl:attribute> 115 <xsl:attribute name="link">#0000FF</xsl:attribute> 116 <xsl:attribute name="vlink">#840084</xsl:attribute> 117 <xsl:attribute name="alink">#0000FF</xsl:attribute> 118</xsl:template> 119 120<xsl:template name="head.content"> 121 <xsl:param name="node" select="."/> 122 <xsl:param name="title"> 123 <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/> 124 </xsl:param> 125 126 <title> 127 <xsl:copy-of select="$title"/> 128 </title> 129 130 <xsl:if test="$html.stylesheet != ''"> 131 <xsl:call-template name="output.html.stylesheets"> 132 <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/> 133 </xsl:call-template> 134 </xsl:if> 135 136 <xsl:if test="$link.mailto.url != ''"> 137 <link rev="made" 138 href="{$link.mailto.url}"/> 139 </xsl:if> 140 141 <xsl:if test="$html.base != ''"> 142 <base href="{$html.base}"/> 143 </xsl:if> 144 145 <meta name="generator" content="DocBook XSL Stylesheets V{$VERSION}"/> 146 147 <xsl:if test="$generate.meta.abstract != 0"> 148 <xsl:variable name="info" select="(articleinfo 149 |bookinfo 150 |prefaceinfo 151 |chapterinfo 152 |appendixinfo 153 |sectioninfo 154 |sect1info 155 |sect2info 156 |sect3info 157 |sect4info 158 |sect5info 159 |referenceinfo 160 |refentryinfo 161 |partinfo 162 |info 163 |docinfo)[1]"/> 164 <xsl:if test="$info and $info/abstract"> 165 <meta name="description"> 166 <xsl:attribute name="content"> 167 <xsl:for-each select="$info/abstract[1]/*"> 168 <xsl:value-of select="normalize-space(.)"/> 169 <xsl:if test="position() < last()"> 170 <xsl:text> </xsl:text> 171 </xsl:if> 172 </xsl:for-each> 173 </xsl:attribute> 174 </meta> 175 </xsl:if> 176 </xsl:if> 177 178 <xsl:if test="($draft.mode = 'yes' or 179 ($draft.mode = 'maybe' and 180 ancestor-or-self::*[@status][1]/@status = 'draft')) 181 and $draft.watermark.image != ''"> 182 <style type="text/css"><xsl:text> 183body { background-image: url('</xsl:text> 184<xsl:value-of select="$draft.watermark.image"/><xsl:text>'); 185 background-repeat: no-repeat; 186 background-position: top left; 187 /* The following properties make the watermark "fixed" on the page. */ 188 /* I think that's just a bit too distracting for the reader... */ 189 /* background-attachment: fixed; */ 190 /* background-position: center center; */ 191 }</xsl:text> 192 </style> 193 </xsl:if> 194 <xsl:apply-templates select="." mode="head.keywords.content"/> 195</xsl:template> 196 197<xsl:template name="output.html.stylesheets"> 198 <xsl:param name="stylesheets" select="''"/> 199 200 <xsl:choose> 201 <xsl:when test="contains($stylesheets, ' ')"> 202 <link rel="stylesheet" href="{substring-before($stylesheets, ' ')}"> 203 <xsl:if test="$html.stylesheet.type != ''"> 204 <xsl:attribute name="type"> 205 <xsl:value-of select="$html.stylesheet.type"/> 206 </xsl:attribute> 207 </xsl:if> 208 </link> 209 <xsl:call-template name="output.html.stylesheets"> 210 <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/> 211 </xsl:call-template> 212 </xsl:when> 213 <xsl:when test="$stylesheets != ''"> 214 <link rel="stylesheet" href="{$stylesheets}"> 215 <xsl:if test="$html.stylesheet.type != ''"> 216 <xsl:attribute name="type"> 217 <xsl:value-of select="$html.stylesheet.type"/> 218 </xsl:attribute> 219 </xsl:if> 220 </link> 221 </xsl:when> 222 </xsl:choose> 223</xsl:template> 224 225<!-- ============================================================ --> 226 227<xsl:template match="*" mode="head.keywords.content"> 228 <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/> 229 <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/> 230 <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/> 231 <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/> 232 <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/> 233 <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/> 234 <xsl:apply-templates select="artheader/keywordset" mode="html.header"/> 235 <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/> 236 <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/> 237 <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/> 238 <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/> 239 <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/> 240 <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/> 241 <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/> 242 <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/> 243 <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/> 244 <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/> 245 <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/> 246 <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/> 247 <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/> 248 <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/> 249 <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/> 250 <xsl:apply-templates select="info/keywordset" mode="html.header"/> 251 252 <xsl:if test="$inherit.keywords != 0 253 and parent::*"> 254 <xsl:apply-templates select="parent::*" mode="head.keywords.content"/> 255 </xsl:if> 256</xsl:template> 257 258<!-- ============================================================ --> 259 260<xsl:template name="system.head.content"> 261 <xsl:param name="node" select="."/> 262 263 <!-- FIXME: When chunking, only the annotations actually used 264 in this chunk should be referenced. I don't think it 265 does any harm to reference them all, but it adds 266 unnecessary bloat to each chunk. --> 267 <xsl:if test="$annotation.support != 0 and //annotation"> 268 <xsl:call-template name="add.annotation.links"/> 269 <script type="text/javascript"> 270 <xsl:text> // Create PopupWindow objects</xsl:text> 271 <xsl:for-each select="//annotation"> 272 <xsl:text> var popup_</xsl:text> 273 <xsl:value-of select="generate-id(.)"/> 274 <xsl:text> = new PopupWindow("popup-</xsl:text> 275 <xsl:value-of select="generate-id(.)"/> 276 <xsl:text>"); </xsl:text> 277 <xsl:text>popup_</xsl:text> 278 <xsl:value-of select="generate-id(.)"/> 279 <xsl:text>.offsetY = 15; </xsl:text> 280 <xsl:text>popup_</xsl:text> 281 <xsl:value-of select="generate-id(.)"/> 282 <xsl:text>.autoHide(); </xsl:text> 283 </xsl:for-each> 284 </script> 285 286 <style type="text/css"> 287 <xsl:value-of select="$annotation.css"/> 288 </style> 289 </xsl:if> 290 291 <!-- system.head.content is like user.head.content, except that 292 it is called before head.content. This is important because it 293 means, for example, that <style> elements output by system.head.content 294 have a lower CSS precedence than the users stylesheet. --> 295</xsl:template> 296 297<!-- ============================================================ --> 298 299<xsl:template name="user.preroot"> 300 <!-- Pre-root output, can be used to output comments and PIs. --> 301 <!-- This must not output any element content! --> 302</xsl:template> 303 304<xsl:template name="user.head.content"> 305 <xsl:param name="node" select="."/> 306</xsl:template> 307 308<xsl:template name="user.header.navigation"> 309 <xsl:param name="node" select="."/> 310</xsl:template> 311 312<xsl:template name="user.header.content"> 313 <xsl:param name="node" select="."/> 314</xsl:template> 315 316<xsl:template name="user.footer.content"> 317 <xsl:param name="node" select="."/> 318</xsl:template> 319 320<xsl:template name="user.footer.navigation"> 321 <xsl:param name="node" select="."/> 322</xsl:template> 323 324<xsl:template match="/"> 325 <xsl:choose> 326 <xsl:when test="function-available('exsl:node-set') 327 and (*/self::ng:* or */self::db:*)"> 328 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document, 329 toss the namespace and continue. Someday we'll reverse this logic 330 and add the namespace to documents that don't have one. 331 But not before the whole stylesheet has been converted to use 332 namespaces. i.e., don't hold your breath --> 333 <xsl:message>Stripping NS from DocBook 5/NG document.</xsl:message> 334 <xsl:variable name="nons"> 335 <xsl:apply-templates mode="stripNS"/> 336 </xsl:variable> 337 <!-- 338 <xsl:message>Saving stripped document.</xsl:message> 339 <xsl:call-template name="write.chunk"> 340 <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/> 341 <xsl:with-param name="method" select="'xml'"/> 342 <xsl:with-param name="content"> 343 <xsl:copy-of select="exsl:node-set($nons)"/> 344 </xsl:with-param> 345 </xsl:call-template> 346 --> 347 <xsl:message>Processing stripped document.</xsl:message> 348 <xsl:apply-templates select="exsl:node-set($nons)"/> 349 </xsl:when> 350 <xsl:otherwise> 351 <xsl:choose> 352 <xsl:when test="$rootid != ''"> 353 <xsl:choose> 354 <xsl:when test="count(key('id',$rootid)) = 0"> 355 <xsl:message terminate="yes"> 356 <xsl:text>ID '</xsl:text> 357 <xsl:value-of select="$rootid"/> 358 <xsl:text>' not found in document.</xsl:text> 359 </xsl:message> 360 </xsl:when> 361 <xsl:otherwise> 362 <xsl:if test="$collect.xref.targets = 'yes' or 363 $collect.xref.targets = 'only'"> 364 <xsl:apply-templates select="key('id', $rootid)" 365 mode="collect.targets"/> 366 </xsl:if> 367 <xsl:if test="$collect.xref.targets != 'only'"> 368 <xsl:apply-templates select="key('id',$rootid)" 369 mode="process.root"/> 370 <xsl:if test="$tex.math.in.alt != ''"> 371 <xsl:apply-templates select="key('id',$rootid)" 372 mode="collect.tex.math"/> 373 </xsl:if> 374 </xsl:if> 375 </xsl:otherwise> 376 </xsl:choose> 377 </xsl:when> 378 <xsl:otherwise> 379 <xsl:if test="$collect.xref.targets = 'yes' or 380 $collect.xref.targets = 'only'"> 381 <xsl:apply-templates select="/" mode="collect.targets"/> 382 </xsl:if> 383 <xsl:if test="$collect.xref.targets != 'only'"> 384 <xsl:apply-templates select="/" mode="process.root"/> 385 <xsl:if test="$tex.math.in.alt != ''"> 386 <xsl:apply-templates select="/" mode="collect.tex.math"/> 387 </xsl:if> 388 </xsl:if> 389 </xsl:otherwise> 390 </xsl:choose> 391 </xsl:otherwise> 392 </xsl:choose> 393</xsl:template> 394 395<xsl:template match="*" mode="process.root"> 396 <xsl:variable name="doc" select="self::*"/> 397 398 <xsl:call-template name="user.preroot"/> 399 <xsl:call-template name="root.messages"/> 400 401 <html> 402 <head> 403 <xsl:call-template name="system.head.content"> 404 <xsl:with-param name="node" select="$doc"/> 405 </xsl:call-template> 406 <xsl:call-template name="head.content"> 407 <xsl:with-param name="node" select="$doc"/> 408 </xsl:call-template> 409 <xsl:call-template name="user.head.content"> 410 <xsl:with-param name="node" select="$doc"/> 411 </xsl:call-template> 412 </head> 413 <body> 414 <xsl:call-template name="body.attributes"/> 415 <xsl:call-template name="user.header.content"> 416 <xsl:with-param name="node" select="$doc"/> 417 </xsl:call-template> 418 <xsl:apply-templates select="."/> 419 <xsl:call-template name="user.footer.content"> 420 <xsl:with-param name="node" select="$doc"/> 421 </xsl:call-template> 422 </body> 423 </html> 424</xsl:template> 425 426<xsl:template name="root.messages"> 427 <!-- redefine this any way you'd like to output messages --> 428 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE --> 429</xsl:template> 430 431<!-- ==================================================================== --> 432 433<xsl:template name="chunk"> 434 <xsl:param name="node" select="."/> 435 436 <!-- The default is that we are not chunking... --> 437 <xsl:text>0</xsl:text> 438</xsl:template> 439 440<!-- ==================================================================== --> 441 442</xsl:stylesheet> 443