lists.xsl 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. version='1.0'>
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  10. and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <xsl:template match="itemizedlist">
  14. <xsl:variable name="id">
  15. <xsl:call-template name="object.id"/>
  16. </xsl:variable>
  17. <xsl:variable name="pi-label-width">
  18. <xsl:call-template name="dbfo-attribute">
  19. <xsl:with-param name="pis"
  20. select="processing-instruction('dbfo')"/>
  21. <xsl:with-param name="attribute" select="'label-width'"/>
  22. </xsl:call-template>
  23. </xsl:variable>
  24. <xsl:variable name="label-width">
  25. <xsl:choose>
  26. <xsl:when test="$pi-label-width = ''">
  27. <xsl:value-of select="$itemizedlist.label.width"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:value-of select="$pi-label-width"/>
  31. </xsl:otherwise>
  32. </xsl:choose>
  33. </xsl:variable>
  34. <xsl:if test="title">
  35. <xsl:apply-templates select="title" mode="list.title.mode"/>
  36. </xsl:if>
  37. <!-- Preserve order of PIs and comments -->
  38. <xsl:apply-templates
  39. select="*[not(self::listitem
  40. or self::title
  41. or self::titleabbrev)]
  42. |comment()[not(preceding-sibling::listitem)]
  43. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  44. <xsl:variable name="content">
  45. <xsl:apply-templates
  46. select="listitem
  47. |comment()[preceding-sibling::listitem]
  48. |processing-instruction()[preceding-sibling::listitem]"/>
  49. </xsl:variable>
  50. <!-- nested lists don't add extra list-block spacing -->
  51. <xsl:choose>
  52. <xsl:when test="ancestor::listitem">
  53. <fo:list-block id="{$id}" xsl:use-attribute-sets="itemizedlist.properties">
  54. <xsl:attribute name="provisional-distance-between-starts">
  55. <xsl:value-of select="$label-width"/>
  56. </xsl:attribute>
  57. <xsl:copy-of select="$content"/>
  58. </fo:list-block>
  59. </xsl:when>
  60. <xsl:otherwise>
  61. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing itemizedlist.properties">
  62. <xsl:attribute name="provisional-distance-between-starts">
  63. <xsl:value-of select="$label-width"/>
  64. </xsl:attribute>
  65. <xsl:copy-of select="$content"/>
  66. </fo:list-block>
  67. </xsl:otherwise>
  68. </xsl:choose>
  69. </xsl:template>
  70. <xsl:template match="itemizedlist/title|orderedlist/title">
  71. <!--nop-->
  72. </xsl:template>
  73. <xsl:template match="variablelist/title" mode="vl.as.list">
  74. <!--nop-->
  75. </xsl:template>
  76. <xsl:template match="variablelist/title" mode="vl.as.blocks">
  77. <!--nop-->
  78. </xsl:template>
  79. <xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
  80. <!--nop-->
  81. </xsl:template>
  82. <xsl:template match="procedure/titleabbrev">
  83. <!--nop-->
  84. </xsl:template>
  85. <xsl:template match="variablelist/titleabbrev" mode="vl.as.list">
  86. <!--nop-->
  87. </xsl:template>
  88. <xsl:template match="variablelist/titleabbrev" mode="vl.as.blocks">
  89. <!--nop-->
  90. </xsl:template>
  91. <xsl:template match="itemizedlist/listitem">
  92. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  93. <xsl:variable name="item.contents">
  94. <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="itemizedlist.label.properties">
  95. <fo:block>
  96. <xsl:call-template name="itemizedlist.label.markup">
  97. <xsl:with-param name="itemsymbol">
  98. <xsl:call-template name="list.itemsymbol">
  99. <xsl:with-param name="node" select="parent::itemizedlist"/>
  100. </xsl:call-template>
  101. </xsl:with-param>
  102. </xsl:call-template>
  103. </fo:block>
  104. </fo:list-item-label>
  105. <fo:list-item-body start-indent="body-start()">
  106. <xsl:choose>
  107. <!-- * work around broken passivetex list-item-body rendering -->
  108. <xsl:when test="$passivetex.extensions = '1'">
  109. <xsl:apply-templates/>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <fo:block>
  113. <xsl:apply-templates/>
  114. </fo:block>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </fo:list-item-body>
  118. </xsl:variable>
  119. <xsl:choose>
  120. <xsl:when test="parent::*/@spacing = 'compact'">
  121. <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
  122. <xsl:copy-of select="$item.contents"/>
  123. </fo:list-item>
  124. </xsl:when>
  125. <xsl:otherwise>
  126. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  127. <xsl:copy-of select="$item.contents"/>
  128. </fo:list-item>
  129. </xsl:otherwise>
  130. </xsl:choose>
  131. </xsl:template>
  132. <xsl:template name="itemizedlist.label.markup">
  133. <xsl:param name="itemsymbol" select="'disc'"/>
  134. <xsl:choose>
  135. <xsl:when test="$itemsymbol='none'"></xsl:when>
  136. <xsl:when test="$itemsymbol='disc'">&#x2022;</xsl:when>
  137. <xsl:when test="$itemsymbol='bullet'">&#x2022;</xsl:when>
  138. <xsl:when test="$itemsymbol='endash'">&#x2013;</xsl:when>
  139. <xsl:when test="$itemsymbol='emdash'">&#x2014;</xsl:when>
  140. <!-- Some of these may work in your XSL-FO processor and fonts -->
  141. <!--
  142. <xsl:when test="$itemsymbol='square'">&#x25A0;</xsl:when>
  143. <xsl:when test="$itemsymbol='box'">&#x25A0;</xsl:when>
  144. <xsl:when test="$itemsymbol='smallblacksquare'">&#x25AA;</xsl:when>
  145. <xsl:when test="$itemsymbol='circle'">&#x25CB;</xsl:when>
  146. <xsl:when test="$itemsymbol='opencircle'">&#x25CB;</xsl:when>
  147. <xsl:when test="$itemsymbol='whitesquare'">&#x25A1;</xsl:when>
  148. <xsl:when test="$itemsymbol='smallwhitesquare'">&#x25AB;</xsl:when>
  149. <xsl:when test="$itemsymbol='round'">&#x25CF;</xsl:when>
  150. <xsl:when test="$itemsymbol='blackcircle'">&#x25CF;</xsl:when>
  151. <xsl:when test="$itemsymbol='whitebullet'">&#x25E6;</xsl:when>
  152. <xsl:when test="$itemsymbol='triangle'">&#x2023;</xsl:when>
  153. <xsl:when test="$itemsymbol='point'">&#x203A;</xsl:when>
  154. <xsl:when test="$itemsymbol='hand'"><fo:inline
  155. font-family="Wingdings 2">A</fo:inline></xsl:when>
  156. -->
  157. <xsl:otherwise>&#x2022;</xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:template>
  160. <xsl:template match="orderedlist">
  161. <xsl:variable name="id">
  162. <xsl:call-template name="object.id"/>
  163. </xsl:variable>
  164. <xsl:variable name="pi-label-width">
  165. <xsl:call-template name="dbfo-attribute">
  166. <xsl:with-param name="pis"
  167. select="processing-instruction('dbfo')"/>
  168. <xsl:with-param name="attribute" select="'label-width'"/>
  169. </xsl:call-template>
  170. </xsl:variable>
  171. <xsl:variable name="label-width">
  172. <xsl:choose>
  173. <xsl:when test="$pi-label-width = ''">
  174. <xsl:value-of select="$orderedlist.label.width"/>
  175. </xsl:when>
  176. <xsl:otherwise>
  177. <xsl:value-of select="$pi-label-width"/>
  178. </xsl:otherwise>
  179. </xsl:choose>
  180. </xsl:variable>
  181. <xsl:if test="title">
  182. <xsl:apply-templates select="title" mode="list.title.mode"/>
  183. </xsl:if>
  184. <!-- Preserve order of PIs and comments -->
  185. <xsl:apply-templates
  186. select="*[not(self::listitem
  187. or self::title
  188. or self::titleabbrev)]
  189. |comment()[not(preceding-sibling::listitem)]
  190. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  191. <xsl:variable name="content">
  192. <xsl:apply-templates
  193. select="listitem
  194. |comment()[preceding-sibling::listitem]
  195. |processing-instruction()[preceding-sibling::listitem]"/>
  196. </xsl:variable>
  197. <!-- nested lists don't add extra list-block spacing -->
  198. <xsl:choose>
  199. <xsl:when test="ancestor::listitem">
  200. <fo:list-block id="{$id}" xsl:use-attribute-sets="orderedlist.properties">
  201. <xsl:attribute name="provisional-distance-between-starts">
  202. <xsl:value-of select="$label-width"/>
  203. </xsl:attribute>
  204. <xsl:copy-of select="$content"/>
  205. </fo:list-block>
  206. </xsl:when>
  207. <xsl:otherwise>
  208. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing orderedlist.properties">
  209. <xsl:attribute name="provisional-distance-between-starts">
  210. <xsl:value-of select="$label-width"/>
  211. </xsl:attribute>
  212. <xsl:copy-of select="$content"/>
  213. </fo:list-block>
  214. </xsl:otherwise>
  215. </xsl:choose>
  216. </xsl:template>
  217. <xsl:template match="orderedlist/listitem" mode="item-number">
  218. <xsl:variable name="numeration">
  219. <xsl:call-template name="list.numeration">
  220. <xsl:with-param name="node" select="parent::orderedlist"/>
  221. </xsl:call-template>
  222. </xsl:variable>
  223. <xsl:variable name="type">
  224. <xsl:choose>
  225. <xsl:when test="$numeration='arabic'">1.</xsl:when>
  226. <xsl:when test="$numeration='loweralpha'">a.</xsl:when>
  227. <xsl:when test="$numeration='lowerroman'">i.</xsl:when>
  228. <xsl:when test="$numeration='upperalpha'">A.</xsl:when>
  229. <xsl:when test="$numeration='upperroman'">I.</xsl:when>
  230. <!-- What!? This should never happen -->
  231. <xsl:otherwise>
  232. <xsl:message>
  233. <xsl:text>Unexpected numeration: </xsl:text>
  234. <xsl:value-of select="$numeration"/>
  235. </xsl:message>
  236. <xsl:value-of select="1."/>
  237. </xsl:otherwise>
  238. </xsl:choose>
  239. </xsl:variable>
  240. <xsl:variable name="item-number">
  241. <xsl:call-template name="orderedlist-item-number"/>
  242. </xsl:variable>
  243. <xsl:if test="parent::orderedlist/@inheritnum='inherit'
  244. and ancestor::listitem[parent::orderedlist]">
  245. <xsl:apply-templates select="ancestor::listitem[parent::orderedlist][1]"
  246. mode="item-number"/>
  247. </xsl:if>
  248. <xsl:number value="$item-number" format="{$type}"/>
  249. </xsl:template>
  250. <xsl:template match="orderedlist/listitem">
  251. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  252. <xsl:variable name="item.contents">
  253. <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="orderedlist.label.properties">
  254. <fo:block>
  255. <xsl:apply-templates select="." mode="item-number"/>
  256. </fo:block>
  257. </fo:list-item-label>
  258. <fo:list-item-body start-indent="body-start()">
  259. <fo:block>
  260. <xsl:apply-templates/>
  261. </fo:block>
  262. </fo:list-item-body>
  263. </xsl:variable>
  264. <xsl:choose>
  265. <xsl:when test="parent::*/@spacing = 'compact'">
  266. <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
  267. <xsl:copy-of select="$item.contents"/>
  268. </fo:list-item>
  269. </xsl:when>
  270. <xsl:otherwise>
  271. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  272. <xsl:copy-of select="$item.contents"/>
  273. </fo:list-item>
  274. </xsl:otherwise>
  275. </xsl:choose>
  276. </xsl:template>
  277. <xsl:template match="listitem/*[1][local-name()='para' or
  278. local-name()='simpara' or
  279. local-name()='formalpara']
  280. |glossdef/*[1][local-name()='para' or
  281. local-name()='simpara' or
  282. local-name()='formalpara']
  283. |step/*[1][local-name()='para' or
  284. local-name()='simpara' or
  285. local-name()='formalpara']
  286. |callout/*[1][local-name()='para' or
  287. local-name()='simpara' or
  288. local-name()='formalpara']"
  289. priority="2">
  290. <fo:block>
  291. <xsl:call-template name="anchor"/>
  292. <xsl:apply-templates/>
  293. </fo:block>
  294. </xsl:template>
  295. <xsl:template match="variablelist">
  296. <xsl:variable name="presentation">
  297. <xsl:call-template name="dbfo-attribute">
  298. <xsl:with-param name="pis"
  299. select="processing-instruction('dbfo')"/>
  300. <xsl:with-param name="attribute" select="'list-presentation'"/>
  301. </xsl:call-template>
  302. </xsl:variable>
  303. <xsl:choose>
  304. <xsl:when test="$presentation = 'list'">
  305. <xsl:apply-templates select="." mode="vl.as.list"/>
  306. </xsl:when>
  307. <xsl:when test="$presentation = 'blocks'">
  308. <xsl:apply-templates select="." mode="vl.as.blocks"/>
  309. </xsl:when>
  310. <xsl:when test="$variablelist.as.blocks != 0">
  311. <xsl:apply-templates select="." mode="vl.as.blocks"/>
  312. </xsl:when>
  313. <xsl:otherwise>
  314. <xsl:apply-templates select="." mode="vl.as.list"/>
  315. </xsl:otherwise>
  316. </xsl:choose>
  317. </xsl:template>
  318. <xsl:template match="variablelist" mode="vl.as.list">
  319. <xsl:variable name="id">
  320. <xsl:call-template name="object.id"/>
  321. </xsl:variable>
  322. <xsl:variable name="term-width">
  323. <xsl:call-template name="dbfo-attribute">
  324. <xsl:with-param name="pis"
  325. select="processing-instruction('dbfo')"/>
  326. <xsl:with-param name="attribute" select="'term-width'"/>
  327. </xsl:call-template>
  328. </xsl:variable>
  329. <xsl:variable name="termlength">
  330. <xsl:choose>
  331. <xsl:when test="$term-width != ''">
  332. <xsl:value-of select="$term-width"/>
  333. </xsl:when>
  334. <xsl:when test="@termlength">
  335. <xsl:variable name="termlength.is.number">
  336. <xsl:value-of select="@termlength + 0"/>
  337. </xsl:variable>
  338. <xsl:choose>
  339. <xsl:when test="string($termlength.is.number) = 'NaN'">
  340. <!-- if the term length isn't just a number, assume it's a measurement -->
  341. <xsl:value-of select="@termlength"/>
  342. </xsl:when>
  343. <xsl:otherwise>
  344. <xsl:value-of select="@termlength"/>
  345. <xsl:choose>
  346. <!-- workaround for passivetex lack of support for non-constant expressions -->
  347. <xsl:when test="$passivetex.extensions != 0">
  348. <xsl:text>em</xsl:text>
  349. </xsl:when>
  350. <xsl:otherwise>
  351. <xsl:text>em * 0.60</xsl:text>
  352. </xsl:otherwise>
  353. </xsl:choose>
  354. </xsl:otherwise>
  355. </xsl:choose>
  356. </xsl:when>
  357. <xsl:otherwise>
  358. <xsl:call-template name="longest.term">
  359. <xsl:with-param name="terms" select="varlistentry/term"/>
  360. <xsl:with-param name="maxlength" select="$variablelist.max.termlength"/>
  361. </xsl:call-template>
  362. <xsl:choose>
  363. <!-- workaround for passivetex lack of support for non-constant expressions -->
  364. <xsl:when test="$passivetex.extensions != 0">
  365. <xsl:text>em</xsl:text>
  366. </xsl:when>
  367. <xsl:otherwise>
  368. <xsl:text>em * 0.60</xsl:text>
  369. </xsl:otherwise>
  370. </xsl:choose>
  371. </xsl:otherwise>
  372. </xsl:choose>
  373. </xsl:variable>
  374. <!--
  375. <xsl:message>
  376. <xsl:text>term width: </xsl:text>
  377. <xsl:value-of select="$termlength"/>
  378. </xsl:message>
  379. -->
  380. <xsl:variable name="label-separation">1em</xsl:variable>
  381. <xsl:variable name="distance-between-starts">
  382. <xsl:choose>
  383. <!-- workaround for passivetex lack of support for non-constant expressions -->
  384. <xsl:when test="$passivetex.extensions != 0">
  385. <xsl:value-of select="$termlength"/>
  386. </xsl:when>
  387. <xsl:otherwise>
  388. <xsl:value-of select="$termlength"/>
  389. <xsl:text>+</xsl:text>
  390. <xsl:value-of select="$label-separation"/>
  391. </xsl:otherwise>
  392. </xsl:choose>
  393. </xsl:variable>
  394. <xsl:if test="title">
  395. <xsl:apply-templates select="title" mode="list.title.mode"/>
  396. </xsl:if>
  397. <!-- Preserve order of PIs and comments -->
  398. <xsl:apply-templates
  399. select="*[not(self::varlistentry
  400. or self::title
  401. or self::titleabbrev)]
  402. |comment()[not(preceding-sibling::varlistentry)]
  403. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  404. <xsl:variable name="content">
  405. <xsl:apply-templates mode="vl.as.list"
  406. select="varlistentry
  407. |comment()[preceding-sibling::varlistentry]
  408. |processing-instruction()[preceding-sibling::varlistentry]"/>
  409. </xsl:variable>
  410. <!-- nested lists don't add extra list-block spacing -->
  411. <xsl:choose>
  412. <xsl:when test="ancestor::listitem">
  413. <fo:list-block id="{$id}"
  414. provisional-distance-between-starts=
  415. "{$distance-between-starts}"
  416. provisional-label-separation="{$label-separation}">
  417. <xsl:copy-of select="$content"/>
  418. </fo:list-block>
  419. </xsl:when>
  420. <xsl:otherwise>
  421. <fo:list-block id="{$id}"
  422. provisional-distance-between-starts=
  423. "{$distance-between-starts}"
  424. provisional-label-separation="{$label-separation}"
  425. xsl:use-attribute-sets="list.block.spacing">
  426. <xsl:copy-of select="$content"/>
  427. </fo:list-block>
  428. </xsl:otherwise>
  429. </xsl:choose>
  430. </xsl:template>
  431. <xsl:template name="longest.term">
  432. <xsl:param name="longest" select="0"/>
  433. <xsl:param name="terms" select="."/>
  434. <xsl:param name="maxlength" select="-1"/>
  435. <!-- Process out any indexterms in the term -->
  436. <xsl:variable name="term.text">
  437. <xsl:apply-templates select="$terms[1]"/>
  438. </xsl:variable>
  439. <xsl:choose>
  440. <xsl:when test="$longest &gt; $maxlength and $maxlength &gt; 0">
  441. <xsl:value-of select="$maxlength"/>
  442. </xsl:when>
  443. <xsl:when test="not($terms)">
  444. <xsl:value-of select="$longest"/>
  445. </xsl:when>
  446. <xsl:when test="string-length($term.text) &gt; $longest">
  447. <xsl:call-template name="longest.term">
  448. <xsl:with-param name="longest"
  449. select="string-length($term.text)"/>
  450. <xsl:with-param name="maxlength" select="$maxlength"/>
  451. <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
  452. </xsl:call-template>
  453. </xsl:when>
  454. <xsl:otherwise>
  455. <xsl:call-template name="longest.term">
  456. <xsl:with-param name="longest" select="$longest"/>
  457. <xsl:with-param name="maxlength" select="$maxlength"/>
  458. <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
  459. </xsl:call-template>
  460. </xsl:otherwise>
  461. </xsl:choose>
  462. </xsl:template>
  463. <xsl:template match="varlistentry" mode="vl.as.list">
  464. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  465. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  466. <fo:list-item-label end-indent="label-end()" text-align="start">
  467. <fo:block>
  468. <xsl:apply-templates select="term"/>
  469. </fo:block>
  470. </fo:list-item-label>
  471. <fo:list-item-body start-indent="body-start()">
  472. <fo:block>
  473. <xsl:apply-templates select="listitem"/>
  474. </fo:block>
  475. </fo:list-item-body>
  476. </fo:list-item>
  477. </xsl:template>
  478. <xsl:template match="variablelist" mode="vl.as.blocks">
  479. <xsl:variable name="id">
  480. <xsl:call-template name="object.id"/>
  481. </xsl:variable>
  482. <!-- termlength is irrelevant -->
  483. <xsl:if test="title">
  484. <xsl:apply-templates select="title" mode="list.title.mode"/>
  485. </xsl:if>
  486. <!-- Preserve order of PIs and comments -->
  487. <xsl:apply-templates
  488. select="*[not(self::varlistentry
  489. or self::title
  490. or self::titleabbrev)]
  491. |comment()[not(preceding-sibling::varlistentry)]
  492. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  493. <xsl:variable name="content">
  494. <xsl:apply-templates mode="vl.as.blocks"
  495. select="varlistentry
  496. |comment()[preceding-sibling::varlistentry]
  497. |processing-instruction()[preceding-sibling::varlistentry]"/>
  498. </xsl:variable>
  499. <!-- nested lists don't add extra list-block spacing -->
  500. <xsl:choose>
  501. <xsl:when test="ancestor::listitem">
  502. <fo:block id="{$id}">
  503. <xsl:copy-of select="$content"/>
  504. </fo:block>
  505. </xsl:when>
  506. <xsl:otherwise>
  507. <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
  508. <xsl:copy-of select="$content"/>
  509. </fo:block>
  510. </xsl:otherwise>
  511. </xsl:choose>
  512. </xsl:template>
  513. <xsl:template match="varlistentry" mode="vl.as.blocks">
  514. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  515. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  516. keep-together.within-column="always"
  517. keep-with-next.within-column="always">
  518. <xsl:apply-templates select="term"/>
  519. </fo:block>
  520. <fo:block margin-left="0.25in">
  521. <xsl:apply-templates select="listitem"/>
  522. </fo:block>
  523. </xsl:template>
  524. <xsl:template match="varlistentry/term">
  525. <fo:inline>
  526. <xsl:call-template name="simple.xlink">
  527. <xsl:with-param name="content">
  528. <xsl:apply-templates/>
  529. </xsl:with-param>
  530. </xsl:call-template>
  531. </fo:inline>
  532. <xsl:choose>
  533. <xsl:when test="not(following-sibling::term)"/> <!-- do nothing -->
  534. <xsl:otherwise>
  535. <!-- * if we have multiple terms in the same varlistentry, generate -->
  536. <!-- * a separator (", " by default) and/or an additional line -->
  537. <!-- * break after each one except the last -->
  538. <fo:inline><xsl:value-of select="$variablelist.term.separator"/></fo:inline>
  539. <xsl:if test="not($variablelist.term.break.after = '0')">
  540. <fo:block/>
  541. </xsl:if>
  542. </xsl:otherwise>
  543. </xsl:choose>
  544. </xsl:template>
  545. <xsl:template match="varlistentry/listitem">
  546. <xsl:apply-templates/>
  547. </xsl:template>
  548. <!-- ==================================================================== -->
  549. <xsl:template match="title" mode="list.title.mode">
  550. <xsl:call-template name="formal.object.heading">
  551. <xsl:with-param name="object" select=".."/>
  552. </xsl:call-template>
  553. </xsl:template>
  554. <!-- ==================================================================== -->
  555. <xsl:template match="simplelist">
  556. <!-- with no type specified, the default is 'vert' -->
  557. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  558. <xsl:call-template name="simplelist.table.columns">
  559. <xsl:with-param name="cols">
  560. <xsl:choose>
  561. <xsl:when test="@columns">
  562. <xsl:value-of select="@columns"/>
  563. </xsl:when>
  564. <xsl:otherwise>1</xsl:otherwise>
  565. </xsl:choose>
  566. </xsl:with-param>
  567. </xsl:call-template>
  568. <fo:table-body start-indent="0pt" end-indent="0pt">
  569. <xsl:call-template name="simplelist.vert">
  570. <xsl:with-param name="cols">
  571. <xsl:choose>
  572. <xsl:when test="@columns">
  573. <xsl:value-of select="@columns"/>
  574. </xsl:when>
  575. <xsl:otherwise>1</xsl:otherwise>
  576. </xsl:choose>
  577. </xsl:with-param>
  578. </xsl:call-template>
  579. </fo:table-body>
  580. </fo:table>
  581. </xsl:template>
  582. <xsl:template match="simplelist[@type='inline']">
  583. <!-- if dbchoice PI exists, use that to determine the choice separator -->
  584. <!-- (that is, equivalent of "and" or "or" in current locale), or literal -->
  585. <!-- value of "choice" otherwise -->
  586. <fo:inline><xsl:variable name="localized-choice-separator">
  587. <xsl:choose>
  588. <xsl:when test="processing-instruction('dbchoice')">
  589. <xsl:call-template name="select.choice.separator"/>
  590. </xsl:when>
  591. <xsl:otherwise>
  592. <!-- empty -->
  593. </xsl:otherwise>
  594. </xsl:choose>
  595. </xsl:variable>
  596. <xsl:for-each select="member">
  597. <xsl:apply-templates/>
  598. <xsl:choose>
  599. <xsl:when test="position() = last()"/> <!-- do nothing -->
  600. <xsl:otherwise>
  601. <xsl:text>, </xsl:text>
  602. <xsl:if test="position() = last() - 1">
  603. <xsl:if test="$localized-choice-separator != ''">
  604. <xsl:value-of select="$localized-choice-separator"/>
  605. <xsl:text> </xsl:text>
  606. </xsl:if>
  607. </xsl:if>
  608. </xsl:otherwise>
  609. </xsl:choose>
  610. </xsl:for-each></fo:inline>
  611. </xsl:template>
  612. <xsl:template match="simplelist[@type='horiz']">
  613. <xsl:variable name="explicit.table.width">
  614. <xsl:call-template name="dbfo-attribute">
  615. <xsl:with-param name="pis"
  616. select="processing-instruction('dbfo')"/>
  617. <xsl:with-param name="attribute" select="'list-width'"/>
  618. </xsl:call-template>
  619. </xsl:variable>
  620. <xsl:variable name="table.width">
  621. <xsl:choose>
  622. <xsl:when test="$explicit.table.width != ''">
  623. <xsl:value-of select="$explicit.table.width"/>
  624. </xsl:when>
  625. <xsl:when test="$default.table.width = ''">
  626. <xsl:text>100%</xsl:text>
  627. </xsl:when>
  628. <xsl:otherwise>
  629. <xsl:value-of select="$default.table.width"/>
  630. </xsl:otherwise>
  631. </xsl:choose>
  632. </xsl:variable>
  633. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  634. <xsl:choose>
  635. <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
  636. <xsl:attribute name="table-layout">auto</xsl:attribute>
  637. <xsl:if test="$explicit.table.width != ''">
  638. <xsl:attribute name="width"><xsl:value-of
  639. select="$explicit.table.width"/></xsl:attribute>
  640. </xsl:if>
  641. </xsl:when>
  642. <xsl:otherwise>
  643. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  644. <xsl:attribute name="width"><xsl:value-of
  645. select="$table.width"/></xsl:attribute>
  646. </xsl:otherwise>
  647. </xsl:choose>
  648. <xsl:call-template name="simplelist.table.columns">
  649. <xsl:with-param name="cols">
  650. <xsl:choose>
  651. <xsl:when test="@columns">
  652. <xsl:value-of select="@columns"/>
  653. </xsl:when>
  654. <xsl:otherwise>1</xsl:otherwise>
  655. </xsl:choose>
  656. </xsl:with-param>
  657. </xsl:call-template>
  658. <fo:table-body start-indent="0pt" end-indent="0pt">
  659. <xsl:call-template name="simplelist.horiz">
  660. <xsl:with-param name="cols">
  661. <xsl:choose>
  662. <xsl:when test="@columns">
  663. <xsl:value-of select="@columns"/>
  664. </xsl:when>
  665. <xsl:otherwise>1</xsl:otherwise>
  666. </xsl:choose>
  667. </xsl:with-param>
  668. </xsl:call-template>
  669. </fo:table-body>
  670. </fo:table>
  671. </xsl:template>
  672. <xsl:template match="simplelist[@type='vert']">
  673. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  674. <xsl:call-template name="simplelist.table.columns">
  675. <xsl:with-param name="cols">
  676. <xsl:choose>
  677. <xsl:when test="@columns">
  678. <xsl:value-of select="@columns"/>
  679. </xsl:when>
  680. <xsl:otherwise>1</xsl:otherwise>
  681. </xsl:choose>
  682. </xsl:with-param>
  683. </xsl:call-template>
  684. <fo:table-body start-indent="0pt" end-indent="0pt">
  685. <xsl:call-template name="simplelist.vert">
  686. <xsl:with-param name="cols">
  687. <xsl:choose>
  688. <xsl:when test="@columns">
  689. <xsl:value-of select="@columns"/>
  690. </xsl:when>
  691. <xsl:otherwise>1</xsl:otherwise>
  692. </xsl:choose>
  693. </xsl:with-param>
  694. </xsl:call-template>
  695. </fo:table-body>
  696. </fo:table>
  697. </xsl:template>
  698. <xsl:template name="simplelist.table.columns">
  699. <xsl:param name="cols" select="1"/>
  700. <xsl:param name="curcol" select="1"/>
  701. <fo:table-column column-number="{$curcol}"
  702. column-width="proportional-column-width(1)"/>
  703. <xsl:if test="$curcol &lt; $cols">
  704. <xsl:call-template name="simplelist.table.columns">
  705. <xsl:with-param name="cols" select="$cols"/>
  706. <xsl:with-param name="curcol" select="$curcol + 1"/>
  707. </xsl:call-template>
  708. </xsl:if>
  709. </xsl:template>
  710. <xsl:template name="simplelist.horiz">
  711. <xsl:param name="cols">1</xsl:param>
  712. <xsl:param name="cell">1</xsl:param>
  713. <xsl:param name="members" select="./member"/>
  714. <xsl:if test="$cell &lt;= count($members)">
  715. <fo:table-row>
  716. <xsl:call-template name="simplelist.horiz.row">
  717. <xsl:with-param name="cols" select="$cols"/>
  718. <xsl:with-param name="cell" select="$cell"/>
  719. <xsl:with-param name="members" select="$members"/>
  720. </xsl:call-template>
  721. </fo:table-row>
  722. <xsl:call-template name="simplelist.horiz">
  723. <xsl:with-param name="cols" select="$cols"/>
  724. <xsl:with-param name="cell" select="$cell + $cols"/>
  725. <xsl:with-param name="members" select="$members"/>
  726. </xsl:call-template>
  727. </xsl:if>
  728. </xsl:template>
  729. <xsl:template name="simplelist.horiz.row">
  730. <xsl:param name="cols">1</xsl:param>
  731. <xsl:param name="cell">1</xsl:param>
  732. <xsl:param name="members" select="./member"/>
  733. <xsl:param name="curcol">1</xsl:param>
  734. <xsl:if test="$curcol &lt;= $cols">
  735. <fo:table-cell>
  736. <fo:block>
  737. <xsl:if test="$members[position()=$cell]">
  738. <xsl:apply-templates select="$members[position()=$cell]"/>
  739. </xsl:if>
  740. </fo:block>
  741. </fo:table-cell>
  742. <xsl:call-template name="simplelist.horiz.row">
  743. <xsl:with-param name="cols" select="$cols"/>
  744. <xsl:with-param name="cell" select="$cell+1"/>
  745. <xsl:with-param name="members" select="$members"/>
  746. <xsl:with-param name="curcol" select="$curcol+1"/>
  747. </xsl:call-template>
  748. </xsl:if>
  749. </xsl:template>
  750. <xsl:template name="simplelist.vert">
  751. <xsl:param name="cols">1</xsl:param>
  752. <xsl:param name="cell">1</xsl:param>
  753. <xsl:param name="members" select="./member"/>
  754. <xsl:param name="rows"
  755. select="floor((count($members)+$cols - 1) div $cols)"/>
  756. <xsl:if test="$cell &lt;= $rows">
  757. <fo:table-row>
  758. <xsl:call-template name="simplelist.vert.row">
  759. <xsl:with-param name="cols" select="$cols"/>
  760. <xsl:with-param name="rows" select="$rows"/>
  761. <xsl:with-param name="cell" select="$cell"/>
  762. <xsl:with-param name="members" select="$members"/>
  763. </xsl:call-template>
  764. </fo:table-row>
  765. <xsl:call-template name="simplelist.vert">
  766. <xsl:with-param name="cols" select="$cols"/>
  767. <xsl:with-param name="cell" select="$cell+1"/>
  768. <xsl:with-param name="members" select="$members"/>
  769. <xsl:with-param name="rows" select="$rows"/>
  770. </xsl:call-template>
  771. </xsl:if>
  772. </xsl:template>
  773. <xsl:template name="simplelist.vert.row">
  774. <xsl:param name="cols">1</xsl:param>
  775. <xsl:param name="rows">1</xsl:param>
  776. <xsl:param name="cell">1</xsl:param>
  777. <xsl:param name="members" select="./member"/>
  778. <xsl:param name="curcol">1</xsl:param>
  779. <xsl:if test="$curcol &lt;= $cols">
  780. <fo:table-cell>
  781. <fo:block>
  782. <xsl:if test="$members[position()=$cell]">
  783. <xsl:apply-templates select="$members[position()=$cell]"/>
  784. </xsl:if>
  785. </fo:block>
  786. </fo:table-cell>
  787. <xsl:call-template name="simplelist.vert.row">
  788. <xsl:with-param name="cols" select="$cols"/>
  789. <xsl:with-param name="rows" select="$rows"/>
  790. <xsl:with-param name="cell" select="$cell+$rows"/>
  791. <xsl:with-param name="members" select="$members"/>
  792. <xsl:with-param name="curcol" select="$curcol+1"/>
  793. </xsl:call-template>
  794. </xsl:if>
  795. </xsl:template>
  796. <xsl:template match="member">
  797. <xsl:call-template name="simple.xlink">
  798. <xsl:with-param name="content">
  799. <xsl:apply-templates/>
  800. </xsl:with-param>
  801. </xsl:call-template>
  802. </xsl:template>
  803. <!-- ==================================================================== -->
  804. <xsl:template match="procedure">
  805. <xsl:variable name="id">
  806. <xsl:call-template name="object.id"/>
  807. </xsl:variable>
  808. <xsl:variable name="param.placement"
  809. select="substring-after(normalize-space($formal.title.placement),
  810. concat(local-name(.), ' '))"/>
  811. <xsl:variable name="placement">
  812. <xsl:choose>
  813. <xsl:when test="contains($param.placement, ' ')">
  814. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  815. </xsl:when>
  816. <xsl:when test="$param.placement = ''">before</xsl:when>
  817. <xsl:otherwise>
  818. <xsl:value-of select="$param.placement"/>
  819. </xsl:otherwise>
  820. </xsl:choose>
  821. </xsl:variable>
  822. <!-- Preserve order of PIs and comments -->
  823. <xsl:variable name="preamble"
  824. select="*[not(self::step
  825. or self::title
  826. or self::titleabbrev)]
  827. |comment()[not(preceding-sibling::step)]
  828. |processing-instruction()[not(preceding-sibling::step)]"/>
  829. <xsl:variable name="steps"
  830. select="step
  831. |comment()[preceding-sibling::step]
  832. |processing-instruction()[preceding-sibling::step]"/>
  833. <fo:block id="{$id}" xsl:use-attribute-sets="procedure.properties list.block.spacing">
  834. <xsl:if test="./title and $placement = 'before'">
  835. <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
  836. <!-- heading even though we called formal.object.heading. odd but true. -->
  837. <xsl:call-template name="formal.object.heading"/>
  838. </xsl:if>
  839. <xsl:apply-templates select="$preamble"/>
  840. <fo:list-block xsl:use-attribute-sets="list.block.spacing"
  841. provisional-distance-between-starts="2em"
  842. provisional-label-separation="0.2em">
  843. <xsl:apply-templates select="$steps"/>
  844. </fo:list-block>
  845. <xsl:if test="./title and $placement != 'before'">
  846. <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
  847. <!-- heading even though we called formal.object.heading. odd but true. -->
  848. <xsl:call-template name="formal.object.heading"/>
  849. </xsl:if>
  850. </fo:block>
  851. </xsl:template>
  852. <xsl:template match="procedure/title">
  853. </xsl:template>
  854. <xsl:template match="substeps">
  855. <fo:list-block xsl:use-attribute-sets="list.block.spacing"
  856. provisional-distance-between-starts="2em"
  857. provisional-label-separation="0.2em">
  858. <xsl:apply-templates/>
  859. </fo:list-block>
  860. </xsl:template>
  861. <xsl:template match="procedure/step|substeps/step">
  862. <xsl:variable name="id">
  863. <xsl:call-template name="object.id"/>
  864. </xsl:variable>
  865. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  866. <fo:list-item-label end-indent="label-end()">
  867. <fo:block id="{$id}">
  868. <!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
  869. <xsl:choose>
  870. <xsl:when test="count(../step) = 1">
  871. <xsl:text>&#x2022;</xsl:text>
  872. </xsl:when>
  873. <xsl:otherwise>
  874. <xsl:apply-templates select="." mode="number">
  875. <xsl:with-param name="recursive" select="0"/>
  876. </xsl:apply-templates>.
  877. </xsl:otherwise>
  878. </xsl:choose>
  879. </fo:block>
  880. </fo:list-item-label>
  881. <fo:list-item-body start-indent="body-start()">
  882. <fo:block>
  883. <xsl:apply-templates/>
  884. </fo:block>
  885. </fo:list-item-body>
  886. </fo:list-item>
  887. </xsl:template>
  888. <xsl:template match="stepalternatives">
  889. <fo:list-block provisional-distance-between-starts="2em"
  890. provisional-label-separation="0.2em">
  891. <xsl:apply-templates select="step"/>
  892. </fo:list-block>
  893. </xsl:template>
  894. <xsl:template match="stepalternatives/step">
  895. <xsl:variable name="id">
  896. <xsl:call-template name="object.id"/>
  897. </xsl:variable>
  898. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  899. <fo:list-item-label end-indent="label-end()">
  900. <fo:block id="{$id}">
  901. <xsl:text>&#x2022;</xsl:text>
  902. </fo:block>
  903. </fo:list-item-label>
  904. <fo:list-item-body start-indent="body-start()">
  905. <fo:block>
  906. <xsl:apply-templates/>
  907. </fo:block>
  908. </fo:list-item-body>
  909. </fo:list-item>
  910. </xsl:template>
  911. <xsl:template match="step/title">
  912. <fo:block font-weight="bold"
  913. keep-together.within-column="always"
  914. keep-with-next.within-column="always">
  915. <xsl:apply-templates/>
  916. </fo:block>
  917. </xsl:template>
  918. <!-- ==================================================================== -->
  919. <xsl:template match="segmentedlist">
  920. <xsl:variable name="presentation">
  921. <xsl:call-template name="pi-attribute">
  922. <xsl:with-param name="pis"
  923. select="processing-instruction('dbfo')"/>
  924. <xsl:with-param name="attribute" select="'list-presentation'"/>
  925. </xsl:call-template>
  926. </xsl:variable>
  927. <xsl:variable name="id">
  928. <xsl:call-template name="object.id"/>
  929. </xsl:variable>
  930. <xsl:choose>
  931. <xsl:when test="$presentation = 'table'">
  932. <fo:block id="{$id}">
  933. <xsl:apply-templates select="." mode="seglist-table"/>
  934. </fo:block>
  935. </xsl:when>
  936. <xsl:when test="$presentation = 'list'">
  937. <fo:block id="{$id}">
  938. <xsl:apply-templates/>
  939. </fo:block>
  940. </xsl:when>
  941. <xsl:when test="$segmentedlist.as.table != 0">
  942. <fo:block id="{$id}">
  943. <xsl:apply-templates select="." mode="seglist-table"/>
  944. </fo:block>
  945. </xsl:when>
  946. <xsl:otherwise>
  947. <fo:block id="{$id}">
  948. <xsl:apply-templates/>
  949. </fo:block>
  950. </xsl:otherwise>
  951. </xsl:choose>
  952. </xsl:template>
  953. <xsl:template match="segmentedlist/title">
  954. <xsl:apply-templates select="." mode="list.title.mode" />
  955. </xsl:template>
  956. <xsl:template match="segtitle">
  957. </xsl:template>
  958. <xsl:template match="segtitle" mode="segtitle-in-seg">
  959. <xsl:apply-templates/>
  960. </xsl:template>
  961. <xsl:template match="seglistitem">
  962. <xsl:variable name="id">
  963. <xsl:call-template name="object.id"/>
  964. </xsl:variable>
  965. <fo:block id="{$id}">
  966. <xsl:apply-templates/>
  967. </fo:block>
  968. </xsl:template>
  969. <xsl:template match="seg">
  970. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  971. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  972. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  973. <!--
  974. Note: segtitle is only going to be the right thing in a well formed
  975. SegmentedList. If there are too many Segs or too few SegTitles,
  976. you'll get something odd...maybe an error
  977. -->
  978. <fo:block>
  979. <fo:inline font-weight="bold">
  980. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  981. mode="segtitle-in-seg"/>
  982. <xsl:text>: </xsl:text>
  983. </fo:inline>
  984. <xsl:apply-templates/>
  985. </fo:block>
  986. </xsl:template>
  987. <xsl:template match="segmentedlist" mode="seglist-table">
  988. <xsl:apply-templates select="title" mode="list.title.mode" />
  989. <fo:table>
  990. <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
  991. <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
  992. <fo:table-header start-indent="0pt" end-indent="0pt">
  993. <fo:table-row>
  994. <xsl:apply-templates select="segtitle" mode="seglist-table"/>
  995. </fo:table-row>
  996. </fo:table-header>
  997. <fo:table-body start-indent="0pt" end-indent="0pt">
  998. <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
  999. </fo:table-body>
  1000. </fo:table>
  1001. </xsl:template>
  1002. <xsl:template match="segtitle" mode="seglist-table">
  1003. <fo:table-cell>
  1004. <fo:block font-weight="bold">
  1005. <xsl:apply-templates/>
  1006. </fo:block>
  1007. </fo:table-cell>
  1008. </xsl:template>
  1009. <xsl:template match="seglistitem" mode="seglist-table">
  1010. <xsl:variable name="id">
  1011. <xsl:call-template name="object.id"/>
  1012. </xsl:variable>
  1013. <fo:table-row id="{$id}">
  1014. <xsl:apply-templates mode="seglist-table"/>
  1015. </fo:table-row>
  1016. </xsl:template>
  1017. <xsl:template match="seg" mode="seglist-table">
  1018. <fo:table-cell>
  1019. <fo:block>
  1020. <xsl:apply-templates/>
  1021. </fo:block>
  1022. </fo:table-cell>
  1023. </xsl:template>
  1024. <!-- ==================================================================== -->
  1025. <xsl:template match="calloutlist">
  1026. <xsl:variable name="id">
  1027. <xsl:call-template name="object.id"/>
  1028. </xsl:variable>
  1029. <fo:block id="{$id}"
  1030. text-align="{$alignment}">
  1031. <!-- The above restores alignment altered by image align attribute -->
  1032. <xsl:if test="title|info/title">
  1033. <xsl:apply-templates select="(title|info/title)[1]"
  1034. mode="list.title.mode"/>
  1035. </xsl:if>
  1036. <!-- Preserve order of PIs and comments -->
  1037. <xsl:apply-templates
  1038. select="*[not(self::callout or self::title or self::titleabbrev)]
  1039. |comment()[not(preceding-sibling::callout)]
  1040. |processing-instruction()[not(preceding-sibling::callout)]"/>
  1041. <fo:list-block space-before.optimum="1em"
  1042. space-before.minimum="0.8em"
  1043. space-before.maximum="1.2em"
  1044. provisional-distance-between-starts="2.2em"
  1045. provisional-label-separation="0.2em">
  1046. <xsl:apply-templates select="callout
  1047. |comment()[preceding-sibling::callout]
  1048. |processing-instruction()[preceding-sibling::callout]"/>
  1049. </fo:list-block>
  1050. </fo:block>
  1051. </xsl:template>
  1052. <xsl:template match="calloutlist/title">
  1053. </xsl:template>
  1054. <xsl:template match="callout">
  1055. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  1056. <fo:list-item id="{$id}">
  1057. <fo:list-item-label end-indent="label-end()">
  1058. <fo:block>
  1059. <xsl:call-template name="callout.arearefs">
  1060. <xsl:with-param name="arearefs" select="@arearefs"/>
  1061. </xsl:call-template>
  1062. </fo:block>
  1063. </fo:list-item-label>
  1064. <fo:list-item-body start-indent="body-start()">
  1065. <fo:block>
  1066. <xsl:apply-templates/>
  1067. </fo:block>
  1068. </fo:list-item-body>
  1069. </fo:list-item>
  1070. </xsl:template>
  1071. <xsl:template name="callout.arearefs">
  1072. <xsl:param name="arearefs"></xsl:param>
  1073. <xsl:if test="$arearefs!=''">
  1074. <xsl:choose>
  1075. <xsl:when test="substring-before($arearefs,' ')=''">
  1076. <xsl:call-template name="callout.arearef">
  1077. <xsl:with-param name="arearef" select="$arearefs"/>
  1078. </xsl:call-template>
  1079. </xsl:when>
  1080. <xsl:otherwise>
  1081. <xsl:call-template name="callout.arearef">
  1082. <xsl:with-param name="arearef"
  1083. select="substring-before($arearefs,' ')"/>
  1084. </xsl:call-template>
  1085. </xsl:otherwise>
  1086. </xsl:choose>
  1087. <xsl:call-template name="callout.arearefs">
  1088. <xsl:with-param name="arearefs"
  1089. select="substring-after($arearefs,' ')"/>
  1090. </xsl:call-template>
  1091. </xsl:if>
  1092. </xsl:template>
  1093. <xsl:template name="callout.arearef">
  1094. <xsl:param name="arearef"></xsl:param>
  1095. <xsl:variable name="targets" select="key('id',$arearef)"/>
  1096. <xsl:variable name="target" select="$targets[1]"/>
  1097. <xsl:choose>
  1098. <xsl:when test="count($target)=0">
  1099. <xsl:value-of select="$arearef"/>
  1100. <xsl:text>: ???</xsl:text>
  1101. </xsl:when>
  1102. <xsl:when test="local-name($target)='co'">
  1103. <xsl:apply-templates select="$target" mode="callout-bug"/>
  1104. </xsl:when>
  1105. <xsl:when test="local-name($target)='areaset'">
  1106. <xsl:call-template name="callout-bug">
  1107. <xsl:with-param name="conum">
  1108. <xsl:apply-templates select="$target" mode="conumber"/>
  1109. </xsl:with-param>
  1110. </xsl:call-template>
  1111. </xsl:when>
  1112. <xsl:when test="local-name($target)='area'">
  1113. <xsl:choose>
  1114. <xsl:when test="$target/parent::areaset">
  1115. <xsl:call-template name="callout-bug">
  1116. <xsl:with-param name="conum">
  1117. <xsl:apply-templates select="$target/parent::areaset"
  1118. mode="conumber"/>
  1119. </xsl:with-param>
  1120. </xsl:call-template>
  1121. </xsl:when>
  1122. <xsl:otherwise>
  1123. <xsl:call-template name="callout-bug">
  1124. <xsl:with-param name="conum">
  1125. <xsl:apply-templates select="$target" mode="conumber"/>
  1126. </xsl:with-param>
  1127. </xsl:call-template>
  1128. </xsl:otherwise>
  1129. </xsl:choose>
  1130. </xsl:when>
  1131. <xsl:otherwise>
  1132. <xsl:text>???</xsl:text>
  1133. </xsl:otherwise>
  1134. </xsl:choose>
  1135. </xsl:template>
  1136. <!-- ==================================================================== -->
  1137. </xsl:stylesheet>