docbook.xsl 18 KB

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