docbook.xsl 17 KB

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