glossary.xsl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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="http://www.w3.org/1999/xhtml" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <xsl:template match="glossary">
  14. <xsl:variable name="language">
  15. <xsl:call-template name="l10n.language"/>
  16. </xsl:variable>
  17. <xsl:variable name="lowercase">
  18. <xsl:call-template name="gentext">
  19. <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
  20. </xsl:call-template>
  21. </xsl:variable>
  22. <xsl:variable name="uppercase">
  23. <xsl:call-template name="gentext">
  24. <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
  25. </xsl:call-template>
  26. </xsl:variable>
  27. <xsl:call-template name="id.warning"/>
  28. <div>
  29. <xsl:apply-templates select="." mode="class.attribute"/>
  30. <xsl:if test="$generate.id.attributes != 0">
  31. <xsl:attribute name="id">
  32. <xsl:call-template name="object.id"/>
  33. </xsl:attribute>
  34. </xsl:if>
  35. <xsl:call-template name="glossary.titlepage"/>
  36. <xsl:choose>
  37. <xsl:when test="glossdiv">
  38. <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. <xsl:choose>
  45. <xsl:when test="glossdiv">
  46. <xsl:apply-templates select="glossdiv"/>
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <dl>
  50. <xsl:choose>
  51. <xsl:when test="$glossary.sort != 0">
  52. <xsl:apply-templates select="glossentry">
  53. <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
  54. </xsl:apply-templates>
  55. </xsl:when>
  56. <xsl:otherwise>
  57. <xsl:apply-templates select="glossentry"/>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </dl>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. <xsl:if test="not(parent::article)">
  64. <xsl:call-template name="process.footnotes"/>
  65. </xsl:if>
  66. </div>
  67. </xsl:template>
  68. <xsl:template match="glossary/glossaryinfo"/>
  69. <xsl:template match="glossary/info"/>
  70. <xsl:template match="glossary/title"/>
  71. <xsl:template match="glossary/subtitle"/>
  72. <xsl:template match="glossary/titleabbrev"/>
  73. <!-- ==================================================================== -->
  74. <xsl:template match="glosslist">
  75. <xsl:variable name="language">
  76. <xsl:call-template name="l10n.language"/>
  77. </xsl:variable>
  78. <xsl:variable name="lowercase">
  79. <xsl:call-template name="gentext">
  80. <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
  81. </xsl:call-template>
  82. </xsl:variable>
  83. <xsl:variable name="uppercase">
  84. <xsl:call-template name="gentext">
  85. <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
  86. </xsl:call-template>
  87. </xsl:variable>
  88. <div>
  89. <xsl:apply-templates select="." mode="class.attribute"/>
  90. <xsl:call-template name="anchor"/>
  91. <xsl:if test="blockinfo/title|info/title|title">
  92. <xsl:call-template name="formal.object.heading"/>
  93. </xsl:if>
  94. <dl>
  95. <xsl:choose>
  96. <xsl:when test="$glossary.sort != 0">
  97. <xsl:apply-templates select="glossentry">
  98. <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
  99. </xsl:apply-templates>
  100. </xsl:when>
  101. <xsl:otherwise>
  102. <xsl:apply-templates select="glossentry"/>
  103. </xsl:otherwise>
  104. </xsl:choose>
  105. </dl>
  106. </div>
  107. </xsl:template>
  108. <!-- ==================================================================== -->
  109. <xsl:template match="glossdiv">
  110. <xsl:variable name="language">
  111. <xsl:call-template name="l10n.language"/>
  112. </xsl:variable>
  113. <xsl:variable name="lowercase">
  114. <xsl:call-template name="gentext">
  115. <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
  116. </xsl:call-template>
  117. </xsl:variable>
  118. <xsl:variable name="uppercase">
  119. <xsl:call-template name="gentext">
  120. <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
  121. </xsl:call-template>
  122. </xsl:variable>
  123. <xsl:call-template name="id.warning"/>
  124. <div>
  125. <xsl:apply-templates select="." mode="class.attribute"/>
  126. <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
  127. <dl>
  128. <xsl:choose>
  129. <xsl:when test="$glossary.sort != 0">
  130. <xsl:apply-templates select="glossentry">
  131. <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
  132. </xsl:apply-templates>
  133. </xsl:when>
  134. <xsl:otherwise>
  135. <xsl:apply-templates select="glossentry"/>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </dl>
  139. </div>
  140. </xsl:template>
  141. <xsl:template match="glossdiv/title">
  142. <h3>
  143. <xsl:apply-templates select="." mode="class.attribute"/>
  144. <xsl:apply-templates/>
  145. </h3>
  146. </xsl:template>
  147. <!-- ==================================================================== -->
  148. <!--
  149. GlossEntry ::=
  150. GlossTerm, Acronym?, Abbrev?,
  151. (IndexTerm)*,
  152. RevHistory?,
  153. (GlossSee | GlossDef+)
  154. -->
  155. <xsl:template match="glossentry">
  156. <xsl:choose>
  157. <xsl:when test="$glossentry.show.acronym = 'primary'">
  158. <dt>
  159. <xsl:call-template name="anchor">
  160. <xsl:with-param name="conditional">
  161. <xsl:choose>
  162. <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
  163. <xsl:otherwise>1</xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:with-param>
  166. </xsl:call-template>
  167. <xsl:choose>
  168. <xsl:when test="acronym|abbrev">
  169. <xsl:apply-templates select="acronym|abbrev"/>
  170. <xsl:text> (</xsl:text>
  171. <xsl:apply-templates select="glossterm"/>
  172. <xsl:text>)</xsl:text>
  173. </xsl:when>
  174. <xsl:otherwise>
  175. <xsl:apply-templates select="glossterm"/>
  176. </xsl:otherwise>
  177. </xsl:choose>
  178. </dt>
  179. </xsl:when>
  180. <xsl:when test="$glossentry.show.acronym = 'yes'">
  181. <dt>
  182. <xsl:call-template name="anchor">
  183. <xsl:with-param name="conditional">
  184. <xsl:choose>
  185. <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
  186. <xsl:otherwise>1</xsl:otherwise>
  187. </xsl:choose>
  188. </xsl:with-param>
  189. </xsl:call-template>
  190. <xsl:apply-templates select="glossterm"/>
  191. <xsl:if test="acronym|abbrev">
  192. <xsl:text> (</xsl:text>
  193. <xsl:apply-templates select="acronym|abbrev"/>
  194. <xsl:text>)</xsl:text>
  195. </xsl:if>
  196. </dt>
  197. </xsl:when>
  198. <xsl:otherwise>
  199. <dt>
  200. <xsl:call-template name="anchor">
  201. <xsl:with-param name="conditional">
  202. <xsl:choose>
  203. <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
  204. <xsl:otherwise>1</xsl:otherwise>
  205. </xsl:choose>
  206. </xsl:with-param>
  207. </xsl:call-template>
  208. <xsl:apply-templates select="glossterm"/>
  209. </dt>
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. <xsl:apply-templates select="indexterm|revhistory|glosssee|glossdef"/>
  213. </xsl:template>
  214. <xsl:template match="glossentry/glossterm">
  215. <xsl:apply-templates/>
  216. <xsl:if test="following-sibling::glossterm">, </xsl:if>
  217. </xsl:template>
  218. <xsl:template match="glossentry/acronym">
  219. <xsl:apply-templates/>
  220. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  221. </xsl:template>
  222. <xsl:template match="glossentry/abbrev">
  223. <xsl:apply-templates/>
  224. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  225. </xsl:template>
  226. <xsl:template match="glossentry/revhistory">
  227. </xsl:template>
  228. <xsl:template match="glossentry/glosssee">
  229. <xsl:variable name="otherterm" select="@otherterm"/>
  230. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  231. <xsl:variable name="target" select="$targets[1]"/>
  232. <dd>
  233. <p>
  234. <xsl:variable name="template">
  235. <xsl:call-template name="gentext.template">
  236. <xsl:with-param name="context" select="'glossary'"/>
  237. <xsl:with-param name="name" select="'see'"/>
  238. </xsl:call-template>
  239. </xsl:variable>
  240. <xsl:variable name="title">
  241. <xsl:choose>
  242. <xsl:when test="$target">
  243. <a>
  244. <xsl:apply-templates select="." mode="class.attribute"/>
  245. <xsl:attribute name="href">
  246. <xsl:call-template name="href.target">
  247. <xsl:with-param name="object" select="$target"/>
  248. </xsl:call-template>
  249. </xsl:attribute>
  250. <xsl:apply-templates select="$target" mode="xref-to"/>
  251. </a>
  252. </xsl:when>
  253. <xsl:when test="$otherterm != '' and not($target)">
  254. <xsl:message>
  255. <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
  256. <xsl:value-of select="$otherterm"/>
  257. </xsl:message>
  258. <xsl:apply-templates/>
  259. </xsl:when>
  260. <xsl:otherwise>
  261. <xsl:apply-templates/>
  262. </xsl:otherwise>
  263. </xsl:choose>
  264. </xsl:variable>
  265. <xsl:call-template name="substitute-markup">
  266. <xsl:with-param name="template" select="$template"/>
  267. <xsl:with-param name="title" select="$title"/>
  268. </xsl:call-template>
  269. <xsl:text>.</xsl:text>
  270. </p>
  271. </dd>
  272. </xsl:template>
  273. <xsl:template match="glossentry/glossdef">
  274. <dd>
  275. <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
  276. <xsl:if test="glossseealso">
  277. <p>
  278. <xsl:variable name="template">
  279. <xsl:call-template name="gentext.template">
  280. <xsl:with-param name="context" select="'glossary'"/>
  281. <xsl:with-param name="name" select="'seealso'"/>
  282. </xsl:call-template>
  283. </xsl:variable>
  284. <xsl:variable name="title">
  285. <xsl:apply-templates select="glossseealso"/>
  286. </xsl:variable>
  287. <xsl:call-template name="substitute-markup">
  288. <xsl:with-param name="template" select="$template"/>
  289. <xsl:with-param name="title" select="$title"/>
  290. </xsl:call-template>
  291. </p>
  292. </xsl:if>
  293. </dd>
  294. </xsl:template>
  295. <xsl:template match="glossseealso">
  296. <xsl:variable name="otherterm" select="@otherterm"/>
  297. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  298. <xsl:variable name="target" select="$targets[1]"/>
  299. <xsl:choose>
  300. <xsl:when test="$target">
  301. <a>
  302. <xsl:apply-templates select="." mode="class.attribute"/>
  303. <xsl:attribute name="href">
  304. <xsl:call-template name="href.target">
  305. <xsl:with-param name="object" select="$target"/>
  306. </xsl:call-template>
  307. </xsl:attribute>
  308. <xsl:apply-templates select="$target" mode="xref-to"/>
  309. </a>
  310. </xsl:when>
  311. <xsl:when test="$otherterm != '' and not($target)">
  312. <xsl:message>
  313. <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
  314. <xsl:value-of select="$otherterm"/>
  315. </xsl:message>
  316. <xsl:apply-templates/>
  317. </xsl:when>
  318. <xsl:otherwise>
  319. <xsl:apply-templates/>
  320. </xsl:otherwise>
  321. </xsl:choose>
  322. <xsl:choose>
  323. <xsl:when test="position() = last()">
  324. <xsl:text>.</xsl:text>
  325. </xsl:when>
  326. <xsl:otherwise>
  327. <xsl:text>, </xsl:text>
  328. </xsl:otherwise>
  329. </xsl:choose>
  330. </xsl:template>
  331. <!-- ==================================================================== -->
  332. <!-- Glossary collection -->
  333. <xsl:template match="glossary[@role='auto']" priority="2">
  334. <xsl:variable name="language">
  335. <xsl:call-template name="l10n.language"/>
  336. </xsl:variable>
  337. <xsl:variable name="lowercase">
  338. <xsl:call-template name="gentext">
  339. <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
  340. </xsl:call-template>
  341. </xsl:variable>
  342. <xsl:variable name="uppercase">
  343. <xsl:call-template name="gentext">
  344. <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
  345. </xsl:call-template>
  346. </xsl:variable>
  347. <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
  348. <xsl:variable name="collection" select="document($glossary.collection, .)"/>
  349. <xsl:call-template name="id.warning"/>
  350. <xsl:if test="$glossary.collection = ''">
  351. <xsl:message>
  352. <xsl:text>Warning: processing automatic glossary </xsl:text>
  353. <xsl:text>without a glossary.collection file.</xsl:text>
  354. </xsl:message>
  355. </xsl:if>
  356. <xsl:if test="not($collection) and $glossary.collection != ''">
  357. <xsl:message>
  358. <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
  359. <xsl:text>open glossary.collection file '</xsl:text>
  360. <xsl:value-of select="$glossary.collection"/>
  361. <xsl:text>'</xsl:text>
  362. </xsl:message>
  363. </xsl:if>
  364. <div>
  365. <xsl:apply-templates select="." mode="class.attribute"/>
  366. <xsl:if test="$generate.id.attributes != 0">
  367. <xsl:attribute name="id">
  368. <xsl:call-template name="object.id"/>
  369. </xsl:attribute>
  370. </xsl:if>
  371. <xsl:call-template name="glossary.titlepage"/>
  372. <xsl:choose>
  373. <xsl:when test="glossdiv and $collection//glossdiv">
  374. <xsl:for-each select="$collection//glossdiv">
  375. <!-- first see if there are any in this div -->
  376. <xsl:variable name="exist.test">
  377. <xsl:for-each select="glossentry">
  378. <xsl:variable name="cterm" select="glossterm"/>
  379. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  380. <xsl:value-of select="glossterm"/>
  381. </xsl:if>
  382. </xsl:for-each>
  383. </xsl:variable>
  384. <xsl:if test="$exist.test != ''">
  385. <xsl:apply-templates select="." mode="auto-glossary">
  386. <xsl:with-param name="terms" select="$terms"/>
  387. </xsl:apply-templates>
  388. </xsl:if>
  389. </xsl:for-each>
  390. </xsl:when>
  391. <xsl:otherwise>
  392. <dl>
  393. <xsl:choose>
  394. <xsl:when test="$glossary.sort != 0">
  395. <xsl:for-each select="$collection//glossentry">
  396. <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
  397. <xsl:variable name="cterm" select="glossterm"/>
  398. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  399. <xsl:apply-templates select="." mode="auto-glossary"/>
  400. </xsl:if>
  401. </xsl:for-each>
  402. </xsl:when>
  403. <xsl:otherwise>
  404. <xsl:for-each select="$collection//glossentry">
  405. <xsl:variable name="cterm" select="glossterm"/>
  406. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  407. <xsl:apply-templates select="." mode="auto-glossary"/>
  408. </xsl:if>
  409. </xsl:for-each>
  410. </xsl:otherwise>
  411. </xsl:choose>
  412. </dl>
  413. </xsl:otherwise>
  414. </xsl:choose>
  415. <xsl:if test="not(parent::article)">
  416. <xsl:call-template name="process.footnotes"/>
  417. </xsl:if>
  418. </div>
  419. </xsl:template>
  420. <xsl:template match="*" mode="auto-glossary">
  421. <!-- pop back out to the default mode for most elements -->
  422. <xsl:apply-templates select="."/>
  423. </xsl:template>
  424. <xsl:template match="glossdiv" mode="auto-glossary">
  425. <xsl:param name="terms" select="."/>
  426. <xsl:variable name="language">
  427. <xsl:call-template name="l10n.language"/>
  428. </xsl:variable>
  429. <xsl:variable name="lowercase">
  430. <xsl:call-template name="gentext">
  431. <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
  432. </xsl:call-template>
  433. </xsl:variable>
  434. <xsl:variable name="uppercase">
  435. <xsl:call-template name="gentext">
  436. <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
  437. </xsl:call-template>
  438. </xsl:variable>
  439. <div>
  440. <xsl:apply-templates select="." mode="class.attribute"/>
  441. <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
  442. <dl>
  443. <xsl:choose>
  444. <xsl:when test="$glossary.sort != 0">
  445. <xsl:for-each select="glossentry">
  446. <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
  447. <xsl:variable name="cterm" select="glossterm"/>
  448. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  449. <xsl:apply-templates select="." mode="auto-glossary"/>
  450. </xsl:if>
  451. </xsl:for-each>
  452. </xsl:when>
  453. <xsl:otherwise>
  454. <xsl:for-each select="glossentry">
  455. <xsl:variable name="cterm" select="glossterm"/>
  456. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  457. <xsl:apply-templates select="." mode="auto-glossary"/>
  458. </xsl:if>
  459. </xsl:for-each>
  460. </xsl:otherwise>
  461. </xsl:choose>
  462. </dl>
  463. </div>
  464. </xsl:template>
  465. <!-- ==================================================================== -->
  466. </xsl:stylesheet>