refentry.xsl 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version='1.0'>
  4. <!-- ********************************************************************
  5. $Id: refentry.xsl 9297 2012-04-22 03:56:16Z bobstayton $
  6. ********************************************************************
  7. This file is part of the XSL DocBook Stylesheet distribution.
  8. See ../README or http://docbook.sf.net/release/xsl/current/ for
  9. copyright and other information.
  10. ******************************************************************** -->
  11. <!-- ==================================================================== -->
  12. <xsl:template match="reference">
  13. <xsl:call-template name="id.warning"/>
  14. <div>
  15. <xsl:call-template name="common.html.attributes">
  16. <xsl:with-param name="inherit" select="1"/>
  17. </xsl:call-template>
  18. <xsl:call-template name="id.attribute">
  19. <xsl:with-param name="conditional" select="0"/>
  20. </xsl:call-template>
  21. <xsl:call-template name="reference.titlepage"/>
  22. <xsl:variable name="toc.params">
  23. <xsl:call-template name="find.path.params">
  24. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  25. </xsl:call-template>
  26. </xsl:variable>
  27. <xsl:if test="not(partintro) and contains($toc.params, 'toc')">
  28. <xsl:call-template name="division.toc"/>
  29. </xsl:if>
  30. <xsl:apply-templates/>
  31. </div>
  32. </xsl:template>
  33. <xsl:template match="reference" mode="division.number">
  34. <xsl:number from="book" count="reference" format="I."/>
  35. </xsl:template>
  36. <xsl:template match="reference/docinfo"></xsl:template>
  37. <xsl:template match="reference/referenceinfo"></xsl:template>
  38. <xsl:template match="reference/title"></xsl:template>
  39. <xsl:template match="reference/subtitle"></xsl:template>
  40. <xsl:template match="reference/titleabbrev"></xsl:template>
  41. <!-- ==================================================================== -->
  42. <xsl:template name="refentry.title">
  43. <xsl:param name="node" select="."/>
  44. <xsl:variable name="refmeta" select="$node//refmeta"/>
  45. <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
  46. <xsl:variable name="refnamediv" select="$node//refnamediv"/>
  47. <xsl:variable name="refname" select="$refnamediv//refname"/>
  48. <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
  49. <xsl:variable name="title">
  50. <xsl:choose>
  51. <xsl:when test="$refentrytitle">
  52. <xsl:apply-templates select="$refentrytitle[1]" mode="title"/>
  53. </xsl:when>
  54. <xsl:when test="$refdesc">
  55. <xsl:apply-templates select="$refdesc[1]" mode="title"/>
  56. </xsl:when>
  57. <xsl:when test="$refname">
  58. <xsl:apply-templates select="$refname[1]" mode="title"/>
  59. </xsl:when>
  60. <xsl:otherwise></xsl:otherwise>
  61. </xsl:choose>
  62. </xsl:variable>
  63. <h1 class="title">
  64. <xsl:copy-of select="$title"/>
  65. </h1>
  66. </xsl:template>
  67. <xsl:template match="refentry">
  68. <xsl:call-template name="id.warning"/>
  69. <div>
  70. <xsl:call-template name="common.html.attributes">
  71. <xsl:with-param name="inherit" select="1"/>
  72. </xsl:call-template>
  73. <xsl:call-template name="id.attribute">
  74. <xsl:with-param name="conditional" select="0"/>
  75. </xsl:call-template>
  76. <xsl:if test="$refentry.separator != 0 and preceding-sibling::refentry">
  77. <div class="refentry.separator">
  78. <hr/>
  79. </div>
  80. </xsl:if>
  81. <xsl:call-template name="anchor">
  82. <xsl:with-param name="conditional" select="0"/>
  83. </xsl:call-template>
  84. <xsl:call-template name="refentry.titlepage"/>
  85. <xsl:apply-templates/>
  86. <xsl:call-template name="process.footnotes"/>
  87. </div>
  88. </xsl:template>
  89. <xsl:template match="refentry/docinfo|refentry/refentryinfo"></xsl:template>
  90. <xsl:template match="refentry/info"></xsl:template>
  91. <xsl:template match="refentrytitle|refname|refdescriptor" mode="title">
  92. <xsl:apply-templates/>
  93. </xsl:template>
  94. <xsl:template match="refmeta">
  95. </xsl:template>
  96. <xsl:template match="manvolnum">
  97. <xsl:if test="$refentry.xref.manvolnum != 0">
  98. <xsl:text>(</xsl:text>
  99. <xsl:apply-templates/>
  100. <xsl:text>)</xsl:text>
  101. </xsl:if>
  102. </xsl:template>
  103. <xsl:template match="refmiscinfo">
  104. </xsl:template>
  105. <xsl:template match="refentrytitle">
  106. <xsl:call-template name="inline.charseq"/>
  107. </xsl:template>
  108. <xsl:template match="refnamediv">
  109. <div>
  110. <xsl:call-template name="common.html.attributes">
  111. <xsl:with-param name="inherit" select="1"/>
  112. </xsl:call-template>
  113. <xsl:call-template name="id.attribute"/>
  114. <xsl:call-template name="anchor"/>
  115. <xsl:choose>
  116. <xsl:when test="preceding-sibling::refnamediv">
  117. <!-- no title on secondary refnamedivs! -->
  118. </xsl:when>
  119. <xsl:when test="$refentry.generate.name != 0">
  120. <h2>
  121. <xsl:call-template name="gentext">
  122. <xsl:with-param name="key" select="'RefName'"/>
  123. </xsl:call-template>
  124. </h2>
  125. </xsl:when>
  126. <xsl:when test="$refentry.generate.title != 0">
  127. <h2>
  128. <xsl:choose>
  129. <xsl:when test="../refmeta/refentrytitle">
  130. <xsl:apply-templates select="../refmeta/refentrytitle"/>
  131. </xsl:when>
  132. <xsl:otherwise>
  133. <xsl:apply-templates select="refname[1]"/>
  134. </xsl:otherwise>
  135. </xsl:choose>
  136. </h2>
  137. </xsl:when>
  138. </xsl:choose>
  139. <p>
  140. <xsl:apply-templates/>
  141. </p>
  142. </div>
  143. </xsl:template>
  144. <xsl:template match="refname">
  145. <xsl:if test="not(preceding-sibling::refdescriptor)">
  146. <xsl:apply-templates/>
  147. <xsl:if test="following-sibling::refname">
  148. <xsl:text>, </xsl:text>
  149. </xsl:if>
  150. </xsl:if>
  151. </xsl:template>
  152. <xsl:template match="refpurpose">
  153. <xsl:if test="node()">
  154. <xsl:text> </xsl:text>
  155. <xsl:call-template name="dingbat">
  156. <xsl:with-param name="dingbat">em-dash</xsl:with-param>
  157. </xsl:call-template>
  158. <xsl:text> </xsl:text>
  159. <xsl:apply-templates/>
  160. </xsl:if>
  161. </xsl:template>
  162. <xsl:template match="refdescriptor">
  163. <xsl:apply-templates/>
  164. </xsl:template>
  165. <xsl:template match="refclass">
  166. <xsl:if test="$refclass.suppress = 0">
  167. <b>
  168. <xsl:if test="@role">
  169. <xsl:value-of select="@role"/>
  170. <xsl:text>: </xsl:text>
  171. </xsl:if>
  172. <xsl:apply-templates/>
  173. </b>
  174. </xsl:if>
  175. </xsl:template>
  176. <xsl:template match="refsynopsisdiv">
  177. <div>
  178. <xsl:call-template name="common.html.attributes">
  179. <xsl:with-param name="inherit" select="1"/>
  180. </xsl:call-template>
  181. <xsl:call-template name="id.attribute"/>
  182. <xsl:call-template name="anchor"/>
  183. <h2>
  184. <xsl:choose>
  185. <xsl:when test="refsynopsisdiv/title|title">
  186. <xsl:apply-templates select="(refsynopsisdiv/title|title)[1]"
  187. mode="titlepage.mode"/>
  188. </xsl:when>
  189. <xsl:otherwise>
  190. <xsl:call-template name="gentext">
  191. <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
  192. </xsl:call-template>
  193. </xsl:otherwise>
  194. </xsl:choose>
  195. </h2>
  196. <xsl:apply-templates/>
  197. </div>
  198. </xsl:template>
  199. <xsl:template match="refsynopsisdivinfo"></xsl:template>
  200. <xsl:template match="refsynopsisdiv/title">
  201. </xsl:template>
  202. <xsl:template match="refsynopsisdiv/title" mode="titlepage.mode">
  203. <xsl:apply-templates/>
  204. </xsl:template>
  205. <xsl:template match="refsection|refsect1|refsect2|refsect3">
  206. <div>
  207. <xsl:call-template name="common.html.attributes">
  208. <xsl:with-param name="inherit" select="1"/>
  209. </xsl:call-template>
  210. <xsl:call-template name="id.attribute">
  211. <xsl:with-param name="conditional" select="0"/>
  212. </xsl:call-template>
  213. <xsl:call-template name="anchor">
  214. <xsl:with-param name="conditional" select="0"/>
  215. </xsl:call-template>
  216. <!-- pick up info title -->
  217. <xsl:apply-templates select="(title|info/title)[1]"/>
  218. <xsl:apply-templates select="node()[not(self::title) and not(self::info)]"/>
  219. </div>
  220. </xsl:template>
  221. <xsl:template match="refsection/title|refsection/info/title">
  222. <!-- the ID is output in the block.object call for refsect1 -->
  223. <xsl:variable name="level" select="count(ancestor-or-self::refsection)"/>
  224. <xsl:variable name="refsynopsisdiv">
  225. <xsl:text>0</xsl:text>
  226. <xsl:if test="ancestor::refsynopsisdiv">1</xsl:if>
  227. </xsl:variable>
  228. <xsl:variable name="hlevel">
  229. <xsl:choose>
  230. <xsl:when test="$level+$refsynopsisdiv &gt; 5">6</xsl:when>
  231. <xsl:otherwise>
  232. <xsl:value-of select="$level+1+$refsynopsisdiv"/>
  233. </xsl:otherwise>
  234. </xsl:choose>
  235. </xsl:variable>
  236. <xsl:element name="h{$hlevel}">
  237. <xsl:apply-templates/>
  238. </xsl:element>
  239. </xsl:template>
  240. <xsl:template match="refsect1/title|refsect1/info/title">
  241. <!-- the ID is output in the block.object call for refsect1 -->
  242. <h2>
  243. <xsl:apply-templates/>
  244. </h2>
  245. </xsl:template>
  246. <xsl:template match="refsect2/title|refsect2/info/title">
  247. <!-- the ID is output in the block.object call for refsect2 -->
  248. <h3>
  249. <xsl:apply-templates/>
  250. </h3>
  251. </xsl:template>
  252. <xsl:template match="refsect3/title|refsect3/info/title">
  253. <!-- the ID is output in the block.object call for refsect3 -->
  254. <h4>
  255. <xsl:apply-templates/>
  256. </h4>
  257. </xsl:template>
  258. <xsl:template match="refsectioninfo|refsection/info"></xsl:template>
  259. <xsl:template match="refsect1info|refsect1/info"></xsl:template>
  260. <xsl:template match="refsect2info|refsect2/info"></xsl:template>
  261. <xsl:template match="refsect3info|refsect3/info"></xsl:template>
  262. <!-- ==================================================================== -->
  263. </xsl:stylesheet>