lists.xsl 43 KB

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