lists.xsl 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374
  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: lists.xsl 9668 2012-11-28 00:47:59Z bobstayton $
  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="keep.together">
  18. <xsl:call-template name="pi.dbfo_keep-together"/>
  19. </xsl:variable>
  20. <xsl:variable name="pi-label-width">
  21. <xsl:call-template name="pi.dbfo_label-width"/>
  22. </xsl:variable>
  23. <xsl:variable name="label-width">
  24. <xsl:choose>
  25. <xsl:when test="$pi-label-width = ''">
  26. <xsl:value-of select="$itemizedlist.label.width"/>
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <xsl:value-of select="$pi-label-width"/>
  30. </xsl:otherwise>
  31. </xsl:choose>
  32. </xsl:variable>
  33. <xsl:if test="title">
  34. <xsl:apply-templates select="title" mode="list.title.mode"/>
  35. </xsl:if>
  36. <!-- Preserve order of PIs and comments -->
  37. <xsl:apply-templates
  38. select="*[not(self::listitem
  39. or self::title
  40. or self::titleabbrev)]
  41. |comment()[not(preceding-sibling::listitem)]
  42. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  43. <xsl:variable name="content">
  44. <xsl:apply-templates
  45. select="listitem
  46. |comment()[preceding-sibling::listitem]
  47. |processing-instruction()[preceding-sibling::listitem]"/>
  48. </xsl:variable>
  49. <!-- nested lists don't add extra list-block spacing -->
  50. <xsl:choose>
  51. <xsl:when test="ancestor::listitem">
  52. <fo:list-block id="{$id}" xsl:use-attribute-sets="itemizedlist.properties">
  53. <xsl:attribute name="provisional-distance-between-starts">
  54. <xsl:value-of select="$label-width"/>
  55. </xsl:attribute>
  56. <xsl:if test="$keep.together != ''">
  57. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  58. select="$keep.together"/></xsl:attribute>
  59. </xsl:if>
  60. <xsl:copy-of select="$content"/>
  61. </fo:list-block>
  62. </xsl:when>
  63. <xsl:otherwise>
  64. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing itemizedlist.properties">
  65. <xsl:attribute name="provisional-distance-between-starts">
  66. <xsl:value-of select="$label-width"/>
  67. </xsl:attribute>
  68. <xsl:if test="$keep.together != ''">
  69. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  70. select="$keep.together"/></xsl:attribute>
  71. </xsl:if>
  72. <xsl:copy-of select="$content"/>
  73. </fo:list-block>
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </xsl:template>
  77. <xsl:template match="itemizedlist/title|orderedlist/title">
  78. <!--nop-->
  79. </xsl:template>
  80. <xsl:template match="variablelist/title" mode="vl.as.list">
  81. <!--nop-->
  82. </xsl:template>
  83. <xsl:template match="variablelist/title" mode="vl.as.blocks">
  84. <!--nop-->
  85. </xsl:template>
  86. <xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
  87. <!--nop-->
  88. </xsl:template>
  89. <xsl:template match="procedure/titleabbrev">
  90. <!--nop-->
  91. </xsl:template>
  92. <xsl:template match="variablelist/titleabbrev" mode="vl.as.list">
  93. <!--nop-->
  94. </xsl:template>
  95. <xsl:template match="variablelist/titleabbrev" mode="vl.as.blocks">
  96. <!--nop-->
  97. </xsl:template>
  98. <xsl:template match="itemizedlist/listitem">
  99. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  100. <xsl:variable name="keep.together">
  101. <xsl:call-template name="pi.dbfo_keep-together"/>
  102. </xsl:variable>
  103. <xsl:variable name="item.contents">
  104. <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="itemizedlist.label.properties">
  105. <fo:block>
  106. <xsl:call-template name="itemizedlist.label.markup">
  107. <xsl:with-param name="itemsymbol">
  108. <xsl:call-template name="list.itemsymbol">
  109. <xsl:with-param name="node" select="parent::itemizedlist"/>
  110. </xsl:call-template>
  111. </xsl:with-param>
  112. </xsl:call-template>
  113. </fo:block>
  114. </fo:list-item-label>
  115. <fo:list-item-body start-indent="body-start()">
  116. <fo:block>
  117. <xsl:apply-templates/>
  118. </fo:block>
  119. </fo:list-item-body>
  120. </xsl:variable>
  121. <xsl:choose>
  122. <xsl:when test="parent::*/@spacing = 'compact'">
  123. <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
  124. <xsl:if test="$keep.together != ''">
  125. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  126. select="$keep.together"/></xsl:attribute>
  127. </xsl:if>
  128. <xsl:copy-of select="$item.contents"/>
  129. </fo:list-item>
  130. </xsl:when>
  131. <xsl:otherwise>
  132. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  133. <xsl:if test="$keep.together != ''">
  134. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  135. select="$keep.together"/></xsl:attribute>
  136. </xsl:if>
  137. <xsl:copy-of select="$item.contents"/>
  138. </fo:list-item>
  139. </xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:template>
  142. <xsl:template name="itemizedlist.label.markup">
  143. <xsl:param name="itemsymbol" select="'disc'"/>
  144. <xsl:choose>
  145. <xsl:when test="$itemsymbol='none'"></xsl:when>
  146. <xsl:when test="$itemsymbol='disc'">&#x2022;</xsl:when>
  147. <xsl:when test="$itemsymbol='bullet'">&#x2022;</xsl:when>
  148. <xsl:when test="$itemsymbol='endash'">&#x2013;</xsl:when>
  149. <xsl:when test="$itemsymbol='emdash'">&#x2014;</xsl:when>
  150. <!-- Some of these may work in your XSL-FO processor and fonts -->
  151. <!--
  152. <xsl:when test="$itemsymbol='square'">&#x25A0;</xsl:when>
  153. <xsl:when test="$itemsymbol='box'">&#x25A0;</xsl:when>
  154. <xsl:when test="$itemsymbol='smallblacksquare'">&#x25AA;</xsl:when>
  155. <xsl:when test="$itemsymbol='circle'">&#x25CB;</xsl:when>
  156. <xsl:when test="$itemsymbol='opencircle'">&#x25CB;</xsl:when>
  157. <xsl:when test="$itemsymbol='whitesquare'">&#x25A1;</xsl:when>
  158. <xsl:when test="$itemsymbol='smallwhitesquare'">&#x25AB;</xsl:when>
  159. <xsl:when test="$itemsymbol='round'">&#x25CF;</xsl:when>
  160. <xsl:when test="$itemsymbol='blackcircle'">&#x25CF;</xsl:when>
  161. <xsl:when test="$itemsymbol='whitebullet'">&#x25E6;</xsl:when>
  162. <xsl:when test="$itemsymbol='triangle'">&#x2023;</xsl:when>
  163. <xsl:when test="$itemsymbol='point'">&#x203A;</xsl:when>
  164. <xsl:when test="$itemsymbol='hand'"><fo:inline
  165. font-family="Wingdings 2">A</fo:inline></xsl:when>
  166. -->
  167. <xsl:otherwise>&#x2022;</xsl:otherwise>
  168. </xsl:choose>
  169. </xsl:template>
  170. <xsl:template match="orderedlist">
  171. <xsl:variable name="id">
  172. <xsl:call-template name="object.id"/>
  173. </xsl:variable>
  174. <xsl:variable name="pi-label-width">
  175. <xsl:call-template name="pi.dbfo_label-width"/>
  176. </xsl:variable>
  177. <xsl:variable name="label-width">
  178. <xsl:choose>
  179. <xsl:when test="$pi-label-width = ''">
  180. <xsl:value-of select="$orderedlist.label.width"/>
  181. </xsl:when>
  182. <xsl:otherwise>
  183. <xsl:value-of select="$pi-label-width"/>
  184. </xsl:otherwise>
  185. </xsl:choose>
  186. </xsl:variable>
  187. <xsl:variable name="keep.together">
  188. <xsl:call-template name="pi.dbfo_keep-together"/>
  189. </xsl:variable>
  190. <xsl:if test="title">
  191. <xsl:apply-templates select="title" mode="list.title.mode"/>
  192. </xsl:if>
  193. <!-- Preserve order of PIs and comments -->
  194. <xsl:apply-templates
  195. select="*[not(self::listitem
  196. or self::title
  197. or self::titleabbrev)]
  198. |comment()[not(preceding-sibling::listitem)]
  199. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  200. <xsl:variable name="content">
  201. <xsl:apply-templates
  202. select="listitem
  203. |comment()[preceding-sibling::listitem]
  204. |processing-instruction()[preceding-sibling::listitem]"/>
  205. </xsl:variable>
  206. <!-- nested lists don't add extra list-block spacing -->
  207. <xsl:choose>
  208. <xsl:when test="ancestor::listitem">
  209. <fo:list-block id="{$id}" xsl:use-attribute-sets="orderedlist.properties">
  210. <xsl:attribute name="provisional-distance-between-starts">
  211. <xsl:value-of select="$label-width"/>
  212. </xsl:attribute>
  213. <xsl:if test="$keep.together != ''">
  214. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  215. select="$keep.together"/></xsl:attribute>
  216. </xsl:if>
  217. <xsl:copy-of select="$content"/>
  218. </fo:list-block>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing orderedlist.properties">
  222. <xsl:attribute name="provisional-distance-between-starts">
  223. <xsl:value-of select="$label-width"/>
  224. </xsl:attribute>
  225. <xsl:if test="$keep.together != ''">
  226. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  227. select="$keep.together"/></xsl:attribute>
  228. </xsl:if>
  229. <xsl:copy-of select="$content"/>
  230. </fo:list-block>
  231. </xsl:otherwise>
  232. </xsl:choose>
  233. </xsl:template>
  234. <xsl:template match="orderedlist/listitem">
  235. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  236. <xsl:variable name="keep.together">
  237. <xsl:call-template name="pi.dbfo_keep-together"/>
  238. </xsl:variable>
  239. <xsl:variable name="item.contents">
  240. <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="orderedlist.label.properties">
  241. <fo:block>
  242. <xsl:apply-templates select="." mode="item-number"/>
  243. </fo:block>
  244. </fo:list-item-label>
  245. <fo:list-item-body start-indent="body-start()">
  246. <fo:block>
  247. <xsl:apply-templates/>
  248. </fo:block>
  249. </fo:list-item-body>
  250. </xsl:variable>
  251. <xsl:choose>
  252. <xsl:when test="parent::*/@spacing = 'compact'">
  253. <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
  254. <xsl:if test="$keep.together != ''">
  255. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  256. select="$keep.together"/></xsl:attribute>
  257. </xsl:if>
  258. <xsl:copy-of select="$item.contents"/>
  259. </fo:list-item>
  260. </xsl:when>
  261. <xsl:otherwise>
  262. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  263. <xsl:if test="$keep.together != ''">
  264. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  265. select="$keep.together"/></xsl:attribute>
  266. </xsl:if>
  267. <xsl:copy-of select="$item.contents"/>
  268. </fo:list-item>
  269. </xsl:otherwise>
  270. </xsl:choose>
  271. </xsl:template>
  272. <xsl:template match="listitem/*[1][local-name()='para' or
  273. local-name()='simpara' or
  274. local-name()='formalpara']
  275. |glossdef/*[1][local-name()='para' or
  276. local-name()='simpara' or
  277. local-name()='formalpara']
  278. |step/*[1][local-name()='para' or
  279. local-name()='simpara' or
  280. local-name()='formalpara']
  281. |callout/*[1][local-name()='para' or
  282. local-name()='simpara' or
  283. local-name()='formalpara']"
  284. priority="2">
  285. <fo:block>
  286. <xsl:call-template name="anchor"/>
  287. <xsl:apply-templates/>
  288. </fo:block>
  289. </xsl:template>
  290. <xsl:template match="variablelist">
  291. <xsl:variable name="presentation">
  292. <xsl:call-template name="pi.dbfo_list-presentation"/>
  293. </xsl:variable>
  294. <xsl:choose>
  295. <xsl:when test="$presentation = 'list'">
  296. <xsl:apply-templates select="." mode="vl.as.list"/>
  297. </xsl:when>
  298. <xsl:when test="$presentation = 'blocks'">
  299. <xsl:apply-templates select="." mode="vl.as.blocks"/>
  300. </xsl:when>
  301. <xsl:when test="$variablelist.as.blocks != 0">
  302. <xsl:apply-templates select="." mode="vl.as.blocks"/>
  303. </xsl:when>
  304. <xsl:otherwise>
  305. <xsl:apply-templates select="." mode="vl.as.list"/>
  306. </xsl:otherwise>
  307. </xsl:choose>
  308. </xsl:template>
  309. <xsl:template match="variablelist" mode="vl.as.list">
  310. <xsl:variable name="id">
  311. <xsl:call-template name="object.id"/>
  312. </xsl:variable>
  313. <xsl:variable name="keep.together">
  314. <xsl:call-template name="pi.dbfo_keep-together"/>
  315. </xsl:variable>
  316. <xsl:variable name="term-width">
  317. <xsl:call-template name="pi.dbfo_term-width"/>
  318. </xsl:variable>
  319. <xsl:variable name="termlength">
  320. <xsl:choose>
  321. <xsl:when test="$term-width != ''">
  322. <xsl:value-of select="$term-width"/>
  323. </xsl:when>
  324. <xsl:when test="@termlength">
  325. <xsl:variable name="termlength.is.number">
  326. <xsl:value-of select="@termlength + 0"/>
  327. </xsl:variable>
  328. <xsl:choose>
  329. <xsl:when test="string($termlength.is.number) = 'NaN'">
  330. <!-- if the term length isn't just a number, assume it's a measurement -->
  331. <xsl:value-of select="@termlength"/>
  332. </xsl:when>
  333. <xsl:otherwise>
  334. <xsl:value-of select="@termlength"/>
  335. <xsl:text>em * 0.60</xsl:text>
  336. </xsl:otherwise>
  337. </xsl:choose>
  338. </xsl:when>
  339. <xsl:otherwise>
  340. <xsl:call-template name="longest.term">
  341. <xsl:with-param name="terms" select="varlistentry/term"/>
  342. <xsl:with-param name="maxlength" select="$variablelist.max.termlength"/>
  343. </xsl:call-template>
  344. <xsl:text>em * 0.60</xsl:text>
  345. </xsl:otherwise>
  346. </xsl:choose>
  347. </xsl:variable>
  348. <!--
  349. <xsl:message>
  350. <xsl:text>term width: </xsl:text>
  351. <xsl:value-of select="$termlength"/>
  352. </xsl:message>
  353. -->
  354. <xsl:variable name="label-separation">1em</xsl:variable>
  355. <xsl:variable name="distance-between-starts">
  356. <xsl:value-of select="$termlength"/>
  357. <xsl:text>+</xsl:text>
  358. <xsl:value-of select="$label-separation"/>
  359. </xsl:variable>
  360. <xsl:if test="title">
  361. <xsl:apply-templates select="title" mode="list.title.mode"/>
  362. </xsl:if>
  363. <!-- Preserve order of PIs and comments -->
  364. <xsl:apply-templates
  365. select="*[not(self::varlistentry
  366. or self::title
  367. or self::titleabbrev)]
  368. |comment()[not(preceding-sibling::varlistentry)]
  369. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  370. <xsl:variable name="content">
  371. <xsl:apply-templates mode="vl.as.list"
  372. select="varlistentry
  373. |comment()[preceding-sibling::varlistentry]
  374. |processing-instruction()[preceding-sibling::varlistentry]"/>
  375. </xsl:variable>
  376. <!-- nested lists don't add extra list-block spacing -->
  377. <xsl:choose>
  378. <xsl:when test="ancestor::listitem">
  379. <fo:list-block id="{$id}"
  380. provisional-distance-between-starts=
  381. "{$distance-between-starts}"
  382. provisional-label-separation="{$label-separation}">
  383. <xsl:if test="$keep.together != ''">
  384. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  385. select="$keep.together"/></xsl:attribute>
  386. </xsl:if>
  387. <xsl:copy-of select="$content"/>
  388. </fo:list-block>
  389. </xsl:when>
  390. <xsl:otherwise>
  391. <fo:list-block id="{$id}"
  392. provisional-distance-between-starts=
  393. "{$distance-between-starts}"
  394. provisional-label-separation="{$label-separation}"
  395. xsl:use-attribute-sets="list.block.spacing">
  396. <xsl:if test="$keep.together != ''">
  397. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  398. select="$keep.together"/></xsl:attribute>
  399. </xsl:if>
  400. <xsl:copy-of select="$content"/>
  401. </fo:list-block>
  402. </xsl:otherwise>
  403. </xsl:choose>
  404. </xsl:template>
  405. <xsl:template name="longest.term">
  406. <xsl:param name="longest" select="0"/>
  407. <xsl:param name="terms" select="."/>
  408. <xsl:param name="maxlength" select="-1"/>
  409. <!-- Process out any indexterms in the term -->
  410. <xsl:variable name="term.text">
  411. <xsl:apply-templates select="$terms[1]"/>
  412. </xsl:variable>
  413. <xsl:choose>
  414. <xsl:when test="$longest &gt; $maxlength and $maxlength &gt; 0">
  415. <xsl:value-of select="$maxlength"/>
  416. </xsl:when>
  417. <xsl:when test="not($terms)">
  418. <xsl:value-of select="$longest"/>
  419. </xsl:when>
  420. <xsl:when test="string-length($term.text) &gt; $longest">
  421. <xsl:call-template name="longest.term">
  422. <xsl:with-param name="longest"
  423. select="string-length($term.text)"/>
  424. <xsl:with-param name="maxlength" select="$maxlength"/>
  425. <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
  426. </xsl:call-template>
  427. </xsl:when>
  428. <xsl:otherwise>
  429. <xsl:call-template name="longest.term">
  430. <xsl:with-param name="longest" select="$longest"/>
  431. <xsl:with-param name="maxlength" select="$maxlength"/>
  432. <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
  433. </xsl:call-template>
  434. </xsl:otherwise>
  435. </xsl:choose>
  436. </xsl:template>
  437. <xsl:template match="varlistentry" mode="vl.as.list">
  438. <xsl:variable name="id">
  439. <xsl:call-template name="object.id"/>
  440. </xsl:variable>
  441. <xsl:variable name="keep.together">
  442. <xsl:call-template name="pi.dbfo_keep-together"/>
  443. </xsl:variable>
  444. <xsl:variable name="item.contents">
  445. <fo:list-item-label end-indent="label-end()" text-align="start">
  446. <fo:block xsl:use-attribute-sets="variablelist.term.properties">
  447. <xsl:apply-templates select="term"/>
  448. </fo:block>
  449. </fo:list-item-label>
  450. <fo:list-item-body start-indent="body-start()">
  451. <fo:block>
  452. <xsl:apply-templates select="listitem"/>
  453. </fo:block>
  454. </fo:list-item-body>
  455. </xsl:variable>
  456. <xsl:choose>
  457. <xsl:when test="parent::*/@spacing = 'compact'">
  458. <fo:list-item id="{$id}"
  459. xsl:use-attribute-sets="compact.list.item.spacing">
  460. <xsl:if test="$keep.together != ''">
  461. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  462. select="$keep.together"/></xsl:attribute>
  463. </xsl:if>
  464. <xsl:copy-of select="$item.contents"/>
  465. </fo:list-item>
  466. </xsl:when>
  467. <xsl:otherwise>
  468. <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
  469. <xsl:if test="$keep.together != ''">
  470. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  471. select="$keep.together"/></xsl:attribute>
  472. </xsl:if>
  473. <xsl:copy-of select="$item.contents"/>
  474. </fo:list-item>
  475. </xsl:otherwise>
  476. </xsl:choose>
  477. </xsl:template>
  478. <xsl:template match="variablelist" mode="vl.as.blocks">
  479. <xsl:variable name="id">
  480. <xsl:call-template name="object.id"/>
  481. </xsl:variable>
  482. <!-- termlength is irrelevant -->
  483. <xsl:if test="title">
  484. <xsl:apply-templates select="title" mode="list.title.mode"/>
  485. </xsl:if>
  486. <!-- Preserve order of PIs and comments -->
  487. <xsl:apply-templates
  488. select="*[not(self::varlistentry
  489. or self::title
  490. or self::titleabbrev)]
  491. |comment()[not(preceding-sibling::varlistentry)]
  492. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  493. <xsl:variable name="content">
  494. <xsl:apply-templates mode="vl.as.blocks"
  495. select="varlistentry
  496. |comment()[preceding-sibling::varlistentry]
  497. |processing-instruction()[preceding-sibling::varlistentry]"/>
  498. </xsl:variable>
  499. <!-- nested lists don't add extra list-block spacing -->
  500. <xsl:choose>
  501. <xsl:when test="ancestor::listitem">
  502. <fo:block id="{$id}">
  503. <xsl:copy-of select="$content"/>
  504. </fo:block>
  505. </xsl:when>
  506. <xsl:otherwise>
  507. <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
  508. <xsl:copy-of select="$content"/>
  509. </fo:block>
  510. </xsl:otherwise>
  511. </xsl:choose>
  512. </xsl:template>
  513. <xsl:template match="varlistentry" mode="vl.as.blocks">
  514. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  515. <fo:block id="{$id}" xsl:use-attribute-sets="variablelist.term.properties
  516. list.item.spacing"
  517. keep-together.within-column="always"
  518. keep-with-next.within-column="always">
  519. <xsl:apply-templates select="term"/>
  520. </fo:block>
  521. <fo:block>
  522. <xsl:attribute name="margin-{$direction.align.start}">0.25in</xsl:attribute>
  523. <xsl:apply-templates select="listitem"/>
  524. </fo:block>
  525. </xsl:template>
  526. <xsl:template match="varlistentry/term">
  527. <fo:inline>
  528. <xsl:call-template name="simple.xlink">
  529. <xsl:with-param name="content">
  530. <xsl:apply-templates/>
  531. </xsl:with-param>
  532. </xsl:call-template>
  533. </fo:inline>
  534. <xsl:choose>
  535. <xsl:when test="not(following-sibling::term)"/> <!-- do nothing -->
  536. <xsl:otherwise>
  537. <!-- * if we have multiple terms in the same varlistentry, generate -->
  538. <!-- * a separator (", " by default) and/or an additional line -->
  539. <!-- * break after each one except the last -->
  540. <fo:inline><xsl:value-of select="$variablelist.term.separator"/></fo:inline>
  541. <xsl:if test="not($variablelist.term.break.after = '0')">
  542. <fo:block/>
  543. </xsl:if>
  544. </xsl:otherwise>
  545. </xsl:choose>
  546. </xsl:template>
  547. <xsl:template match="varlistentry/listitem">
  548. <xsl:apply-templates/>
  549. </xsl:template>
  550. <!-- ==================================================================== -->
  551. <xsl:template match="title" mode="list.title.mode">
  552. <xsl:call-template name="formal.object.heading">
  553. <xsl:with-param name="object" select=".."/>
  554. </xsl:call-template>
  555. </xsl:template>
  556. <!-- ==================================================================== -->
  557. <xsl:template match="simplelist|simplelist[@type='vert']">
  558. <!-- with no type specified, the default is 'vert' -->
  559. <xsl:variable name="id">
  560. <xsl:call-template name="object.id"/>
  561. </xsl:variable>
  562. <xsl:variable name="explicit.table.width">
  563. <xsl:call-template name="dbfo-attribute">
  564. <xsl:with-param name="pis"
  565. select="processing-instruction('dbfo')"/>
  566. <xsl:with-param name="attribute" select="'list-width'"/>
  567. </xsl:call-template>
  568. </xsl:variable>
  569. <xsl:variable name="table.width">
  570. <xsl:choose>
  571. <xsl:when test="$explicit.table.width != ''">
  572. <xsl:value-of select="$explicit.table.width"/>
  573. </xsl:when>
  574. <xsl:when test="$default.table.width = ''">
  575. <xsl:text>100%</xsl:text>
  576. </xsl:when>
  577. <xsl:otherwise>
  578. <xsl:value-of select="$default.table.width"/>
  579. </xsl:otherwise>
  580. </xsl:choose>
  581. </xsl:variable>
  582. <fo:table id="{$id}" xsl:use-attribute-sets="normal.para.spacing">
  583. <xsl:choose>
  584. <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
  585. <xsl:attribute name="table-layout">auto</xsl:attribute>
  586. <xsl:if test="$explicit.table.width != ''">
  587. <xsl:attribute name="width"><xsl:value-of
  588. select="$explicit.table.width"/></xsl:attribute>
  589. </xsl:if>
  590. </xsl:when>
  591. <xsl:otherwise>
  592. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  593. <xsl:attribute name="width"><xsl:value-of
  594. select="$table.width"/></xsl:attribute>
  595. </xsl:otherwise>
  596. </xsl:choose>
  597. <xsl:call-template name="simplelist.table.columns">
  598. <xsl:with-param name="cols">
  599. <xsl:choose>
  600. <xsl:when test="@columns">
  601. <xsl:value-of select="@columns"/>
  602. </xsl:when>
  603. <xsl:otherwise>1</xsl:otherwise>
  604. </xsl:choose>
  605. </xsl:with-param>
  606. </xsl:call-template>
  607. <fo:table-body start-indent="0pt" end-indent="0pt">
  608. <xsl:call-template name="simplelist.vert">
  609. <xsl:with-param name="cols">
  610. <xsl:choose>
  611. <xsl:when test="@columns">
  612. <xsl:value-of select="@columns"/>
  613. </xsl:when>
  614. <xsl:otherwise>1</xsl:otherwise>
  615. </xsl:choose>
  616. </xsl:with-param>
  617. </xsl:call-template>
  618. </fo:table-body>
  619. </fo:table>
  620. </xsl:template>
  621. <xsl:template match="simplelist[@type='inline']">
  622. <!-- if dbchoice PI exists, use that to determine the choice separator -->
  623. <!-- (that is, equivalent of "and" or "or" in current locale), or literal -->
  624. <!-- value of "choice" otherwise -->
  625. <xsl:variable name="id">
  626. <xsl:call-template name="object.id"/>
  627. </xsl:variable>
  628. <fo:inline id="{$id}"><xsl:variable name="localized-choice-separator">
  629. <xsl:choose>
  630. <xsl:when test="processing-instruction('dbchoice')">
  631. <xsl:call-template name="select.choice.separator"/>
  632. </xsl:when>
  633. <xsl:otherwise>
  634. <!-- empty -->
  635. </xsl:otherwise>
  636. </xsl:choose>
  637. </xsl:variable>
  638. <xsl:for-each select="member">
  639. <xsl:apply-templates/>
  640. <xsl:choose>
  641. <xsl:when test="position() = last()"/> <!-- do nothing -->
  642. <xsl:otherwise>
  643. <xsl:text>, </xsl:text>
  644. <xsl:if test="position() = last() - 1">
  645. <xsl:if test="$localized-choice-separator != ''">
  646. <xsl:value-of select="$localized-choice-separator"/>
  647. <xsl:text> </xsl:text>
  648. </xsl:if>
  649. </xsl:if>
  650. </xsl:otherwise>
  651. </xsl:choose>
  652. </xsl:for-each></fo:inline>
  653. </xsl:template>
  654. <xsl:template match="simplelist[@type='horiz']">
  655. <xsl:variable name="id">
  656. <xsl:call-template name="object.id"/>
  657. </xsl:variable>
  658. <xsl:variable name="explicit.table.width">
  659. <xsl:call-template name="pi.dbfo_list-width"/>
  660. </xsl:variable>
  661. <xsl:variable name="table.width">
  662. <xsl:choose>
  663. <xsl:when test="$explicit.table.width != ''">
  664. <xsl:value-of select="$explicit.table.width"/>
  665. </xsl:when>
  666. <xsl:when test="$default.table.width = ''">
  667. <xsl:text>100%</xsl:text>
  668. </xsl:when>
  669. <xsl:otherwise>
  670. <xsl:value-of select="$default.table.width"/>
  671. </xsl:otherwise>
  672. </xsl:choose>
  673. </xsl:variable>
  674. <fo:table id="{$id}" xsl:use-attribute-sets="normal.para.spacing">
  675. <xsl:choose>
  676. <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
  677. <xsl:attribute name="table-layout">auto</xsl:attribute>
  678. <xsl:if test="$explicit.table.width != ''">
  679. <xsl:attribute name="width"><xsl:value-of
  680. select="$explicit.table.width"/></xsl:attribute>
  681. </xsl:if>
  682. </xsl:when>
  683. <xsl:otherwise>
  684. <xsl:attribute name="table-layout">fixed</xsl:attribute>
  685. <xsl:attribute name="width"><xsl:value-of
  686. select="$table.width"/></xsl:attribute>
  687. </xsl:otherwise>
  688. </xsl:choose>
  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.horiz">
  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. <xsl:variable name="keep.together">
  881. <xsl:call-template name="pi.dbfo_keep-together"/>
  882. </xsl:variable>
  883. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  884. <xsl:if test="$keep.together != ''">
  885. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  886. select="$keep.together"/></xsl:attribute>
  887. </xsl:if>
  888. <fo:list-item-label end-indent="label-end()">
  889. <fo:block id="{$id}">
  890. <!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
  891. <xsl:choose>
  892. <xsl:when test="count(../step) = 1">
  893. <xsl:text>&#x2022;</xsl:text>
  894. </xsl:when>
  895. <xsl:otherwise>
  896. <xsl:apply-templates select="." mode="number">
  897. <xsl:with-param name="recursive" select="0"/>
  898. </xsl:apply-templates>.
  899. </xsl:otherwise>
  900. </xsl:choose>
  901. </fo:block>
  902. </fo:list-item-label>
  903. <fo:list-item-body start-indent="body-start()">
  904. <fo:block>
  905. <xsl:apply-templates/>
  906. </fo:block>
  907. </fo:list-item-body>
  908. </fo:list-item>
  909. </xsl:template>
  910. <xsl:template match="stepalternatives">
  911. <fo:list-block provisional-distance-between-starts="2em"
  912. provisional-label-separation="0.2em">
  913. <xsl:apply-templates select="step"/>
  914. </fo:list-block>
  915. </xsl:template>
  916. <xsl:template match="stepalternatives/step">
  917. <xsl:variable name="id">
  918. <xsl:call-template name="object.id"/>
  919. </xsl:variable>
  920. <xsl:variable name="keep.together">
  921. <xsl:call-template name="pi.dbfo_keep-together"/>
  922. </xsl:variable>
  923. <fo:list-item xsl:use-attribute-sets="list.item.spacing">
  924. <xsl:if test="$keep.together != ''">
  925. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  926. select="$keep.together"/></xsl:attribute>
  927. </xsl:if>
  928. <fo:list-item-label end-indent="label-end()">
  929. <fo:block id="{$id}">
  930. <xsl:text>&#x2022;</xsl:text>
  931. </fo:block>
  932. </fo:list-item-label>
  933. <fo:list-item-body start-indent="body-start()">
  934. <fo:block>
  935. <xsl:apply-templates/>
  936. </fo:block>
  937. </fo:list-item-body>
  938. </fo:list-item>
  939. </xsl:template>
  940. <xsl:template match="step/title">
  941. <fo:block font-weight="bold"
  942. keep-together.within-column="always"
  943. keep-with-next.within-column="always">
  944. <xsl:apply-templates/>
  945. </fo:block>
  946. </xsl:template>
  947. <!-- ==================================================================== -->
  948. <xsl:template match="segmentedlist">
  949. <xsl:variable name="presentation">
  950. <xsl:call-template name="pi.dbfo_list-presentation"/>
  951. </xsl:variable>
  952. <xsl:variable name="keep.together">
  953. <xsl:call-template name="pi.dbfo_keep-together"/>
  954. </xsl:variable>
  955. <xsl:variable name="id">
  956. <xsl:call-template name="object.id"/>
  957. </xsl:variable>
  958. <xsl:choose>
  959. <xsl:when test="$presentation = 'table'">
  960. <fo:block id="{$id}">
  961. <xsl:if test="$keep.together != ''">
  962. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  963. select="$keep.together"/></xsl:attribute>
  964. </xsl:if>
  965. <xsl:apply-templates select="." mode="seglist-table"/>
  966. </fo:block>
  967. </xsl:when>
  968. <xsl:when test="$presentation = 'list'">
  969. <fo:block id="{$id}">
  970. <xsl:if test="$keep.together != ''">
  971. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  972. select="$keep.together"/></xsl:attribute>
  973. </xsl:if>
  974. <xsl:apply-templates/>
  975. </fo:block>
  976. </xsl:when>
  977. <xsl:when test="$segmentedlist.as.table != 0">
  978. <fo:block id="{$id}">
  979. <xsl:if test="$keep.together != ''">
  980. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  981. select="$keep.together"/></xsl:attribute>
  982. </xsl:if>
  983. <xsl:apply-templates select="." mode="seglist-table"/>
  984. </fo:block>
  985. </xsl:when>
  986. <xsl:otherwise>
  987. <fo:block id="{$id}">
  988. <xsl:if test="$keep.together != ''">
  989. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  990. select="$keep.together"/></xsl:attribute>
  991. </xsl:if>
  992. <xsl:apply-templates/>
  993. </fo:block>
  994. </xsl:otherwise>
  995. </xsl:choose>
  996. </xsl:template>
  997. <xsl:template match="segmentedlist/title">
  998. <xsl:apply-templates select="." mode="list.title.mode" />
  999. </xsl:template>
  1000. <xsl:template match="segtitle">
  1001. </xsl:template>
  1002. <xsl:template match="segtitle" mode="segtitle-in-seg">
  1003. <xsl:apply-templates/>
  1004. </xsl:template>
  1005. <xsl:template match="seglistitem">
  1006. <xsl:variable name="id">
  1007. <xsl:call-template name="object.id"/>
  1008. </xsl:variable>
  1009. <fo:block id="{$id}">
  1010. <xsl:apply-templates/>
  1011. </fo:block>
  1012. </xsl:template>
  1013. <xsl:template match="seg">
  1014. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  1015. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  1016. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  1017. <!--
  1018. Note: segtitle is only going to be the right thing in a well formed
  1019. SegmentedList. If there are too many Segs or too few SegTitles,
  1020. you'll get something odd...maybe an error
  1021. -->
  1022. <fo:block>
  1023. <fo:inline font-weight="bold">
  1024. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  1025. mode="segtitle-in-seg"/>
  1026. <xsl:text>: </xsl:text>
  1027. </fo:inline>
  1028. <xsl:apply-templates/>
  1029. </fo:block>
  1030. </xsl:template>
  1031. <xsl:template match="segmentedlist" mode="seglist-table">
  1032. <xsl:apply-templates select="title" mode="list.title.mode" />
  1033. <fo:table table-layout="fixed">
  1034. <xsl:call-template name="segmentedlist.table.columns">
  1035. <xsl:with-param name="cols" select="count(segtitle)"/>
  1036. </xsl:call-template>
  1037. <fo:table-header start-indent="0pt" end-indent="0pt">
  1038. <fo:table-row>
  1039. <xsl:apply-templates select="segtitle" mode="seglist-table"/>
  1040. </fo:table-row>
  1041. </fo:table-header>
  1042. <fo:table-body start-indent="0pt" end-indent="0pt">
  1043. <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
  1044. </fo:table-body>
  1045. </fo:table>
  1046. </xsl:template>
  1047. <xsl:template name="segmentedlist.table.columns">
  1048. <xsl:param name="cols" select="1"/>
  1049. <xsl:param name="curcol" select="1"/>
  1050. <fo:table-column column-number="{$curcol}"
  1051. column-width="proportional-column-width(1)"/>
  1052. <xsl:if test="$curcol &lt; $cols">
  1053. <xsl:call-template name="segmentedlist.table.columns">
  1054. <xsl:with-param name="cols" select="$cols"/>
  1055. <xsl:with-param name="curcol" select="$curcol+1"/>
  1056. </xsl:call-template>
  1057. </xsl:if>
  1058. </xsl:template>
  1059. <xsl:template match="segtitle" mode="seglist-table">
  1060. <fo:table-cell>
  1061. <fo:block font-weight="bold">
  1062. <xsl:apply-templates/>
  1063. </fo:block>
  1064. </fo:table-cell>
  1065. </xsl:template>
  1066. <xsl:template match="seglistitem" mode="seglist-table">
  1067. <xsl:variable name="id">
  1068. <xsl:call-template name="object.id"/>
  1069. </xsl:variable>
  1070. <fo:table-row id="{$id}">
  1071. <xsl:apply-templates mode="seglist-table"/>
  1072. </fo:table-row>
  1073. </xsl:template>
  1074. <xsl:template match="seg" mode="seglist-table">
  1075. <fo:table-cell>
  1076. <fo:block>
  1077. <xsl:apply-templates/>
  1078. </fo:block>
  1079. </fo:table-cell>
  1080. </xsl:template>
  1081. <!-- ==================================================================== -->
  1082. <xsl:template match="calloutlist">
  1083. <xsl:variable name="id">
  1084. <xsl:call-template name="object.id"/>
  1085. </xsl:variable>
  1086. <xsl:variable name="pi-label-width">
  1087. <xsl:call-template name="pi.dbfo_label-width"/>
  1088. </xsl:variable>
  1089. <fo:block id="{$id}"
  1090. text-align="{$alignment}">
  1091. <!-- The above restores alignment altered by image align attribute -->
  1092. <xsl:if test="title|info/title">
  1093. <xsl:apply-templates select="(title|info/title)[1]"
  1094. mode="list.title.mode"/>
  1095. </xsl:if>
  1096. <!-- Preserve order of PIs and comments -->
  1097. <xsl:apply-templates
  1098. select="*[not(self::callout or self::title or self::titleabbrev)]
  1099. |comment()[not(preceding-sibling::callout)]
  1100. |processing-instruction()[not(preceding-sibling::callout)]"/>
  1101. <fo:list-block xsl:use-attribute-sets="calloutlist.properties">
  1102. <xsl:if test="$pi-label-width != ''">
  1103. <xsl:attribute name="provisional-distance-between-starts">
  1104. <xsl:value-of select="$pi-label-width"/>
  1105. </xsl:attribute>
  1106. </xsl:if>
  1107. <xsl:apply-templates select="callout
  1108. |comment()[preceding-sibling::callout]
  1109. |processing-instruction()[preceding-sibling::callout]"/>
  1110. </fo:list-block>
  1111. </fo:block>
  1112. </xsl:template>
  1113. <xsl:template match="calloutlist/title">
  1114. </xsl:template>
  1115. <xsl:template match="callout">
  1116. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  1117. <xsl:variable name="keep.together">
  1118. <xsl:call-template name="pi.dbfo_keep-together"/>
  1119. </xsl:variable>
  1120. <fo:list-item id="{$id}" xsl:use-attribute-sets="callout.properties">
  1121. <xsl:if test="$keep.together != ''">
  1122. <xsl:attribute name="keep-together.within-column"><xsl:value-of
  1123. select="$keep.together"/></xsl:attribute>
  1124. </xsl:if>
  1125. <fo:list-item-label end-indent="label-end()">
  1126. <fo:block>
  1127. <xsl:call-template name="callout.arearefs">
  1128. <xsl:with-param name="arearefs" select="@arearefs"/>
  1129. </xsl:call-template>
  1130. </fo:block>
  1131. </fo:list-item-label>
  1132. <fo:list-item-body start-indent="body-start()">
  1133. <fo:block>
  1134. <xsl:apply-templates/>
  1135. </fo:block>
  1136. </fo:list-item-body>
  1137. </fo:list-item>
  1138. </xsl:template>
  1139. <xsl:template name="callout.arearefs">
  1140. <xsl:param name="arearefs"></xsl:param>
  1141. <xsl:if test="$arearefs!=''">
  1142. <xsl:choose>
  1143. <xsl:when test="substring-before($arearefs,' ')=''">
  1144. <xsl:call-template name="callout.arearef">
  1145. <xsl:with-param name="arearef" select="$arearefs"/>
  1146. </xsl:call-template>
  1147. </xsl:when>
  1148. <xsl:otherwise>
  1149. <xsl:call-template name="callout.arearef">
  1150. <xsl:with-param name="arearef"
  1151. select="substring-before($arearefs,' ')"/>
  1152. </xsl:call-template>
  1153. </xsl:otherwise>
  1154. </xsl:choose>
  1155. <xsl:call-template name="callout.arearefs">
  1156. <xsl:with-param name="arearefs"
  1157. select="substring-after($arearefs,' ')"/>
  1158. </xsl:call-template>
  1159. </xsl:if>
  1160. </xsl:template>
  1161. <xsl:template name="callout.arearef">
  1162. <xsl:param name="arearef"></xsl:param>
  1163. <xsl:variable name="targets" select="key('id',$arearef)"/>
  1164. <xsl:variable name="target" select="$targets[1]"/>
  1165. <xsl:choose>
  1166. <xsl:when test="count($target)=0">
  1167. <xsl:value-of select="$arearef"/>
  1168. <xsl:text>: ???</xsl:text>
  1169. </xsl:when>
  1170. <xsl:when test="local-name($target)='co'">
  1171. <fo:basic-link internal-destination="{$arearef}">
  1172. <xsl:apply-templates select="$target" mode="callout-bug"/>
  1173. </fo:basic-link>
  1174. </xsl:when>
  1175. <xsl:when test="local-name($target)='areaset'">
  1176. <xsl:call-template name="callout-bug">
  1177. <xsl:with-param name="conum">
  1178. <xsl:apply-templates select="$target" mode="conumber"/>
  1179. </xsl:with-param>
  1180. </xsl:call-template>
  1181. </xsl:when>
  1182. <xsl:when test="local-name($target)='area'">
  1183. <xsl:choose>
  1184. <xsl:when test="$target/parent::areaset">
  1185. <xsl:call-template name="callout-bug">
  1186. <xsl:with-param name="conum">
  1187. <xsl:apply-templates select="$target/parent::areaset"
  1188. mode="conumber"/>
  1189. </xsl:with-param>
  1190. </xsl:call-template>
  1191. </xsl:when>
  1192. <xsl:otherwise>
  1193. <xsl:call-template name="callout-bug">
  1194. <xsl:with-param name="conum">
  1195. <xsl:apply-templates select="$target" mode="conumber"/>
  1196. </xsl:with-param>
  1197. </xsl:call-template>
  1198. </xsl:otherwise>
  1199. </xsl:choose>
  1200. </xsl:when>
  1201. <xsl:otherwise>
  1202. <xsl:text>???</xsl:text>
  1203. </xsl:otherwise>
  1204. </xsl:choose>
  1205. </xsl:template>
  1206. <!-- ==================================================================== -->
  1207. <xsl:template name="orderedlist-starting-number">
  1208. <xsl:param name="list" select="."/>
  1209. <xsl:variable name="pi-start">
  1210. <xsl:call-template name="pi.dbfo_start">
  1211. <xsl:with-param name="node" select="$list"/>
  1212. </xsl:call-template>
  1213. </xsl:variable>
  1214. <xsl:call-template name="output-orderedlist-starting-number">
  1215. <xsl:with-param name="list" select="$list"/>
  1216. <xsl:with-param name="pi-start" select="$pi-start"/>
  1217. </xsl:call-template>
  1218. </xsl:template>
  1219. </xsl:stylesheet>