glossary.xsl 17 KB

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