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://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">
  465. <xsl:call-template name="object.id"/>
  466. </xsl:variable>
  467. <xsl:variable name="item.contents">
  468. <fo:list-item-label end-indent="label-end()" text-align="start">
  469. <fo:block>
  470. <xsl:apply-templates select="term"/>
  471. </fo:block>
  472. </fo:list-item-label>
  473. <fo:list-item-body start-indent="body-start()">
  474. <fo:block>
  475. <xsl:apply-templates select="listitem"/>
  476. </fo:block>
  477. </fo:list-item-body>
  478. </xsl:variable>
  479. <xsl:choose>
  480. <xsl:when test="parent::*/@spacing = 'compact'">
  481. <fo:list-item id="{$id}"
  482. xsl:use-attribute-sets="compact.list.item.spacing">
  483. <xsl:copy-of select="$item.contents"/>
  484. </fo:list-item>
  485. </xsl:when>
  486. <xsl:otherwise>
  487. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  488. <xsl:copy-of select="$item.contents"/>
  489. </fo:list-item>
  490. </xsl:otherwise>
  491. </xsl:choose>
  492. </xsl:template>
  493. <xsl:template match="variablelist" mode="vl.as.blocks">
  494. <xsl:variable name="id">
  495. <xsl:call-template name="object.id"/>
  496. </xsl:variable>
  497. <!-- termlength is irrelevant -->
  498. <xsl:if test="title">
  499. <xsl:apply-templates select="title" mode="list.title.mode"/>
  500. </xsl:if>
  501. <!-- Preserve order of PIs and comments -->
  502. <xsl:apply-templates
  503. select="*[not(self::varlistentry
  504. or self::title
  505. or self::titleabbrev)]
  506. |comment()[not(preceding-sibling::varlistentry)]
  507. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  508. <xsl:variable name="content">
  509. <xsl:apply-templates mode="vl.as.blocks"
  510. select="varlistentry
  511. |comment()[preceding-sibling::varlistentry]
  512. |processing-instruction()[preceding-sibling::varlistentry]"/>
  513. </xsl:variable>
  514. <!-- nested lists don't add extra list-block spacing -->
  515. <xsl:choose>
  516. <xsl:when test="ancestor::listitem">
  517. <fo:block id="{$id}">
  518. <xsl:copy-of select="$content"/>
  519. </fo:block>
  520. </xsl:when>
  521. <xsl:otherwise>
  522. <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
  523. <xsl:copy-of select="$content"/>
  524. </fo:block>
  525. </xsl:otherwise>
  526. </xsl:choose>
  527. </xsl:template>
  528. <xsl:template match="varlistentry" mode="vl.as.blocks">
  529. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  530. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  531. keep-together.within-column="always"
  532. keep-with-next.within-column="always">
  533. <xsl:apply-templates select="term"/>
  534. </fo:block>
  535. <fo:block margin-left="0.25in">
  536. <xsl:apply-templates select="listitem"/>
  537. </fo:block>
  538. </xsl:template>
  539. <xsl:template match="varlistentry/term">
  540. <fo:inline>
  541. <xsl:call-template name="simple.xlink">
  542. <xsl:with-param name="content">
  543. <xsl:apply-templates/>
  544. </xsl:with-param>
  545. </xsl:call-template>
  546. </fo:inline>
  547. <xsl:choose>
  548. <xsl:when test="not(following-sibling::term)"/> <!-- do nothing -->
  549. <xsl:otherwise>
  550. <!-- * if we have multiple terms in the same varlistentry, generate -->
  551. <!-- * a separator (", " by default) and/or an additional line -->
  552. <!-- * break after each one except the last -->
  553. <fo:inline><xsl:value-of select="$variablelist.term.separator"/></fo:inline>
  554. <xsl:if test="not($variablelist.term.break.after = '0')">
  555. <fo:block/>
  556. </xsl:if>
  557. </xsl:otherwise>
  558. </xsl:choose>
  559. </xsl:template>
  560. <xsl:template match="varlistentry/listitem">
  561. <xsl:apply-templates/>
  562. </xsl:template>
  563. <!-- ==================================================================== -->
  564. <xsl:template match="title" mode="list.title.mode">
  565. <xsl:call-template name="formal.object.heading">
  566. <xsl:with-param name="object" select=".."/>
  567. </xsl:call-template>
  568. </xsl:template>
  569. <!-- ==================================================================== -->
  570. <xsl:template match="simplelist">
  571. <!-- with no type specified, the default is 'vert' -->
  572. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  573. <xsl:call-template name="simplelist.table.columns">
  574. <xsl:with-param name="cols">
  575. <xsl:choose>
  576. <xsl:when test="@columns">
  577. <xsl:value-of select="@columns"/>
  578. </xsl:when>
  579. <xsl:otherwise>1</xsl:otherwise>
  580. </xsl:choose>
  581. </xsl:with-param>
  582. </xsl:call-template>
  583. <fo:table-body start-indent="0pt" end-indent="0pt">
  584. <xsl:call-template name="simplelist.vert">
  585. <xsl:with-param name="cols">
  586. <xsl:choose>
  587. <xsl:when test="@columns">
  588. <xsl:value-of select="@columns"/>
  589. </xsl:when>
  590. <xsl:otherwise>1</xsl:otherwise>
  591. </xsl:choose>
  592. </xsl:with-param>
  593. </xsl:call-template>
  594. </fo:table-body>
  595. </fo:table>
  596. </xsl:template>
  597. <xsl:template match="simplelist[@type='inline']">
  598. <!-- if dbchoice PI exists, use that to determine the choice separator -->
  599. <!-- (that is, equivalent of "and" or "or" in current locale), or literal -->
  600. <!-- value of "choice" otherwise -->
  601. <fo:inline><xsl:variable name="localized-choice-separator">
  602. <xsl:choose>
  603. <xsl:when test="processing-instruction('dbchoice')">
  604. <xsl:call-template name="select.choice.separator"/>
  605. </xsl:when>
  606. <xsl:otherwise>
  607. <!-- empty -->
  608. </xsl:otherwise>
  609. </xsl:choose>
  610. </xsl:variable>
  611. <xsl:for-each select="member">
  612. <xsl:apply-templates/>
  613. <xsl:choose>
  614. <xsl:when test="position() = last()"/> <!-- do nothing -->
  615. <xsl:otherwise>
  616. <xsl:text>, </xsl:text>
  617. <xsl:if test="position() = last() - 1">
  618. <xsl:if test="$localized-choice-separator != ''">
  619. <xsl:value-of select="$localized-choice-separator"/>
  620. <xsl:text> </xsl:text>
  621. </xsl:if>
  622. </xsl:if>
  623. </xsl:otherwise>
  624. </xsl:choose>
  625. </xsl:for-each></fo:inline>
  626. </xsl:template>
  627. <xsl:template match="simplelist[@type='horiz']">
  628. <xsl:variable name="explicit.table.width">
  629. <xsl:call-template name="dbfo-attribute">
  630. <xsl:with-param name="pis"
  631. select="processing-instruction('dbfo')"/>
  632. <xsl:with-param name="attribute" select="'list-width'"/>
  633. </xsl:call-template>
  634. </xsl:variable>
  635. <xsl:variable name="table.width">
  636. <xsl:choose>
  637. <xsl:when test="$explicit.table.width != ''">
  638. <xsl:value-of select="$explicit.table.width"/>
  639. </xsl:when>
  640. <xsl:when test="$default.table.width = ''">
  641. <xsl:text>100%</xsl:text>
  642. </xsl:when>
  643. <xsl:otherwise>
  644. <xsl:value-of select="$default.table.width"/>
  645. </xsl:otherwise>
  646. </xsl:choose>
  647. </xsl:variable>
  648. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  649. <xsl:choose>
  650. <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
  651. <xsl:attribute name="table-layout">auto</xsl:attribute>
  652. <xsl:if test="$explicit.table.width != ''">
  653. <xsl:attribute name="width"><xsl:value-of
  654. select="$explicit.table.width"/></xsl:attribute>
  655. </xsl:if>
  656. </xsl:when>
  657. <xsl:otherwise>
  658. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  659. <xsl:attribute name="width"><xsl:value-of
  660. select="$table.width"/></xsl:attribute>
  661. </xsl:otherwise>
  662. </xsl:choose>
  663. <xsl:call-template name="simplelist.table.columns">
  664. <xsl:with-param name="cols">
  665. <xsl:choose>
  666. <xsl:when test="@columns">
  667. <xsl:value-of select="@columns"/>
  668. </xsl:when>
  669. <xsl:otherwise>1</xsl:otherwise>
  670. </xsl:choose>
  671. </xsl:with-param>
  672. </xsl:call-template>
  673. <fo:table-body start-indent="0pt" end-indent="0pt">
  674. <xsl:call-template name="simplelist.horiz">
  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>
  685. </fo:table>
  686. </xsl:template>
  687. <xsl:template match="simplelist[@type='vert']">
  688. <fo:table xsl:use-attribute-sets="normal.para.spacing">
  689. <xsl:call-template name="simplelist.table.columns">
  690. <xsl:with-param name="cols">
  691. <xsl:choose>
  692. <xsl:when test="@columns">
  693. <xsl:value-of select="@columns"/>
  694. </xsl:when>
  695. <xsl:otherwise>1</xsl:otherwise>
  696. </xsl:choose>
  697. </xsl:with-param>
  698. </xsl:call-template>
  699. <fo:table-body start-indent="0pt" end-indent="0pt">
  700. <xsl:call-template name="simplelist.vert">
  701. <xsl:with-param name="cols">
  702. <xsl:choose>
  703. <xsl:when test="@columns">
  704. <xsl:value-of select="@columns"/>
  705. </xsl:when>
  706. <xsl:otherwise>1</xsl:otherwise>
  707. </xsl:choose>
  708. </xsl:with-param>
  709. </xsl:call-template>
  710. </fo:table-body>
  711. </fo:table>
  712. </xsl:template>
  713. <xsl:template name="simplelist.table.columns">
  714. <xsl:param name="cols" select="1"/>
  715. <xsl:param name="curcol" select="1"/>
  716. <fo:table-column column-number="{$curcol}"
  717. column-width="proportional-column-width(1)"/>
  718. <xsl:if test="$curcol &lt; $cols">
  719. <xsl:call-template name="simplelist.table.columns">
  720. <xsl:with-param name="cols" select="$cols"/>
  721. <xsl:with-param name="curcol" select="$curcol + 1"/>
  722. </xsl:call-template>
  723. </xsl:if>
  724. </xsl:template>
  725. <xsl:template name="simplelist.horiz">
  726. <xsl:param name="cols">1</xsl:param>
  727. <xsl:param name="cell">1</xsl:param>
  728. <xsl:param name="members" select="./member"/>
  729. <xsl:if test="$cell &lt;= count($members)">
  730. <fo:table-row>
  731. <xsl:call-template name="simplelist.horiz.row">
  732. <xsl:with-param name="cols" select="$cols"/>
  733. <xsl:with-param name="cell" select="$cell"/>
  734. <xsl:with-param name="members" select="$members"/>
  735. </xsl:call-template>
  736. </fo:table-row>
  737. <xsl:call-template name="simplelist.horiz">
  738. <xsl:with-param name="cols" select="$cols"/>
  739. <xsl:with-param name="cell" select="$cell + $cols"/>
  740. <xsl:with-param name="members" select="$members"/>
  741. </xsl:call-template>
  742. </xsl:if>
  743. </xsl:template>
  744. <xsl:template name="simplelist.horiz.row">
  745. <xsl:param name="cols">1</xsl:param>
  746. <xsl:param name="cell">1</xsl:param>
  747. <xsl:param name="members" select="./member"/>
  748. <xsl:param name="curcol">1</xsl:param>
  749. <xsl:if test="$curcol &lt;= $cols">
  750. <fo:table-cell>
  751. <fo:block>
  752. <xsl:if test="$members[position()=$cell]">
  753. <xsl:apply-templates select="$members[position()=$cell]"/>
  754. </xsl:if>
  755. </fo:block>
  756. </fo:table-cell>
  757. <xsl:call-template name="simplelist.horiz.row">
  758. <xsl:with-param name="cols" select="$cols"/>
  759. <xsl:with-param name="cell" select="$cell+1"/>
  760. <xsl:with-param name="members" select="$members"/>
  761. <xsl:with-param name="curcol" select="$curcol+1"/>
  762. </xsl:call-template>
  763. </xsl:if>
  764. </xsl:template>
  765. <xsl:template name="simplelist.vert">
  766. <xsl:param name="cols">1</xsl:param>
  767. <xsl:param name="cell">1</xsl:param>
  768. <xsl:param name="members" select="./member"/>
  769. <xsl:param name="rows"
  770. select="floor((count($members)+$cols - 1) div $cols)"/>
  771. <xsl:if test="$cell &lt;= $rows">
  772. <fo:table-row>
  773. <xsl:call-template name="simplelist.vert.row">
  774. <xsl:with-param name="cols" select="$cols"/>
  775. <xsl:with-param name="rows" select="$rows"/>
  776. <xsl:with-param name="cell" select="$cell"/>
  777. <xsl:with-param name="members" select="$members"/>
  778. </xsl:call-template>
  779. </fo:table-row>
  780. <xsl:call-template name="simplelist.vert">
  781. <xsl:with-param name="cols" select="$cols"/>
  782. <xsl:with-param name="cell" select="$cell+1"/>
  783. <xsl:with-param name="members" select="$members"/>
  784. <xsl:with-param name="rows" select="$rows"/>
  785. </xsl:call-template>
  786. </xsl:if>
  787. </xsl:template>
  788. <xsl:template name="simplelist.vert.row">
  789. <xsl:param name="cols">1</xsl:param>
  790. <xsl:param name="rows">1</xsl:param>
  791. <xsl:param name="cell">1</xsl:param>
  792. <xsl:param name="members" select="./member"/>
  793. <xsl:param name="curcol">1</xsl:param>
  794. <xsl:if test="$curcol &lt;= $cols">
  795. <fo:table-cell>
  796. <fo:block>
  797. <xsl:if test="$members[position()=$cell]">
  798. <xsl:apply-templates select="$members[position()=$cell]"/>
  799. </xsl:if>
  800. </fo:block>
  801. </fo:table-cell>
  802. <xsl:call-template name="simplelist.vert.row">
  803. <xsl:with-param name="cols" select="$cols"/>
  804. <xsl:with-param name="rows" select="$rows"/>
  805. <xsl:with-param name="cell" select="$cell+$rows"/>
  806. <xsl:with-param name="members" select="$members"/>
  807. <xsl:with-param name="curcol" select="$curcol+1"/>
  808. </xsl:call-template>
  809. </xsl:if>
  810. </xsl:template>
  811. <xsl:template match="member">
  812. <xsl:call-template name="simple.xlink">
  813. <xsl:with-param name="content">
  814. <xsl:apply-templates/>
  815. </xsl:with-param>
  816. </xsl:call-template>
  817. </xsl:template>
  818. <!-- ==================================================================== -->
  819. <xsl:template match="procedure">
  820. <xsl:variable name="id">
  821. <xsl:call-template name="object.id"/>
  822. </xsl:variable>
  823. <xsl:variable name="param.placement"
  824. select="substring-after(normalize-space($formal.title.placement),
  825. concat(local-name(.), ' '))"/>
  826. <xsl:variable name="placement">
  827. <xsl:choose>
  828. <xsl:when test="contains($param.placement, ' ')">
  829. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  830. </xsl:when>
  831. <xsl:when test="$param.placement = ''">before</xsl:when>
  832. <xsl:otherwise>
  833. <xsl:value-of select="$param.placement"/>
  834. </xsl:otherwise>
  835. </xsl:choose>
  836. </xsl:variable>
  837. <!-- Preserve order of PIs and comments -->
  838. <xsl:variable name="preamble"
  839. select="*[not(self::step
  840. or self::title
  841. or self::titleabbrev)]
  842. |comment()[not(preceding-sibling::step)]
  843. |processing-instruction()[not(preceding-sibling::step)]"/>
  844. <xsl:variable name="steps"
  845. select="step
  846. |comment()[preceding-sibling::step]
  847. |processing-instruction()[preceding-sibling::step]"/>
  848. <fo:block id="{$id}" xsl:use-attribute-sets="procedure.properties list.block.spacing">
  849. <xsl:if test="./title and $placement = 'before'">
  850. <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
  851. <!-- heading even though we called formal.object.heading. odd but true. -->
  852. <xsl:call-template name="formal.object.heading"/>
  853. </xsl:if>
  854. <xsl:apply-templates select="$preamble"/>
  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 select="$steps"/>
  859. </fo:list-block>
  860. <xsl:if test="./title and $placement != 'before'">
  861. <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
  862. <!-- heading even though we called formal.object.heading. odd but true. -->
  863. <xsl:call-template name="formal.object.heading"/>
  864. </xsl:if>
  865. </fo:block>
  866. </xsl:template>
  867. <xsl:template match="procedure/title">
  868. </xsl:template>
  869. <xsl:template match="substeps">
  870. <fo:list-block xsl:use-attribute-sets="list.block.spacing"
  871. provisional-distance-between-starts="2em"
  872. provisional-label-separation="0.2em">
  873. <xsl:apply-templates/>
  874. </fo:list-block>
  875. </xsl:template>
  876. <xsl:template match="procedure/step|substeps/step">
  877. <xsl:variable name="id">
  878. <xsl:call-template name="object.id"/>
  879. </xsl:variable>
  880. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  881. <fo:list-item-label end-indent="label-end()">
  882. <fo:block id="{$id}">
  883. <!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
  884. <xsl:choose>
  885. <xsl:when test="count(../step) = 1">
  886. <xsl:text>&#x2022;</xsl:text>
  887. </xsl:when>
  888. <xsl:otherwise>
  889. <xsl:apply-templates select="." mode="number">
  890. <xsl:with-param name="recursive" select="0"/>
  891. </xsl:apply-templates>.
  892. </xsl:otherwise>
  893. </xsl:choose>
  894. </fo:block>
  895. </fo:list-item-label>
  896. <fo:list-item-body start-indent="body-start()">
  897. <fo:block>
  898. <xsl:apply-templates/>
  899. </fo:block>
  900. </fo:list-item-body>
  901. </fo:list-item>
  902. </xsl:template>
  903. <xsl:template match="stepalternatives">
  904. <fo:list-block provisional-distance-between-starts="2em"
  905. provisional-label-separation="0.2em">
  906. <xsl:apply-templates select="step"/>
  907. </fo:list-block>
  908. </xsl:template>
  909. <xsl:template match="stepalternatives/step">
  910. <xsl:variable name="id">
  911. <xsl:call-template name="object.id"/>
  912. </xsl:variable>
  913. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  914. <fo:list-item-label end-indent="label-end()">
  915. <fo:block id="{$id}">
  916. <xsl:text>&#x2022;</xsl:text>
  917. </fo:block>
  918. </fo:list-item-label>
  919. <fo:list-item-body start-indent="body-start()">
  920. <fo:block>
  921. <xsl:apply-templates/>
  922. </fo:block>
  923. </fo:list-item-body>
  924. </fo:list-item>
  925. </xsl:template>
  926. <xsl:template match="step/title">
  927. <fo:block font-weight="bold"
  928. keep-together.within-column="always"
  929. keep-with-next.within-column="always">
  930. <xsl:apply-templates/>
  931. </fo:block>
  932. </xsl:template>
  933. <!-- ==================================================================== -->
  934. <xsl:template match="segmentedlist">
  935. <xsl:variable name="presentation">
  936. <xsl:call-template name="pi-attribute">
  937. <xsl:with-param name="pis"
  938. select="processing-instruction('dbfo')"/>
  939. <xsl:with-param name="attribute" select="'list-presentation'"/>
  940. </xsl:call-template>
  941. </xsl:variable>
  942. <xsl:variable name="id">
  943. <xsl:call-template name="object.id"/>
  944. </xsl:variable>
  945. <xsl:choose>
  946. <xsl:when test="$presentation = 'table'">
  947. <fo:block id="{$id}">
  948. <xsl:apply-templates select="." mode="seglist-table"/>
  949. </fo:block>
  950. </xsl:when>
  951. <xsl:when test="$presentation = 'list'">
  952. <fo:block id="{$id}">
  953. <xsl:apply-templates/>
  954. </fo:block>
  955. </xsl:when>
  956. <xsl:when test="$segmentedlist.as.table != 0">
  957. <fo:block id="{$id}">
  958. <xsl:apply-templates select="." mode="seglist-table"/>
  959. </fo:block>
  960. </xsl:when>
  961. <xsl:otherwise>
  962. <fo:block id="{$id}">
  963. <xsl:apply-templates/>
  964. </fo:block>
  965. </xsl:otherwise>
  966. </xsl:choose>
  967. </xsl:template>
  968. <xsl:template match="segmentedlist/title">
  969. <xsl:apply-templates select="." mode="list.title.mode" />
  970. </xsl:template>
  971. <xsl:template match="segtitle">
  972. </xsl:template>
  973. <xsl:template match="segtitle" mode="segtitle-in-seg">
  974. <xsl:apply-templates/>
  975. </xsl:template>
  976. <xsl:template match="seglistitem">
  977. <xsl:variable name="id">
  978. <xsl:call-template name="object.id"/>
  979. </xsl:variable>
  980. <fo:block id="{$id}">
  981. <xsl:apply-templates/>
  982. </fo:block>
  983. </xsl:template>
  984. <xsl:template match="seg">
  985. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  986. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  987. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  988. <!--
  989. Note: segtitle is only going to be the right thing in a well formed
  990. SegmentedList. If there are too many Segs or too few SegTitles,
  991. you'll get something odd...maybe an error
  992. -->
  993. <fo:block>
  994. <fo:inline font-weight="bold">
  995. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  996. mode="segtitle-in-seg"/>
  997. <xsl:text>: </xsl:text>
  998. </fo:inline>
  999. <xsl:apply-templates/>
  1000. </fo:block>
  1001. </xsl:template>
  1002. <xsl:template match="segmentedlist" mode="seglist-table">
  1003. <xsl:apply-templates select="title" mode="list.title.mode" />
  1004. <fo:table>
  1005. <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
  1006. <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
  1007. <fo:table-header start-indent="0pt" end-indent="0pt">
  1008. <fo:table-row>
  1009. <xsl:apply-templates select="segtitle" mode="seglist-table"/>
  1010. </fo:table-row>
  1011. </fo:table-header>
  1012. <fo:table-body start-indent="0pt" end-indent="0pt">
  1013. <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
  1014. </fo:table-body>
  1015. </fo:table>
  1016. </xsl:template>
  1017. <xsl:template match="segtitle" mode="seglist-table">
  1018. <fo:table-cell>
  1019. <fo:block font-weight="bold">
  1020. <xsl:apply-templates/>
  1021. </fo:block>
  1022. </fo:table-cell>
  1023. </xsl:template>
  1024. <xsl:template match="seglistitem" mode="seglist-table">
  1025. <xsl:variable name="id">
  1026. <xsl:call-template name="object.id"/>
  1027. </xsl:variable>
  1028. <fo:table-row id="{$id}">
  1029. <xsl:apply-templates mode="seglist-table"/>
  1030. </fo:table-row>
  1031. </xsl:template>
  1032. <xsl:template match="seg" mode="seglist-table">
  1033. <fo:table-cell>
  1034. <fo:block>
  1035. <xsl:apply-templates/>
  1036. </fo:block>
  1037. </fo:table-cell>
  1038. </xsl:template>
  1039. <!-- ==================================================================== -->
  1040. <xsl:template match="calloutlist">
  1041. <xsl:variable name="id">
  1042. <xsl:call-template name="object.id"/>
  1043. </xsl:variable>
  1044. <fo:block id="{$id}"
  1045. text-align="{$alignment}">
  1046. <!-- The above restores alignment altered by image align attribute -->
  1047. <xsl:if test="title|info/title">
  1048. <xsl:apply-templates select="(title|info/title)[1]"
  1049. mode="list.title.mode"/>
  1050. </xsl:if>
  1051. <!-- Preserve order of PIs and comments -->
  1052. <xsl:apply-templates
  1053. select="*[not(self::callout or self::title or self::titleabbrev)]
  1054. |comment()[not(preceding-sibling::callout)]
  1055. |processing-instruction()[not(preceding-sibling::callout)]"/>
  1056. <fo:list-block space-before.optimum="1em"
  1057. space-before.minimum="0.8em"
  1058. space-before.maximum="1.2em"
  1059. provisional-distance-between-starts="2.2em"
  1060. provisional-label-separation="0.2em">
  1061. <xsl:apply-templates select="callout
  1062. |comment()[preceding-sibling::callout]
  1063. |processing-instruction()[preceding-sibling::callout]"/>
  1064. </fo:list-block>
  1065. </fo:block>
  1066. </xsl:template>
  1067. <xsl:template match="calloutlist/title">
  1068. </xsl:template>
  1069. <xsl:template match="callout">
  1070. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  1071. <fo:list-item id="{$id}">
  1072. <fo:list-item-label end-indent="label-end()">
  1073. <fo:block>
  1074. <xsl:call-template name="callout.arearefs">
  1075. <xsl:with-param name="arearefs" select="@arearefs"/>
  1076. </xsl:call-template>
  1077. </fo:block>
  1078. </fo:list-item-label>
  1079. <fo:list-item-body start-indent="body-start()">
  1080. <fo:block>
  1081. <xsl:apply-templates/>
  1082. </fo:block>
  1083. </fo:list-item-body>
  1084. </fo:list-item>
  1085. </xsl:template>
  1086. <xsl:template name="callout.arearefs">
  1087. <xsl:param name="arearefs"></xsl:param>
  1088. <xsl:if test="$arearefs!=''">
  1089. <xsl:choose>
  1090. <xsl:when test="substring-before($arearefs,' ')=''">
  1091. <xsl:call-template name="callout.arearef">
  1092. <xsl:with-param name="arearef" select="$arearefs"/>
  1093. </xsl:call-template>
  1094. </xsl:when>
  1095. <xsl:otherwise>
  1096. <xsl:call-template name="callout.arearef">
  1097. <xsl:with-param name="arearef"
  1098. select="substring-before($arearefs,' ')"/>
  1099. </xsl:call-template>
  1100. </xsl:otherwise>
  1101. </xsl:choose>
  1102. <xsl:call-template name="callout.arearefs">
  1103. <xsl:with-param name="arearefs"
  1104. select="substring-after($arearefs,' ')"/>
  1105. </xsl:call-template>
  1106. </xsl:if>
  1107. </xsl:template>
  1108. <xsl:template name="callout.arearef">
  1109. <xsl:param name="arearef"></xsl:param>
  1110. <xsl:variable name="targets" select="key('id',$arearef)"/>
  1111. <xsl:variable name="target" select="$targets[1]"/>
  1112. <xsl:choose>
  1113. <xsl:when test="count($target)=0">
  1114. <xsl:value-of select="$arearef"/>
  1115. <xsl:text>: ???</xsl:text>
  1116. </xsl:when>
  1117. <xsl:when test="local-name($target)='co'">
  1118. <xsl:apply-templates select="$target" mode="callout-bug"/>
  1119. </xsl:when>
  1120. <xsl:when test="local-name($target)='areaset'">
  1121. <xsl:call-template name="callout-bug">
  1122. <xsl:with-param name="conum">
  1123. <xsl:apply-templates select="$target" mode="conumber"/>
  1124. </xsl:with-param>
  1125. </xsl:call-template>
  1126. </xsl:when>
  1127. <xsl:when test="local-name($target)='area'">
  1128. <xsl:choose>
  1129. <xsl:when test="$target/parent::areaset">
  1130. <xsl:call-template name="callout-bug">
  1131. <xsl:with-param name="conum">
  1132. <xsl:apply-templates select="$target/parent::areaset"
  1133. mode="conumber"/>
  1134. </xsl:with-param>
  1135. </xsl:call-template>
  1136. </xsl:when>
  1137. <xsl:otherwise>
  1138. <xsl:call-template name="callout-bug">
  1139. <xsl:with-param name="conum">
  1140. <xsl:apply-templates select="$target" mode="conumber"/>
  1141. </xsl:with-param>
  1142. </xsl:call-template>
  1143. </xsl:otherwise>
  1144. </xsl:choose>
  1145. </xsl:when>
  1146. <xsl:otherwise>
  1147. <xsl:text>???</xsl:text>
  1148. </xsl:otherwise>
  1149. </xsl:choose>
  1150. </xsl:template>
  1151. <!-- ==================================================================== -->
  1152. </xsl:stylesheet>