lists.xsl 43 KB

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