component.xsl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version='1.0'>
  4. <!-- ********************************************************************
  5. $Id: component.xsl 9500 2012-07-15 23:24:21Z 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. <!-- Set to 2 for backwards compatibility -->
  13. <xsl:param name="component.heading.level" select="2"/>
  14. <xsl:template name="component.title">
  15. <xsl:param name="node" select="."/>
  16. <!-- This handles the case where a component (bibliography, for example)
  17. occurs inside a section; will we need parameters for this? -->
  18. <!-- This "level" is a section level. To compute <h> level, add 1. -->
  19. <xsl:variable name="level">
  20. <xsl:choose>
  21. <!-- chapters and other book children should get <h1> -->
  22. <xsl:when test="$node/parent::book">0</xsl:when>
  23. <xsl:when test="ancestor::section">
  24. <xsl:value-of select="count(ancestor::section)+1"/>
  25. </xsl:when>
  26. <xsl:when test="ancestor::sect5">6</xsl:when>
  27. <xsl:when test="ancestor::sect4">5</xsl:when>
  28. <xsl:when test="ancestor::sect3">4</xsl:when>
  29. <xsl:when test="ancestor::sect2">3</xsl:when>
  30. <xsl:when test="ancestor::sect1">2</xsl:when>
  31. <xsl:otherwise>1</xsl:otherwise>
  32. </xsl:choose>
  33. </xsl:variable>
  34. <xsl:element name="h{$level+1}">
  35. <xsl:attribute name="class">title</xsl:attribute>
  36. <xsl:call-template name="anchor">
  37. <xsl:with-param name="node" select="$node"/>
  38. <xsl:with-param name="conditional" select="0"/>
  39. </xsl:call-template>
  40. <xsl:apply-templates select="$node" mode="object.title.markup">
  41. <xsl:with-param name="allow-anchors" select="1"/>
  42. </xsl:apply-templates>
  43. </xsl:element>
  44. </xsl:template>
  45. <xsl:template name="component.subtitle">
  46. <xsl:param name="node" select="."/>
  47. <xsl:variable name="subtitle"
  48. select="($node/docinfo/subtitle
  49. |$node/info/subtitle
  50. |$node/prefaceinfo/subtitle
  51. |$node/chapterinfo/subtitle
  52. |$node/appendixinfo/subtitle
  53. |$node/articleinfo/subtitle
  54. |$node/artheader/subtitle
  55. |$node/subtitle)[1]"/>
  56. <xsl:if test="$subtitle">
  57. <h3 class="subtitle">
  58. <xsl:call-template name="id.attribute"/>
  59. <i>
  60. <xsl:apply-templates select="$node" mode="object.subtitle.markup"/>
  61. </i>
  62. </h3>
  63. </xsl:if>
  64. </xsl:template>
  65. <xsl:template name="component.separator">
  66. </xsl:template>
  67. <!-- ==================================================================== -->
  68. <xsl:template match="dedication" mode="dedication">
  69. <xsl:call-template name="id.warning"/>
  70. <div>
  71. <xsl:call-template name="common.html.attributes">
  72. <xsl:with-param name="inherit" select="1"/>
  73. </xsl:call-template>
  74. <xsl:call-template name="id.attribute">
  75. <xsl:with-param name="conditional" select="0"/>
  76. </xsl:call-template>
  77. <xsl:call-template name="dedication.titlepage"/>
  78. <xsl:apply-templates/>
  79. <xsl:call-template name="process.footnotes"/>
  80. </div>
  81. </xsl:template>
  82. <xsl:template match="dedication/title|dedication/info/title"
  83. mode="titlepage.mode" priority="2">
  84. <xsl:call-template name="component.title">
  85. <xsl:with-param name="node" select="ancestor::dedication[1]"/>
  86. </xsl:call-template>
  87. </xsl:template>
  88. <xsl:template match="dedication/subtitle|dedication/info/subtitle"
  89. mode="titlepage.mode" priority="2">
  90. <xsl:call-template name="component.subtitle">
  91. <xsl:with-param name="node" select="ancestor::dedication[1]"/>
  92. </xsl:call-template>
  93. </xsl:template>
  94. <xsl:template match="dedication"></xsl:template> <!-- see mode="dedication" -->
  95. <xsl:template match="dedication/title"></xsl:template>
  96. <xsl:template match="dedication/subtitle"></xsl:template>
  97. <xsl:template match="dedication/titleabbrev"></xsl:template>
  98. <!-- ==================================================================== -->
  99. <xsl:template match="acknowledgements" mode="acknowledgements">
  100. <xsl:call-template name="id.warning"/>
  101. <div>
  102. <xsl:call-template name="common.html.attributes">
  103. <xsl:with-param name="inherit" select="1"/>
  104. </xsl:call-template>
  105. <xsl:call-template name="id.attribute">
  106. <xsl:with-param name="conditional" select="0"/>
  107. </xsl:call-template>
  108. <xsl:call-template name="acknowledgements.titlepage"/>
  109. <xsl:apply-templates/>
  110. <xsl:call-template name="process.footnotes"/>
  111. </div>
  112. </xsl:template>
  113. <xsl:template match="acknowledgements/title|acknowledgements/info/title"
  114. mode="titlepage.mode" priority="2">
  115. <xsl:call-template name="component.title">
  116. <xsl:with-param name="node" select="ancestor::acknowledgements[1]"/>
  117. </xsl:call-template>
  118. </xsl:template>
  119. <xsl:template match="acknowledgements/subtitle|acknowledgements/info/subtitle"
  120. mode="titlepage.mode" priority="2">
  121. <xsl:call-template name="component.subtitle">
  122. <xsl:with-param name="node" select="ancestor::acknowledgements[1]"/>
  123. </xsl:call-template>
  124. </xsl:template>
  125. <xsl:template match="acknowledgements"></xsl:template> <!-- see mode="acknowledgements" -->
  126. <xsl:template match="acknowledgements/title"></xsl:template>
  127. <xsl:template match="acknowledgements/subtitle"></xsl:template>
  128. <xsl:template match="acknowledgements/titleabbrev"></xsl:template>
  129. <!-- ==================================================================== -->
  130. <xsl:template match="colophon">
  131. <xsl:call-template name="id.warning"/>
  132. <div>
  133. <xsl:call-template name="common.html.attributes">
  134. <xsl:with-param name="inherit" select="1"/>
  135. </xsl:call-template>
  136. <xsl:call-template name="id.attribute">
  137. <xsl:with-param name="conditional" select="0"/>
  138. </xsl:call-template>
  139. <xsl:call-template name="component.separator"/>
  140. <xsl:call-template name="component.title"/>
  141. <xsl:call-template name="component.subtitle"/>
  142. <xsl:apply-templates/>
  143. <xsl:call-template name="process.footnotes"/>
  144. </div>
  145. </xsl:template>
  146. <xsl:template match="colophon/title"></xsl:template>
  147. <xsl:template match="colophon/subtitle"></xsl:template>
  148. <xsl:template match="colophon/titleabbrev"></xsl:template>
  149. <!-- ==================================================================== -->
  150. <xsl:template match="preface">
  151. <xsl:call-template name="id.warning"/>
  152. <xsl:element name="{$div.element}">
  153. <xsl:call-template name="common.html.attributes">
  154. <xsl:with-param name="inherit" select="1"/>
  155. </xsl:call-template>
  156. <xsl:call-template name="id.attribute">
  157. <xsl:with-param name="conditional" select="0"/>
  158. </xsl:call-template>
  159. <xsl:call-template name="component.separator"/>
  160. <xsl:call-template name="preface.titlepage"/>
  161. <xsl:variable name="toc.params">
  162. <xsl:call-template name="find.path.params">
  163. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  164. </xsl:call-template>
  165. </xsl:variable>
  166. <xsl:if test="contains($toc.params, 'toc')">
  167. <xsl:call-template name="component.toc">
  168. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  169. </xsl:call-template>
  170. <xsl:call-template name="component.toc.separator"/>
  171. </xsl:if>
  172. <xsl:apply-templates/>
  173. <xsl:call-template name="process.footnotes"/>
  174. </xsl:element>
  175. </xsl:template>
  176. <xsl:template match="preface/title" mode="titlepage.mode" priority="2">
  177. <xsl:call-template name="component.title">
  178. <xsl:with-param name="node" select="ancestor::preface[1]"/>
  179. </xsl:call-template>
  180. </xsl:template>
  181. <xsl:template match="preface/subtitle
  182. |preface/prefaceinfo/subtitle
  183. |preface/info/subtitle
  184. |preface/docinfo/subtitle"
  185. mode="titlepage.mode" priority="2">
  186. <xsl:call-template name="component.subtitle">
  187. <xsl:with-param name="node" select="ancestor::preface[1]"/>
  188. </xsl:call-template>
  189. </xsl:template>
  190. <xsl:template match="preface/docinfo|prefaceinfo"></xsl:template>
  191. <xsl:template match="preface/info"></xsl:template>
  192. <xsl:template match="preface/title"></xsl:template>
  193. <xsl:template match="preface/titleabbrev"></xsl:template>
  194. <xsl:template match="preface/subtitle"></xsl:template>
  195. <!-- ==================================================================== -->
  196. <xsl:template match="chapter">
  197. <xsl:call-template name="id.warning"/>
  198. <xsl:element name="{$div.element}">
  199. <xsl:call-template name="common.html.attributes">
  200. <xsl:with-param name="inherit" select="1"/>
  201. </xsl:call-template>
  202. <xsl:call-template name="id.attribute">
  203. <xsl:with-param name="conditional" select="0"/>
  204. </xsl:call-template>
  205. <xsl:call-template name="component.separator"/>
  206. <xsl:call-template name="chapter.titlepage"/>
  207. <xsl:variable name="toc.params">
  208. <xsl:call-template name="find.path.params">
  209. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  210. </xsl:call-template>
  211. </xsl:variable>
  212. <xsl:if test="contains($toc.params, 'toc')">
  213. <xsl:call-template name="component.toc">
  214. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  215. </xsl:call-template>
  216. <xsl:call-template name="component.toc.separator"/>
  217. </xsl:if>
  218. <xsl:apply-templates/>
  219. <xsl:call-template name="process.footnotes"/>
  220. </xsl:element>
  221. </xsl:template>
  222. <xsl:template match="chapter/title|chapter/chapterinfo/title|chapter/info/title"
  223. mode="titlepage.mode" priority="2">
  224. <xsl:call-template name="component.title">
  225. <xsl:with-param name="node" select="ancestor::chapter[1]"/>
  226. </xsl:call-template>
  227. </xsl:template>
  228. <xsl:template match="chapter/subtitle
  229. |chapter/chapterinfo/subtitle
  230. |chapter/info/subtitle
  231. |chapter/docinfo/subtitle"
  232. mode="titlepage.mode" priority="2">
  233. <xsl:call-template name="component.subtitle">
  234. <xsl:with-param name="node" select="ancestor::chapter[1]"/>
  235. </xsl:call-template>
  236. </xsl:template>
  237. <xsl:template match="chapter/docinfo|chapterinfo"></xsl:template>
  238. <xsl:template match="chapter/info"></xsl:template>
  239. <xsl:template match="chapter/title"></xsl:template>
  240. <xsl:template match="chapter/titleabbrev"></xsl:template>
  241. <xsl:template match="chapter/subtitle"></xsl:template>
  242. <!-- ==================================================================== -->
  243. <xsl:template match="appendix">
  244. <xsl:variable name="ischunk">
  245. <xsl:call-template name="chunk"/>
  246. </xsl:variable>
  247. <xsl:call-template name="id.warning"/>
  248. <xsl:element name="{$div.element}">
  249. <xsl:call-template name="common.html.attributes">
  250. <xsl:with-param name="inherit" select="1"/>
  251. </xsl:call-template>
  252. <xsl:call-template name="id.attribute">
  253. <xsl:with-param name="conditional" select="0"/>
  254. </xsl:call-template>
  255. <xsl:choose>
  256. <xsl:when test="parent::article and $ischunk = 0">
  257. <xsl:call-template name="section.heading">
  258. <xsl:with-param name="level" select="1"/>
  259. <xsl:with-param name="title">
  260. <xsl:apply-templates select="." mode="object.title.markup"/>
  261. </xsl:with-param>
  262. </xsl:call-template>
  263. </xsl:when>
  264. <xsl:otherwise>
  265. <xsl:call-template name="component.separator"/>
  266. <xsl:call-template name="appendix.titlepage"/>
  267. </xsl:otherwise>
  268. </xsl:choose>
  269. <xsl:variable name="toc.params">
  270. <xsl:call-template name="find.path.params">
  271. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  272. </xsl:call-template>
  273. </xsl:variable>
  274. <xsl:if test="contains($toc.params, 'toc')">
  275. <xsl:call-template name="component.toc">
  276. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  277. </xsl:call-template>
  278. <xsl:call-template name="component.toc.separator"/>
  279. </xsl:if>
  280. <xsl:apply-templates/>
  281. <xsl:if test="not(parent::article) or $ischunk != 0">
  282. <xsl:call-template name="process.footnotes"/>
  283. </xsl:if>
  284. </xsl:element>
  285. </xsl:template>
  286. <xsl:template match="appendix/title|appendix/appendixinfo/title"
  287. mode="titlepage.mode" priority="2">
  288. <xsl:call-template name="component.title">
  289. <xsl:with-param name="node" select="ancestor::appendix[1]"/>
  290. </xsl:call-template>
  291. </xsl:template>
  292. <xsl:template match="appendix/subtitle
  293. |appendix/appendixinfo/subtitle
  294. |appendix/info/subtitle
  295. |appendix/docinfo/subtitle"
  296. mode="titlepage.mode" priority="2">
  297. <xsl:call-template name="component.subtitle">
  298. <xsl:with-param name="node" select="ancestor::appendix[1]"/>
  299. </xsl:call-template>
  300. </xsl:template>
  301. <xsl:template match="appendix/docinfo|appendixinfo"></xsl:template>
  302. <xsl:template match="appendix/info"></xsl:template>
  303. <xsl:template match="appendix/title"></xsl:template>
  304. <xsl:template match="appendix/titleabbrev"></xsl:template>
  305. <xsl:template match="appendix/subtitle"></xsl:template>
  306. <!-- ==================================================================== -->
  307. <xsl:template match="article">
  308. <xsl:call-template name="id.warning"/>
  309. <xsl:element name="{$div.element}">
  310. <xsl:call-template name="common.html.attributes">
  311. <xsl:with-param name="inherit" select="1"/>
  312. </xsl:call-template>
  313. <xsl:call-template name="id.attribute">
  314. <xsl:with-param name="conditional" select="0"/>
  315. </xsl:call-template>
  316. <xsl:call-template name="article.titlepage"/>
  317. <xsl:variable name="toc.params">
  318. <xsl:call-template name="find.path.params">
  319. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  320. </xsl:call-template>
  321. </xsl:variable>
  322. <xsl:call-template name="make.lots">
  323. <xsl:with-param name="toc.params" select="$toc.params"/>
  324. <xsl:with-param name="toc">
  325. <xsl:call-template name="component.toc">
  326. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  327. </xsl:call-template>
  328. </xsl:with-param>
  329. </xsl:call-template>
  330. <xsl:apply-templates/>
  331. <xsl:call-template name="process.footnotes"/>
  332. </xsl:element>
  333. </xsl:template>
  334. <xsl:template match="article/title|article/articleinfo/title" mode="titlepage.mode" priority="2">
  335. <xsl:call-template name="component.title">
  336. <xsl:with-param name="node" select="ancestor::article[1]"/>
  337. </xsl:call-template>
  338. </xsl:template>
  339. <xsl:template match="article/subtitle
  340. |article/articleinfo/subtitle
  341. |article/info/subtitle
  342. |article/artheader/subtitle"
  343. mode="titlepage.mode" priority="2">
  344. <xsl:call-template name="component.subtitle">
  345. <xsl:with-param name="node" select="ancestor::article[1]"/>
  346. </xsl:call-template>
  347. </xsl:template>
  348. <xsl:template match="article/artheader|article/articleinfo"></xsl:template>
  349. <xsl:template match="article/info"></xsl:template>
  350. <xsl:template match="article/title"></xsl:template>
  351. <xsl:template match="article/titleabbrev"></xsl:template>
  352. <xsl:template match="article/subtitle"></xsl:template>
  353. <!-- ==================================================================== -->
  354. <xsl:template match="topic">
  355. <xsl:call-template name="id.warning"/>
  356. <xsl:element name="{$div.element}">
  357. <xsl:call-template name="common.html.attributes">
  358. <xsl:with-param name="inherit" select="1"/>
  359. </xsl:call-template>
  360. <xsl:call-template name="id.attribute">
  361. <xsl:with-param name="conditional" select="0"/>
  362. </xsl:call-template>
  363. <xsl:call-template name="topic.titlepage"/>
  364. <xsl:variable name="toc.params">
  365. <xsl:call-template name="find.path.params">
  366. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  367. </xsl:call-template>
  368. </xsl:variable>
  369. <xsl:apply-templates/>
  370. <xsl:call-template name="process.footnotes"/>
  371. </xsl:element>
  372. </xsl:template>
  373. <xsl:template match="topic/title|topic/info/title" mode="titlepage.mode" priority="2">
  374. <xsl:call-template name="component.title">
  375. <xsl:with-param name="node" select="ancestor::topic[1]"/>
  376. </xsl:call-template>
  377. </xsl:template>
  378. <xsl:template match="topic/subtitle
  379. |topic/info/subtitle"
  380. mode="titlepage.mode" priority="2">
  381. <xsl:call-template name="component.subtitle">
  382. <xsl:with-param name="node" select="ancestor::topic[1]"/>
  383. </xsl:call-template>
  384. </xsl:template>
  385. <xsl:template match="topic/info"></xsl:template>
  386. <xsl:template match="topic/title"></xsl:template>
  387. <xsl:template match="topic/titleabbrev"></xsl:template>
  388. <xsl:template match="topic/subtitle"></xsl:template>
  389. </xsl:stylesheet>