glossary.xsl 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <?xml version='1.0'?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY % common.entities SYSTEM "../common/entities.ent">
  4. %common.entities;
  5. ]>
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. xmlns:xlink='http://www.w3.org/1999/xlink'
  9. exclude-result-prefixes="xlink"
  10. version='1.0'>
  11. <!-- ********************************************************************
  12. $Id: glossary.xsl 8591 2010-02-27 20:42:27Z bobstayton $
  13. ********************************************************************
  14. This file is part of the XSL DocBook Stylesheet distribution.
  15. See ../README or http://docbook.sf.net/release/xsl/current/ for
  16. copyright and other information.
  17. ******************************************************************** -->
  18. <!-- ==================================================================== -->
  19. <xsl:template match="glossary">
  20. <xsl:call-template name="make-glossary"/>
  21. </xsl:template>
  22. <xsl:template match="glossdiv/title"/>
  23. <xsl:template match="glossdiv/subtitle"/>
  24. <xsl:template match="glossdiv/titleabbrev"/>
  25. <!-- ==================================================================== -->
  26. <xsl:template name="make-glossary">
  27. <xsl:param name="divs" select="glossdiv"/>
  28. <xsl:param name="entries" select="glossentry"/>
  29. <xsl:param name="preamble" select="*[not(self::title
  30. or self::subtitle
  31. or self::glossdiv
  32. or self::glossentry)]"/>
  33. &setup-language-variable;
  34. <xsl:variable name="id">
  35. <xsl:call-template name="object.id"/>
  36. </xsl:variable>
  37. <xsl:variable name="presentation">
  38. <xsl:call-template name="pi.dbfo_glossary-presentation"/>
  39. </xsl:variable>
  40. <xsl:variable name="term-width">
  41. <xsl:call-template name="pi.dbfo_glossterm-width"/>
  42. </xsl:variable>
  43. <xsl:variable name="width">
  44. <xsl:choose>
  45. <xsl:when test="$term-width = ''">
  46. <xsl:value-of select="$glossterm.width"/>
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <xsl:value-of select="$term-width"/>
  50. </xsl:otherwise>
  51. </xsl:choose>
  52. </xsl:variable>
  53. <fo:block id="{$id}">
  54. <xsl:call-template name="glossary.titlepage"/>
  55. </fo:block>
  56. <xsl:if test="$preamble">
  57. <xsl:apply-templates select="$preamble"/>
  58. </xsl:if>
  59. <xsl:choose>
  60. <xsl:when test="$presentation = 'list'">
  61. <xsl:apply-templates select="$divs" mode="glossary.as.list">
  62. <xsl:with-param name="width" select="$width"/>
  63. </xsl:apply-templates>
  64. <xsl:if test="$entries">
  65. <fo:list-block provisional-distance-between-starts="{$width}"
  66. provisional-label-separation="{$glossterm.separation}"
  67. xsl:use-attribute-sets="normal.para.spacing">
  68. <xsl:choose>
  69. <xsl:when test="$glossary.sort != 0">
  70. <xsl:apply-templates select="$entries" mode="glossary.as.list">
  71. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  72. </xsl:apply-templates>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </fo:list-block>
  79. </xsl:if>
  80. </xsl:when>
  81. <xsl:when test="$presentation = 'blocks'">
  82. <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
  83. <xsl:choose>
  84. <xsl:when test="$glossary.sort != 0">
  85. <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
  86. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  87. </xsl:apply-templates>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:when>
  94. <xsl:when test="$glossary.as.blocks != 0">
  95. <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
  96. <xsl:choose>
  97. <xsl:when test="$glossary.sort != 0">
  98. <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
  99. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  100. </xsl:apply-templates>
  101. </xsl:when>
  102. <xsl:otherwise>
  103. <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. </xsl:when>
  107. <xsl:otherwise>
  108. <xsl:apply-templates select="$divs" mode="glossary.as.list">
  109. <xsl:with-param name="width" select="$width"/>
  110. </xsl:apply-templates>
  111. <xsl:if test="$entries">
  112. <fo:list-block provisional-distance-between-starts="{$width}"
  113. provisional-label-separation="{$glossterm.separation}"
  114. xsl:use-attribute-sets="normal.para.spacing">
  115. <xsl:choose>
  116. <xsl:when test="$glossary.sort != 0">
  117. <xsl:apply-templates select="$entries" mode="glossary.as.list">
  118. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  119. </xsl:apply-templates>
  120. </xsl:when>
  121. <xsl:otherwise>
  122. <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
  123. </xsl:otherwise>
  124. </xsl:choose>
  125. </fo:list-block>
  126. </xsl:if>
  127. </xsl:otherwise>
  128. </xsl:choose>
  129. </xsl:template>
  130. <xsl:template match="book/glossary|part/glossary|/glossary" priority="2">
  131. <xsl:variable name="id">
  132. <xsl:call-template name="object.id"/>
  133. </xsl:variable>
  134. <xsl:variable name="master-reference">
  135. <xsl:call-template name="select.pagemaster"/>
  136. </xsl:variable>
  137. <fo:page-sequence hyphenate="{$hyphenate}"
  138. master-reference="{$master-reference}">
  139. <xsl:attribute name="language">
  140. <xsl:call-template name="l10n.language"/>
  141. </xsl:attribute>
  142. <xsl:attribute name="format">
  143. <xsl:call-template name="page.number.format">
  144. <xsl:with-param name="master-reference" select="$master-reference"/>
  145. </xsl:call-template>
  146. </xsl:attribute>
  147. <xsl:attribute name="initial-page-number">
  148. <xsl:call-template name="initial.page.number">
  149. <xsl:with-param name="master-reference" select="$master-reference"/>
  150. </xsl:call-template>
  151. </xsl:attribute>
  152. <xsl:attribute name="force-page-count">
  153. <xsl:call-template name="force.page.count">
  154. <xsl:with-param name="master-reference" select="$master-reference"/>
  155. </xsl:call-template>
  156. </xsl:attribute>
  157. <xsl:attribute name="hyphenation-character">
  158. <xsl:call-template name="gentext">
  159. <xsl:with-param name="key" select="'hyphenation-character'"/>
  160. </xsl:call-template>
  161. </xsl:attribute>
  162. <xsl:attribute name="hyphenation-push-character-count">
  163. <xsl:call-template name="gentext">
  164. <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
  165. </xsl:call-template>
  166. </xsl:attribute>
  167. <xsl:attribute name="hyphenation-remain-character-count">
  168. <xsl:call-template name="gentext">
  169. <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
  170. </xsl:call-template>
  171. </xsl:attribute>
  172. <xsl:apply-templates select="." mode="running.head.mode">
  173. <xsl:with-param name="master-reference" select="$master-reference"/>
  174. </xsl:apply-templates>
  175. <xsl:apply-templates select="." mode="running.foot.mode">
  176. <xsl:with-param name="master-reference" select="$master-reference"/>
  177. </xsl:apply-templates>
  178. <fo:flow flow-name="xsl-region-body">
  179. <xsl:call-template name="set.flow.properties">
  180. <xsl:with-param name="element" select="local-name(.)"/>
  181. <xsl:with-param name="master-reference" select="$master-reference"/>
  182. </xsl:call-template>
  183. <xsl:call-template name="make-glossary"/>
  184. </fo:flow>
  185. </fo:page-sequence>
  186. </xsl:template>
  187. <xsl:template match="glossary/glossaryinfo"></xsl:template>
  188. <xsl:template match="glossary/info"></xsl:template>
  189. <xsl:template match="glossary/title"></xsl:template>
  190. <xsl:template match="glossary/subtitle"></xsl:template>
  191. <xsl:template match="glossary/titleabbrev"></xsl:template>
  192. <!-- ==================================================================== -->
  193. <xsl:template match="glosslist">
  194. &setup-language-variable;
  195. <xsl:variable name="presentation">
  196. <xsl:call-template name="pi.dbfo_glosslist-presentation"/>
  197. </xsl:variable>
  198. <xsl:variable name="term-width">
  199. <xsl:call-template name="pi.dbfo_glossterm-width"/>
  200. </xsl:variable>
  201. <xsl:variable name="width">
  202. <xsl:choose>
  203. <xsl:when test="$term-width = ''">
  204. <xsl:value-of select="$glossterm.width"/>
  205. </xsl:when>
  206. <xsl:otherwise>
  207. <xsl:value-of select="$term-width"/>
  208. </xsl:otherwise>
  209. </xsl:choose>
  210. </xsl:variable>
  211. <xsl:if test="title or info/title">
  212. <xsl:apply-templates select="(title|info/title)[1]" mode="list.title.mode"/>
  213. </xsl:if>
  214. <xsl:choose>
  215. <xsl:when test="$presentation = 'list'">
  216. <fo:list-block provisional-distance-between-starts="{$width}"
  217. provisional-label-separation="{$glossterm.separation}"
  218. xsl:use-attribute-sets="normal.para.spacing">
  219. <xsl:choose>
  220. <xsl:when test="$glossary.sort != 0">
  221. <xsl:apply-templates select="glossentry" mode="glossary.as.list">
  222. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  223. </xsl:apply-templates>
  224. </xsl:when>
  225. <xsl:otherwise>
  226. <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
  227. </xsl:otherwise>
  228. </xsl:choose>
  229. </fo:list-block>
  230. </xsl:when>
  231. <xsl:when test="$presentation = 'blocks'">
  232. <xsl:choose>
  233. <xsl:when test="$glossary.sort != 0">
  234. <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
  235. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  236. </xsl:apply-templates>
  237. </xsl:when>
  238. <xsl:otherwise>
  239. <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
  240. </xsl:otherwise>
  241. </xsl:choose>
  242. </xsl:when>
  243. <xsl:when test="$glosslist.as.blocks != 0">
  244. <xsl:choose>
  245. <xsl:when test="$glossary.sort != 0">
  246. <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
  247. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  248. </xsl:apply-templates>
  249. </xsl:when>
  250. <xsl:otherwise>
  251. <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. </xsl:when>
  255. <xsl:otherwise>
  256. <fo:list-block provisional-distance-between-starts="{$width}"
  257. provisional-label-separation="{$glossterm.separation}"
  258. xsl:use-attribute-sets="normal.para.spacing">
  259. <xsl:choose>
  260. <xsl:when test="$glossary.sort != 0">
  261. <xsl:apply-templates select="glossentry" mode="glossary.as.list">
  262. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  263. </xsl:apply-templates>
  264. </xsl:when>
  265. <xsl:otherwise>
  266. <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
  267. </xsl:otherwise>
  268. </xsl:choose>
  269. </fo:list-block>
  270. </xsl:otherwise>
  271. </xsl:choose>
  272. </xsl:template>
  273. <!-- ==================================================================== -->
  274. <!-- Glossary collection -->
  275. <xsl:template match="glossary[@role='auto']" priority="2">
  276. <xsl:variable name="collection" select="document($glossary.collection, .)"/>
  277. <xsl:if test="$glossary.collection = ''">
  278. <xsl:message>
  279. <xsl:text>Warning: processing automatic glossary </xsl:text>
  280. <xsl:text>without a glossary.collection file.</xsl:text>
  281. </xsl:message>
  282. </xsl:if>
  283. <xsl:if test="not($collection) and $glossary.collection != ''">
  284. <xsl:message>
  285. <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
  286. <xsl:text>open glossary.collection file '</xsl:text>
  287. <xsl:value-of select="$glossary.collection"/>
  288. <xsl:text>'</xsl:text>
  289. </xsl:message>
  290. </xsl:if>
  291. <xsl:call-template name="make-auto-glossary"/>
  292. </xsl:template>
  293. <xsl:template name="make-auto-glossary">
  294. <xsl:param name="collection" select="document($glossary.collection, .)"/>
  295. <xsl:param name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
  296. <xsl:param name="preamble" select="*[not(self::title
  297. or self::subtitle
  298. or self::glossdiv
  299. or self::glossentry)]"/>
  300. &setup-language-variable;
  301. <xsl:variable name="id">
  302. <xsl:call-template name="object.id"/>
  303. </xsl:variable>
  304. <xsl:variable name="presentation">
  305. <xsl:call-template name="pi.dbfo_glossary-presentation"/>
  306. </xsl:variable>
  307. <xsl:variable name="term-width">
  308. <xsl:call-template name="pi.dbfo_glossterm-width"/>
  309. </xsl:variable>
  310. <xsl:variable name="width">
  311. <xsl:choose>
  312. <xsl:when test="$term-width = ''">
  313. <xsl:value-of select="$glossterm.width"/>
  314. </xsl:when>
  315. <xsl:otherwise>
  316. <xsl:value-of select="$term-width"/>
  317. </xsl:otherwise>
  318. </xsl:choose>
  319. </xsl:variable>
  320. <xsl:if test="$glossary.collection = ''">
  321. <xsl:message>
  322. <xsl:text>Warning: processing automatic glossary </xsl:text>
  323. <xsl:text>without a glossary.collection file.</xsl:text>
  324. </xsl:message>
  325. </xsl:if>
  326. <fo:block id="{$id}">
  327. <xsl:call-template name="glossary.titlepage"/>
  328. </fo:block>
  329. <xsl:if test="$preamble">
  330. <xsl:apply-templates select="$preamble"/>
  331. </xsl:if>
  332. <xsl:choose>
  333. <xsl:when test="glossdiv and $collection//glossdiv">
  334. <xsl:for-each select="$collection//glossdiv">
  335. <!-- first see if there are any in this div -->
  336. <xsl:variable name="exist.test">
  337. <xsl:for-each select="glossentry">
  338. <xsl:variable name="cterm" select="glossterm"/>
  339. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  340. <xsl:value-of select="glossterm"/>
  341. </xsl:if>
  342. </xsl:for-each>
  343. </xsl:variable>
  344. <xsl:if test="$exist.test != ''">
  345. <xsl:choose>
  346. <xsl:when test="$presentation = 'list'">
  347. <xsl:apply-templates select="." mode="auto-glossary-as-list">
  348. <xsl:with-param name="width" select="$width"/>
  349. <xsl:with-param name="terms" select="$terms"/>
  350. </xsl:apply-templates>
  351. </xsl:when>
  352. <xsl:when test="$presentation = 'blocks'">
  353. <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
  354. <xsl:with-param name="terms" select="$terms"/>
  355. </xsl:apply-templates>
  356. </xsl:when>
  357. <xsl:when test="$glossary.as.blocks != 0">
  358. <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
  359. <xsl:with-param name="terms" select="$terms"/>
  360. </xsl:apply-templates>
  361. </xsl:when>
  362. <xsl:otherwise>
  363. <xsl:apply-templates select="." mode="auto-glossary-as-list">
  364. <xsl:with-param name="width" select="$width"/>
  365. <xsl:with-param name="terms" select="$terms"/>
  366. </xsl:apply-templates>
  367. </xsl:otherwise>
  368. </xsl:choose>
  369. </xsl:if>
  370. </xsl:for-each>
  371. </xsl:when>
  372. <xsl:otherwise>
  373. <xsl:choose>
  374. <xsl:when test="$presentation = 'list'">
  375. <fo:list-block provisional-distance-between-starts="{$width}"
  376. provisional-label-separation="{$glossterm.separation}"
  377. xsl:use-attribute-sets="normal.para.spacing">
  378. <xsl:choose>
  379. <xsl:when test="$glossary.sort != 0">
  380. <xsl:for-each select="$collection//glossentry">
  381. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  382. <xsl:variable name="cterm" select="glossterm"/>
  383. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  384. <xsl:apply-templates select="."
  385. mode="auto-glossary-as-list"/>
  386. </xsl:if>
  387. </xsl:for-each>
  388. </xsl:when>
  389. <xsl:otherwise>
  390. <xsl:for-each select="$collection//glossentry">
  391. <xsl:variable name="cterm" select="glossterm"/>
  392. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  393. <xsl:apply-templates select="."
  394. mode="auto-glossary-as-list"/>
  395. </xsl:if>
  396. </xsl:for-each>
  397. </xsl:otherwise>
  398. </xsl:choose>
  399. </fo:list-block>
  400. </xsl:when>
  401. <xsl:when test="$presentation = 'blocks' or
  402. $glossary.as.blocks != 0">
  403. <xsl:choose>
  404. <xsl:when test="$glossary.sort != 0">
  405. <xsl:for-each select="$collection//glossentry">
  406. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  407. <xsl:variable name="cterm" select="glossterm"/>
  408. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  409. <xsl:apply-templates select="."
  410. mode="auto-glossary-as-blocks"/>
  411. </xsl:if>
  412. </xsl:for-each>
  413. </xsl:when>
  414. <xsl:otherwise>
  415. <xsl:for-each select="$collection//glossentry">
  416. <xsl:variable name="cterm" select="glossterm"/>
  417. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  418. <xsl:apply-templates select="."
  419. mode="auto-glossary-as-blocks"/>
  420. </xsl:if>
  421. </xsl:for-each>
  422. </xsl:otherwise>
  423. </xsl:choose>
  424. </xsl:when>
  425. <xsl:otherwise>
  426. <fo:list-block provisional-distance-between-starts="{$width}"
  427. provisional-label-separation="{$glossterm.separation}"
  428. xsl:use-attribute-sets="normal.para.spacing">
  429. <xsl:choose>
  430. <xsl:when test="$glossary.sort != 0">
  431. <xsl:for-each select="$collection//glossentry">
  432. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  433. <xsl:variable name="cterm" select="glossterm"/>
  434. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  435. <xsl:apply-templates select="."
  436. mode="auto-glossary-as-list"/>
  437. </xsl:if>
  438. </xsl:for-each>
  439. </xsl:when>
  440. <xsl:otherwise>
  441. <xsl:for-each select="$collection//glossentry">
  442. <xsl:variable name="cterm" select="glossterm"/>
  443. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  444. <xsl:apply-templates select="."
  445. mode="auto-glossary-as-list"/>
  446. </xsl:if>
  447. </xsl:for-each>
  448. </xsl:otherwise>
  449. </xsl:choose>
  450. </fo:list-block>
  451. </xsl:otherwise>
  452. </xsl:choose>
  453. </xsl:otherwise>
  454. </xsl:choose>
  455. </xsl:template>
  456. <xsl:template match="book/glossary[@role='auto']|
  457. part/glossary[@role='auto']|
  458. /glossary[@role='auto']" priority="2.5">
  459. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  460. <xsl:variable name="master-reference">
  461. <xsl:call-template name="select.pagemaster"/>
  462. </xsl:variable>
  463. <xsl:if test="$glossary.collection = ''">
  464. <xsl:message>
  465. <xsl:text>Warning: processing automatic glossary </xsl:text>
  466. <xsl:text>without a glossary.collection file.</xsl:text>
  467. </xsl:message>
  468. </xsl:if>
  469. <fo:page-sequence hyphenate="{$hyphenate}"
  470. master-reference="{$master-reference}">
  471. <xsl:attribute name="language">
  472. <xsl:call-template name="l10n.language"/>
  473. </xsl:attribute>
  474. <xsl:attribute name="format">
  475. <xsl:call-template name="page.number.format">
  476. <xsl:with-param name="master-reference" select="$master-reference"/>
  477. </xsl:call-template>
  478. </xsl:attribute>
  479. <xsl:attribute name="initial-page-number">
  480. <xsl:call-template name="initial.page.number">
  481. <xsl:with-param name="master-reference" select="$master-reference"/>
  482. </xsl:call-template>
  483. </xsl:attribute>
  484. <xsl:attribute name="force-page-count">
  485. <xsl:call-template name="force.page.count">
  486. <xsl:with-param name="master-reference" select="$master-reference"/>
  487. </xsl:call-template>
  488. </xsl:attribute>
  489. <xsl:attribute name="hyphenation-character">
  490. <xsl:call-template name="gentext">
  491. <xsl:with-param name="key" select="'hyphenation-character'"/>
  492. </xsl:call-template>
  493. </xsl:attribute>
  494. <xsl:attribute name="hyphenation-push-character-count">
  495. <xsl:call-template name="gentext">
  496. <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
  497. </xsl:call-template>
  498. </xsl:attribute>
  499. <xsl:attribute name="hyphenation-remain-character-count">
  500. <xsl:call-template name="gentext">
  501. <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
  502. </xsl:call-template>
  503. </xsl:attribute>
  504. <xsl:apply-templates select="." mode="running.head.mode">
  505. <xsl:with-param name="master-reference" select="$master-reference"/>
  506. </xsl:apply-templates>
  507. <xsl:apply-templates select="." mode="running.foot.mode">
  508. <xsl:with-param name="master-reference" select="$master-reference"/>
  509. </xsl:apply-templates>
  510. <fo:flow flow-name="xsl-region-body">
  511. <xsl:call-template name="set.flow.properties">
  512. <xsl:with-param name="element" select="local-name(.)"/>
  513. <xsl:with-param name="master-reference" select="$master-reference"/>
  514. </xsl:call-template>
  515. <xsl:call-template name="make-auto-glossary"/>
  516. </fo:flow>
  517. </fo:page-sequence>
  518. </xsl:template>
  519. <xsl:template match="glossdiv" mode="auto-glossary-as-list">
  520. <xsl:param name="width" select="$glossterm.width"/>
  521. <xsl:param name="terms" select="."/>
  522. &setup-language-variable;
  523. <xsl:variable name="id">
  524. <xsl:call-template name="object.id"/>
  525. </xsl:variable>
  526. <xsl:variable name="preamble"
  527. select="*[not(self::title
  528. or self::subtitle
  529. or self::glossentry)]"/>
  530. <fo:block id="{$id}">
  531. <xsl:call-template name="glossdiv.titlepage"/>
  532. </fo:block>
  533. <xsl:apply-templates select="$preamble"/>
  534. <fo:list-block provisional-distance-between-starts="{$width}"
  535. provisional-label-separation="{$glossterm.separation}"
  536. xsl:use-attribute-sets="normal.para.spacing">
  537. <xsl:choose>
  538. <xsl:when test="$glossary.sort != 0">
  539. <xsl:for-each select="glossentry">
  540. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  541. <xsl:variable name="cterm" select="glossterm"/>
  542. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  543. <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
  544. </xsl:if>
  545. </xsl:for-each>
  546. </xsl:when>
  547. <xsl:otherwise>
  548. <xsl:for-each select="glossentry">
  549. <xsl:variable name="cterm" select="glossterm"/>
  550. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  551. <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
  552. </xsl:if>
  553. </xsl:for-each>
  554. </xsl:otherwise>
  555. </xsl:choose>
  556. </fo:list-block>
  557. </xsl:template>
  558. <xsl:template match="glossentry" mode="auto-glossary-as-list">
  559. <xsl:apply-templates select="." mode="glossary.as.list"/>
  560. </xsl:template>
  561. <xsl:template match="glossdiv" mode="auto-glossary-as-blocks">
  562. <xsl:param name="terms" select="."/>
  563. &setup-language-variable;
  564. <xsl:variable name="id">
  565. <xsl:call-template name="object.id"/>
  566. </xsl:variable>
  567. <xsl:variable name="preamble"
  568. select="*[not(self::title
  569. or self::subtitle
  570. or self::glossentry)]"/>
  571. <fo:block id="{$id}">
  572. <xsl:call-template name="glossdiv.titlepage"/>
  573. </fo:block>
  574. <xsl:apply-templates select="$preamble"/>
  575. <xsl:choose>
  576. <xsl:when test="$glossary.sort != 0">
  577. <xsl:for-each select="glossentry">
  578. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  579. <xsl:variable name="cterm" select="glossterm"/>
  580. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  581. <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
  582. </xsl:if>
  583. </xsl:for-each>
  584. </xsl:when>
  585. <xsl:otherwise>
  586. <xsl:for-each select="glossentry">
  587. <xsl:variable name="cterm" select="glossterm"/>
  588. <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
  589. <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
  590. </xsl:if>
  591. </xsl:for-each>
  592. </xsl:otherwise>
  593. </xsl:choose>
  594. </xsl:template>
  595. <xsl:template match="glossentry" mode="auto-glossary-as-blocks">
  596. <xsl:apply-templates select="." mode="glossary.as.blocks"/>
  597. </xsl:template>
  598. <!-- ==================================================================== -->
  599. <!-- Format glossary as a list -->
  600. <xsl:template match="glossdiv" mode="glossary.as.list">
  601. <xsl:param name="width" select="$glossterm.width"/>
  602. &setup-language-variable;
  603. <xsl:variable name="id">
  604. <xsl:call-template name="object.id"/>
  605. </xsl:variable>
  606. <xsl:variable name="entries" select="glossentry"/>
  607. <xsl:variable name="preamble"
  608. select="*[not(self::title
  609. or self::subtitle
  610. or self::glossentry)]"/>
  611. <fo:block id="{$id}">
  612. <xsl:call-template name="glossdiv.titlepage"/>
  613. </fo:block>
  614. <xsl:apply-templates select="$preamble"/>
  615. <fo:list-block provisional-distance-between-starts="{$width}"
  616. provisional-label-separation="{$glossterm.separation}"
  617. xsl:use-attribute-sets="normal.para.spacing">
  618. <xsl:choose>
  619. <xsl:when test="$glossary.sort != 0">
  620. <xsl:apply-templates select="$entries" mode="glossary.as.list">
  621. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  622. </xsl:apply-templates>
  623. </xsl:when>
  624. <xsl:otherwise>
  625. <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
  626. </xsl:otherwise>
  627. </xsl:choose>
  628. </fo:list-block>
  629. </xsl:template>
  630. <!--
  631. GlossEntry ::=
  632. GlossTerm, Acronym?, Abbrev?,
  633. (IndexTerm)*,
  634. RevHistory?,
  635. (GlossSee | GlossDef+)
  636. -->
  637. <xsl:template match="glossentry" mode="glossary.as.list">
  638. <xsl:variable name="id">
  639. <xsl:call-template name="object.id"/>
  640. </xsl:variable>
  641. <fo:list-item xsl:use-attribute-sets="glossentry.list.item.properties">
  642. <xsl:call-template name="anchor">
  643. <xsl:with-param name="conditional">
  644. <xsl:choose>
  645. <xsl:when test="$glossterm.auto.link != 0
  646. or $glossary.collection != ''">0</xsl:when>
  647. <xsl:otherwise>1</xsl:otherwise>
  648. </xsl:choose>
  649. </xsl:with-param>
  650. </xsl:call-template>
  651. <fo:list-item-label end-indent="label-end()">
  652. <fo:block xsl:use-attribute-sets="glossterm.list.properties">
  653. <xsl:choose>
  654. <xsl:when test="$glossentry.show.acronym = 'primary'">
  655. <xsl:choose>
  656. <xsl:when test="acronym|abbrev">
  657. <xsl:apply-templates select="acronym|abbrev"
  658. mode="glossary.as.list"/>
  659. <xsl:text> (</xsl:text>
  660. <xsl:apply-templates select="glossterm"
  661. mode="glossary.as.list"/>
  662. <xsl:text>)</xsl:text>
  663. </xsl:when>
  664. <xsl:otherwise>
  665. <xsl:apply-templates select="glossterm"
  666. mode="glossary.as.list"/>
  667. </xsl:otherwise>
  668. </xsl:choose>
  669. </xsl:when>
  670. <xsl:when test="$glossentry.show.acronym = 'yes'">
  671. <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
  672. <xsl:if test="acronym|abbrev">
  673. <xsl:text> (</xsl:text>
  674. <xsl:apply-templates select="acronym|abbrev"
  675. mode="glossary.as.list"/>
  676. <xsl:text>)</xsl:text>
  677. </xsl:if>
  678. </xsl:when>
  679. <xsl:otherwise>
  680. <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
  681. </xsl:otherwise>
  682. </xsl:choose>
  683. <xsl:apply-templates select="indexterm"/>
  684. </fo:block>
  685. </fo:list-item-label>
  686. <fo:list-item-body start-indent="body-start()">
  687. <fo:block xsl:use-attribute-sets="glossdef.list.properties">
  688. <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.list"/>
  689. </fo:block>
  690. </fo:list-item-body>
  691. </fo:list-item>
  692. </xsl:template>
  693. <xsl:template match="glossentry/glossterm" mode="glossary.as.list">
  694. <xsl:variable name="id">
  695. <xsl:call-template name="object.id"/>
  696. </xsl:variable>
  697. <fo:inline id="{$id}">
  698. <xsl:apply-templates/>
  699. </fo:inline>
  700. <xsl:if test="following-sibling::glossterm">, </xsl:if>
  701. </xsl:template>
  702. <xsl:template match="glossentry/acronym" mode="glossary.as.list">
  703. <xsl:apply-templates/>
  704. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  705. </xsl:template>
  706. <xsl:template match="glossentry/abbrev" mode="glossary.as.list">
  707. <xsl:apply-templates/>
  708. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  709. </xsl:template>
  710. <xsl:template match="glossentry/revhistory" mode="glossary.as.list">
  711. </xsl:template>
  712. <xsl:template match="glossentry/glosssee" mode="glossary.as.list">
  713. <xsl:variable name="otherterm" select="@otherterm"/>
  714. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  715. <xsl:variable name="target" select="$targets[1]"/>
  716. <xsl:variable name="xlink" select="@xlink:href"/>
  717. <fo:block>
  718. <xsl:variable name="template">
  719. <xsl:call-template name="gentext.template">
  720. <xsl:with-param name="context" select="'glossary'"/>
  721. <xsl:with-param name="name" select="'see'"/>
  722. </xsl:call-template>
  723. </xsl:variable>
  724. <xsl:variable name="title">
  725. <xsl:choose>
  726. <xsl:when test="$target">
  727. <fo:basic-link internal-destination="{$otherterm}"
  728. xsl:use-attribute-sets="xref.properties">
  729. <xsl:apply-templates select="$target" mode="xref-to"/>
  730. </fo:basic-link>
  731. </xsl:when>
  732. <xsl:when test="$xlink">
  733. <xsl:call-template name="simple.xlink">
  734. <xsl:with-param name="content">
  735. <xsl:apply-templates/>
  736. </xsl:with-param>
  737. </xsl:call-template>
  738. </xsl:when>
  739. <xsl:when test="$otherterm != '' and not($target)">
  740. <xsl:message>
  741. <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
  742. <xsl:value-of select="$otherterm"/>
  743. </xsl:message>
  744. <xsl:apply-templates mode="glossary.as.list"/>
  745. </xsl:when>
  746. <xsl:otherwise>
  747. <xsl:apply-templates mode="glossary.as.list"/>
  748. </xsl:otherwise>
  749. </xsl:choose>
  750. </xsl:variable>
  751. <xsl:call-template name="substitute-markup">
  752. <xsl:with-param name="template" select="$template"/>
  753. <xsl:with-param name="title" select="$title"/>
  754. </xsl:call-template>
  755. </fo:block>
  756. </xsl:template>
  757. <xsl:template match="glossentry/glossdef" mode="glossary.as.list">
  758. <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
  759. <xsl:if test="glossseealso">
  760. <fo:block>
  761. <xsl:variable name="template">
  762. <xsl:call-template name="gentext.template">
  763. <xsl:with-param name="context" select="'glossary'"/>
  764. <xsl:with-param name="name" select="'seealso'"/>
  765. </xsl:call-template>
  766. </xsl:variable>
  767. <xsl:variable name="title">
  768. <xsl:apply-templates select="glossseealso" mode="glossary.as.list"/>
  769. </xsl:variable>
  770. <xsl:call-template name="substitute-markup">
  771. <xsl:with-param name="template" select="$template"/>
  772. <xsl:with-param name="title" select="$title"/>
  773. </xsl:call-template>
  774. </fo:block>
  775. </xsl:if>
  776. </xsl:template>
  777. <xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
  778. mode="glossary.as.list">
  779. <fo:block>
  780. <xsl:apply-templates/>
  781. </fo:block>
  782. </xsl:template>
  783. <xsl:template match="glossseealso" mode="glossary.as.list">
  784. <xsl:variable name="otherterm" select="@otherterm"/>
  785. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  786. <xsl:variable name="target" select="$targets[1]"/>
  787. <xsl:variable name="xlink" select="@xlink:href"/>
  788. <xsl:choose>
  789. <xsl:when test="$target">
  790. <fo:basic-link internal-destination="{$otherterm}"
  791. xsl:use-attribute-sets="xref.properties">
  792. <xsl:apply-templates select="$target" mode="xref-to"/>
  793. </fo:basic-link>
  794. </xsl:when>
  795. <xsl:when test="$xlink">
  796. <xsl:call-template name="simple.xlink">
  797. <xsl:with-param name="content">
  798. <xsl:apply-templates/>
  799. </xsl:with-param>
  800. </xsl:call-template>
  801. </xsl:when>
  802. <xsl:when test="$otherterm != '' and not($target)">
  803. <xsl:message>
  804. <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
  805. <xsl:value-of select="$otherterm"/>
  806. </xsl:message>
  807. <xsl:apply-templates mode="glossary.as.list"/>
  808. </xsl:when>
  809. <xsl:otherwise>
  810. <xsl:apply-templates mode="glossary.as.list"/>
  811. </xsl:otherwise>
  812. </xsl:choose>
  813. <xsl:choose>
  814. <xsl:when test="position() = last()"/>
  815. <xsl:otherwise>
  816. <xsl:call-template name="gentext.template">
  817. <xsl:with-param name="context" select="'glossary'"/>
  818. <xsl:with-param name="name" select="'seealso-separator'"/>
  819. </xsl:call-template>
  820. </xsl:otherwise>
  821. </xsl:choose>
  822. </xsl:template>
  823. <!-- ==================================================================== -->
  824. <!-- Format glossary blocks -->
  825. <xsl:template match="glossdiv" mode="glossary.as.blocks">
  826. &setup-language-variable;
  827. <xsl:variable name="id">
  828. <xsl:call-template name="object.id"/>
  829. </xsl:variable>
  830. <xsl:variable name="entries" select="glossentry"/>
  831. <xsl:variable name="preamble"
  832. select="*[not(self::title
  833. or self::subtitle
  834. or self::glossentry)]"/>
  835. <fo:block id="{$id}">
  836. <xsl:call-template name="glossdiv.titlepage"/>
  837. </fo:block>
  838. <xsl:apply-templates select="$preamble"/>
  839. <xsl:choose>
  840. <xsl:when test="$glossary.sort != 0">
  841. <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
  842. <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
  843. </xsl:apply-templates>
  844. </xsl:when>
  845. <xsl:otherwise>
  846. <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
  847. </xsl:otherwise>
  848. </xsl:choose>
  849. </xsl:template>
  850. <!--
  851. GlossEntry ::=
  852. GlossTerm, Acronym?, Abbrev?,
  853. (IndexTerm)*,
  854. RevHistory?,
  855. (GlossSee | GlossDef+)
  856. -->
  857. <xsl:template match="glossentry" mode="glossary.as.blocks">
  858. <xsl:variable name="id">
  859. <xsl:call-template name="object.id"/>
  860. </xsl:variable>
  861. <fo:block xsl:use-attribute-sets="glossterm.block.properties">
  862. <xsl:call-template name="anchor">
  863. <xsl:with-param name="conditional">
  864. <xsl:choose>
  865. <xsl:when test="$glossterm.auto.link != 0
  866. or $glossary.collection != ''">0</xsl:when>
  867. <xsl:otherwise>1</xsl:otherwise>
  868. </xsl:choose>
  869. </xsl:with-param>
  870. </xsl:call-template>
  871. <xsl:choose>
  872. <xsl:when test="$glossentry.show.acronym = 'primary'">
  873. <xsl:choose>
  874. <xsl:when test="acronym|abbrev">
  875. <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
  876. <xsl:text> (</xsl:text>
  877. <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
  878. <xsl:text>)</xsl:text>
  879. </xsl:when>
  880. <xsl:otherwise>
  881. <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
  882. </xsl:otherwise>
  883. </xsl:choose>
  884. </xsl:when>
  885. <xsl:when test="$glossentry.show.acronym = 'yes'">
  886. <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
  887. <xsl:if test="acronym|abbrev">
  888. <xsl:text> (</xsl:text>
  889. <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
  890. <xsl:text>)</xsl:text>
  891. </xsl:if>
  892. </xsl:when>
  893. <xsl:otherwise>
  894. <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
  895. </xsl:otherwise>
  896. </xsl:choose>
  897. <xsl:apply-templates select="indexterm"/>
  898. </fo:block>
  899. <fo:block xsl:use-attribute-sets="glossdef.block.properties">
  900. <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.blocks"/>
  901. </fo:block>
  902. </xsl:template>
  903. <xsl:template match="glossentry/glossterm" mode="glossary.as.blocks">
  904. <xsl:variable name="id">
  905. <xsl:call-template name="object.id"/>
  906. </xsl:variable>
  907. <fo:inline id="{$id}">
  908. <xsl:apply-templates/>
  909. </fo:inline>
  910. <xsl:if test="following-sibling::glossterm">, </xsl:if>
  911. </xsl:template>
  912. <xsl:template match="glossentry/acronym" mode="glossary.as.blocks">
  913. <xsl:apply-templates/>
  914. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  915. </xsl:template>
  916. <xsl:template match="glossentry/abbrev" mode="glossary.as.blocks">
  917. <xsl:apply-templates/>
  918. <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
  919. </xsl:template>
  920. <xsl:template match="glossentry/glosssee" mode="glossary.as.blocks">
  921. <xsl:variable name="otherterm" select="@otherterm"/>
  922. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  923. <xsl:variable name="target" select="$targets[1]"/>
  924. <xsl:variable name="xlink" select="@xlink:href"/>
  925. <xsl:variable name="template">
  926. <xsl:call-template name="gentext.template">
  927. <xsl:with-param name="context" select="'glossary'"/>
  928. <xsl:with-param name="name" select="'see'"/>
  929. </xsl:call-template>
  930. </xsl:variable>
  931. <xsl:variable name="title">
  932. <xsl:choose>
  933. <xsl:when test="$target">
  934. <fo:basic-link internal-destination="{$otherterm}"
  935. xsl:use-attribute-sets="xref.properties">
  936. <xsl:apply-templates select="$target" mode="xref-to"/>
  937. </fo:basic-link>
  938. </xsl:when>
  939. <xsl:when test="$xlink">
  940. <xsl:call-template name="simple.xlink">
  941. <xsl:with-param name="content">
  942. <xsl:apply-templates/>
  943. </xsl:with-param>
  944. </xsl:call-template>
  945. </xsl:when>
  946. <xsl:when test="$otherterm != '' and not($target)">
  947. <xsl:message>
  948. <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
  949. <xsl:value-of select="$otherterm"/>
  950. </xsl:message>
  951. <xsl:apply-templates mode="glossary.as.blocks"/>
  952. </xsl:when>
  953. <xsl:otherwise>
  954. <xsl:apply-templates mode="glossary.as.blocks"/>
  955. </xsl:otherwise>
  956. </xsl:choose>
  957. </xsl:variable>
  958. <xsl:call-template name="substitute-markup">
  959. <xsl:with-param name="template" select="$template"/>
  960. <xsl:with-param name="title" select="$title"/>
  961. </xsl:call-template>
  962. </xsl:template>
  963. <xsl:template match="glossentry/glossdef" mode="glossary.as.blocks">
  964. <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"
  965. mode="glossary.as.blocks"/>
  966. <xsl:if test="glossseealso">
  967. <fo:block>
  968. <xsl:variable name="template">
  969. <xsl:call-template name="gentext.template">
  970. <xsl:with-param name="context" select="'glossary'"/>
  971. <xsl:with-param name="name" select="'seealso'"/>
  972. </xsl:call-template>
  973. </xsl:variable>
  974. <xsl:variable name="title">
  975. <xsl:apply-templates select="glossseealso" mode="glossary.as.blocks"/>
  976. </xsl:variable>
  977. <xsl:call-template name="substitute-markup">
  978. <xsl:with-param name="template" select="$template"/>
  979. <xsl:with-param name="title" select="$title"/>
  980. </xsl:call-template>
  981. </fo:block>
  982. </xsl:if>
  983. </xsl:template>
  984. <xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
  985. mode="glossary.as.blocks">
  986. <fo:block>
  987. <xsl:apply-templates/>
  988. </fo:block>
  989. </xsl:template>
  990. <!-- Handle any other glossdef content normally -->
  991. <xsl:template match="*" mode="glossary.as.blocks">
  992. <xsl:apply-templates select="." />
  993. </xsl:template>
  994. <xsl:template match="glossseealso" mode="glossary.as.blocks">
  995. <xsl:variable name="otherterm" select="@otherterm"/>
  996. <xsl:variable name="targets" select="key('id', $otherterm)"/>
  997. <xsl:variable name="target" select="$targets[1]"/>
  998. <xsl:variable name="xlink" select="@xlink:href"/>
  999. <xsl:choose>
  1000. <xsl:when test="$target">
  1001. <fo:basic-link internal-destination="{$otherterm}"
  1002. xsl:use-attribute-sets="xref.properties">
  1003. <xsl:apply-templates select="$target" mode="xref-to"/>
  1004. </fo:basic-link>
  1005. </xsl:when>
  1006. <xsl:when test="$xlink">
  1007. <xsl:call-template name="simple.xlink">
  1008. <xsl:with-param name="content">
  1009. <xsl:apply-templates/>
  1010. </xsl:with-param>
  1011. </xsl:call-template>
  1012. </xsl:when>
  1013. <xsl:when test="$otherterm != '' and not($target)">
  1014. <xsl:message>
  1015. <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
  1016. <xsl:value-of select="$otherterm"/>
  1017. </xsl:message>
  1018. <xsl:apply-templates mode="glossary.as.blocks"/>
  1019. </xsl:when>
  1020. <xsl:otherwise>
  1021. <xsl:apply-templates mode="glossary.as.blocks"/>
  1022. </xsl:otherwise>
  1023. </xsl:choose>
  1024. <xsl:choose>
  1025. <xsl:when test="position() = last()"/>
  1026. <xsl:otherwise>
  1027. <xsl:call-template name="gentext.template">
  1028. <xsl:with-param name="context" select="'glossary'"/>
  1029. <xsl:with-param name="name" select="'seealso-separator'"/>
  1030. </xsl:call-template>
  1031. </xsl:otherwise>
  1032. </xsl:choose>
  1033. </xsl:template>
  1034. <!-- ==================================================================== -->
  1035. </xsl:stylesheet>