glossary.xsl 42 KB

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