lists.xsl 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version='1.0'>
  4. <!-- ********************************************************************
  5. $Id: lists.xsl,v 1.1.1.1 2011-08-27 15:30:16 cmaier Exp $
  6. ********************************************************************
  7. This file is part of the XSL DocBook Stylesheet distribution.
  8. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  9. and other information.
  10. ******************************************************************** -->
  11. <!-- ==================================================================== -->
  12. <xsl:template match="itemizedlist">
  13. <div class="{name(.)}">
  14. <xsl:call-template name="anchor"/>
  15. <xsl:if test="title">
  16. <xsl:call-template name="formal.object.heading"/>
  17. </xsl:if>
  18. <!-- Preserve order of PIs and comments -->
  19. <xsl:apply-templates
  20. select="*[not(self::listitem
  21. or self::title
  22. or self::titleabbrev)]
  23. |comment()[not(preceding-sibling::listitem)]
  24. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  25. <ul>
  26. <xsl:if test="$css.decoration != 0">
  27. <xsl:attribute name="type">
  28. <xsl:call-template name="list.itemsymbol"/>
  29. </xsl:attribute>
  30. </xsl:if>
  31. <xsl:if test="@spacing='compact'">
  32. <xsl:attribute name="compact">
  33. <xsl:value-of select="@spacing"/>
  34. </xsl:attribute>
  35. </xsl:if>
  36. <xsl:apply-templates
  37. select="listitem
  38. |comment()[preceding-sibling::listitem]
  39. |processing-instruction()[preceding-sibling::listitem]"/>
  40. </ul>
  41. </div>
  42. </xsl:template>
  43. <xsl:template match="itemizedlist/title">
  44. <!-- nop -->
  45. </xsl:template>
  46. <xsl:template match="itemizedlist/listitem">
  47. <xsl:variable name="mark" select="../@mark"/>
  48. <xsl:variable name="override" select="@override"/>
  49. <xsl:variable name="usemark">
  50. <xsl:choose>
  51. <xsl:when test="$override != ''">
  52. <xsl:value-of select="$override"/>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <xsl:value-of select="$mark"/>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:variable>
  59. <xsl:variable name="cssmark">
  60. <xsl:choose>
  61. <xsl:when test="$usemark = 'opencircle'">circle</xsl:when>
  62. <xsl:when test="$usemark = 'bullet'">disc</xsl:when>
  63. <xsl:when test="$usemark = 'box'">square</xsl:when>
  64. <xsl:otherwise>
  65. <xsl:value-of select="$usemark"/>
  66. </xsl:otherwise>
  67. </xsl:choose>
  68. </xsl:variable>
  69. <li>
  70. <xsl:if test="$css.decoration = '1' and $cssmark != ''">
  71. <xsl:attribute name="style">
  72. <xsl:text>list-style-type: </xsl:text>
  73. <xsl:value-of select="$cssmark"/>
  74. </xsl:attribute>
  75. </xsl:if>
  76. <!-- we can't just drop the anchor in since some browsers (Opera)
  77. get confused about line breaks if we do. So if the first child
  78. is a para, assume the para will put in the anchor. Otherwise,
  79. put the anchor in anyway. -->
  80. <xsl:if test="local-name(child::*[1]) != 'para'">
  81. <xsl:call-template name="anchor"/>
  82. </xsl:if>
  83. <xsl:choose>
  84. <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  85. <div class="{@revisionflag}">
  86. <xsl:apply-templates/>
  87. </div>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <xsl:apply-templates/>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </li>
  94. </xsl:template>
  95. <xsl:template match="orderedlist">
  96. <xsl:variable name="pi-start">
  97. <xsl:call-template name="dbhtml-attribute">
  98. <xsl:with-param name="pis"
  99. select="processing-instruction('dbhtml')"/>
  100. <xsl:with-param name="attribute" select="'start'"/>
  101. </xsl:call-template>
  102. </xsl:variable>
  103. <xsl:variable name="start">
  104. <xsl:choose>
  105. <xsl:when test="@continuation='continues'">
  106. <xsl:call-template name="orderedlist-starting-number"/>
  107. </xsl:when>
  108. <xsl:when test="$pi-start != ''">
  109. <xsl:value-of select="$pi-start"/>
  110. </xsl:when>
  111. <xsl:otherwise>1</xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:variable>
  114. <xsl:variable name="numeration">
  115. <xsl:call-template name="list.numeration"/>
  116. </xsl:variable>
  117. <xsl:variable name="type">
  118. <xsl:choose>
  119. <xsl:when test="$numeration='arabic'">1</xsl:when>
  120. <xsl:when test="$numeration='loweralpha'">a</xsl:when>
  121. <xsl:when test="$numeration='lowerroman'">i</xsl:when>
  122. <xsl:when test="$numeration='upperalpha'">A</xsl:when>
  123. <xsl:when test="$numeration='upperroman'">I</xsl:when>
  124. <!-- What!? This should never happen -->
  125. <xsl:otherwise>
  126. <xsl:message>
  127. <xsl:text>Unexpected numeration: </xsl:text>
  128. <xsl:value-of select="$numeration"/>
  129. </xsl:message>
  130. <xsl:value-of select="1"/>
  131. </xsl:otherwise>
  132. </xsl:choose>
  133. </xsl:variable>
  134. <div class="{name(.)}">
  135. <xsl:call-template name="anchor"/>
  136. <xsl:if test="title">
  137. <xsl:call-template name="formal.object.heading"/>
  138. </xsl:if>
  139. <!-- Preserve order of PIs and comments -->
  140. <xsl:apply-templates
  141. select="*[not(self::listitem
  142. or self::title
  143. or self::titleabbrev)]
  144. |comment()[not(preceding-sibling::listitem)]
  145. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  146. <ol>
  147. <xsl:if test="$start != '1'">
  148. <xsl:attribute name="start">
  149. <xsl:value-of select="$start"/>
  150. </xsl:attribute>
  151. </xsl:if>
  152. <xsl:if test="$numeration != ''">
  153. <xsl:attribute name="type">
  154. <xsl:value-of select="$type"/>
  155. </xsl:attribute>
  156. </xsl:if>
  157. <xsl:if test="@spacing='compact'">
  158. <xsl:attribute name="compact">
  159. <xsl:value-of select="@spacing"/>
  160. </xsl:attribute>
  161. </xsl:if>
  162. <xsl:apply-templates
  163. select="listitem
  164. |comment()[preceding-sibling::listitem]
  165. |processing-instruction()[preceding-sibling::listitem]"/>
  166. </ol>
  167. </div>
  168. </xsl:template>
  169. <xsl:template match="orderedlist/title">
  170. <!-- nop -->
  171. </xsl:template>
  172. <xsl:template match="orderedlist/listitem">
  173. <li>
  174. <xsl:if test="@override">
  175. <xsl:attribute name="value">
  176. <xsl:value-of select="@override"/>
  177. </xsl:attribute>
  178. </xsl:if>
  179. <!-- we can't just drop the anchor in since some browsers (Opera)
  180. get confused about line breaks if we do. So if the first child
  181. is a para, assume the para will put in the anchor. Otherwise,
  182. put the anchor in anyway. -->
  183. <xsl:if test="local-name(child::*[1]) != 'para'">
  184. <xsl:call-template name="anchor"/>
  185. </xsl:if>
  186. <xsl:choose>
  187. <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  188. <div class="{@revisionflag}">
  189. <xsl:apply-templates/>
  190. </div>
  191. </xsl:when>
  192. <xsl:otherwise>
  193. <xsl:apply-templates/>
  194. </xsl:otherwise>
  195. </xsl:choose>
  196. </li>
  197. </xsl:template>
  198. <xsl:template match="variablelist">
  199. <xsl:variable name="pi-presentation">
  200. <xsl:call-template name="dbhtml-attribute">
  201. <xsl:with-param name="pis"
  202. select="processing-instruction('dbhtml')"/>
  203. <xsl:with-param name="attribute" select="'list-presentation'"/>
  204. </xsl:call-template>
  205. </xsl:variable>
  206. <xsl:variable name="presentation">
  207. <xsl:choose>
  208. <xsl:when test="$pi-presentation != ''">
  209. <xsl:value-of select="$pi-presentation"/>
  210. </xsl:when>
  211. <xsl:when test="$variablelist.as.table != 0">
  212. <xsl:value-of select="'table'"/>
  213. </xsl:when>
  214. <xsl:otherwise>
  215. <xsl:value-of select="'list'"/>
  216. </xsl:otherwise>
  217. </xsl:choose>
  218. </xsl:variable>
  219. <xsl:variable name="list-width">
  220. <xsl:call-template name="dbhtml-attribute">
  221. <xsl:with-param name="pis"
  222. select="processing-instruction('dbhtml')"/>
  223. <xsl:with-param name="attribute" select="'list-width'"/>
  224. </xsl:call-template>
  225. </xsl:variable>
  226. <xsl:variable name="term-width">
  227. <xsl:call-template name="dbhtml-attribute">
  228. <xsl:with-param name="pis"
  229. select="processing-instruction('dbhtml')"/>
  230. <xsl:with-param name="attribute" select="'term-width'"/>
  231. </xsl:call-template>
  232. </xsl:variable>
  233. <xsl:variable name="table-summary">
  234. <xsl:call-template name="dbhtml-attribute">
  235. <xsl:with-param name="pis"
  236. select="processing-instruction('dbhtml')"/>
  237. <xsl:with-param name="attribute" select="'table-summary'"/>
  238. </xsl:call-template>
  239. </xsl:variable>
  240. <div class="{name(.)}">
  241. <xsl:call-template name="anchor"/>
  242. <xsl:if test="title">
  243. <xsl:call-template name="formal.object.heading"/>
  244. </xsl:if>
  245. <xsl:choose>
  246. <xsl:when test="$presentation = 'table'">
  247. <!-- Preserve order of PIs and comments -->
  248. <xsl:apply-templates
  249. select="*[not(self::varlistentry
  250. or self::title
  251. or self::titleabbrev)]
  252. |comment()[not(preceding-sibling::varlistentry)]
  253. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  254. <table border="0">
  255. <xsl:if test="$list-width != ''">
  256. <xsl:attribute name="width">
  257. <xsl:value-of select="$list-width"/>
  258. </xsl:attribute>
  259. </xsl:if>
  260. <xsl:if test="$table-summary != ''">
  261. <xsl:attribute name="summary">
  262. <xsl:value-of select="$table-summary"/>
  263. </xsl:attribute>
  264. </xsl:if>
  265. <col align="left" valign="top">
  266. <xsl:if test="$term-width != ''">
  267. <xsl:attribute name="width">
  268. <xsl:value-of select="$term-width"/>
  269. </xsl:attribute>
  270. </xsl:if>
  271. </col>
  272. <tbody>
  273. <xsl:apply-templates mode="varlist-table"
  274. select="varlistentry
  275. |comment()[preceding-sibling::varlistentry]
  276. |processing-instruction()[preceding-sibling::varlistentry]"/>
  277. </tbody>
  278. </table>
  279. </xsl:when>
  280. <xsl:otherwise>
  281. <!-- Preserve order of PIs and comments -->
  282. <xsl:apply-templates
  283. select="*[not(self::varlistentry
  284. or self::title
  285. or self::titleabbrev)]
  286. |comment()[not(preceding-sibling::varlistentry)]
  287. |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
  288. <dl>
  289. <xsl:apply-templates
  290. select="varlistentry
  291. |comment()[preceding-sibling::varlistentry]
  292. |processing-instruction()[preceding-sibling::varlistentry]"/>
  293. </dl>
  294. </xsl:otherwise>
  295. </xsl:choose>
  296. </div>
  297. </xsl:template>
  298. <xsl:template match="variablelist/title">
  299. <!-- nop -->
  300. </xsl:template>
  301. <xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
  302. <!--nop-->
  303. </xsl:template>
  304. <xsl:template match="variablelist/titleabbrev">
  305. <!--nop-->
  306. </xsl:template>
  307. <xsl:template match="listitem" mode="xref">
  308. <xsl:number format="1"/>
  309. </xsl:template>
  310. <xsl:template match="listitem/simpara" priority="2">
  311. <!-- If a listitem contains only a single simpara, don't output
  312. the <p> wrapper; this has the effect of creating an li
  313. with simple text content. -->
  314. <xsl:choose>
  315. <xsl:when test="not(preceding-sibling::*)
  316. and not (following-sibling::*)">
  317. <xsl:call-template name="anchor"/>
  318. <xsl:apply-templates/>
  319. </xsl:when>
  320. <xsl:otherwise>
  321. <!-- p -->
  322. <xsl:if test="@role and $para.propagates.style != 0">
  323. <xsl:attribute name="class">
  324. <xsl:value-of select="@role"/>
  325. </xsl:attribute>
  326. </xsl:if>
  327. <xsl:call-template name="anchor"/>
  328. <xsl:apply-templates/>
  329. <!-- /p -->
  330. </xsl:otherwise>
  331. </xsl:choose>
  332. </xsl:template>
  333. <xsl:template match="varlistentry">
  334. <dt>
  335. <xsl:call-template name="anchor"/>
  336. <xsl:apply-templates select="term"/>
  337. </dt>
  338. <dd>
  339. <xsl:apply-templates select="listitem"/>
  340. </dd>
  341. </xsl:template>
  342. <xsl:template match="varlistentry" mode="varlist-table">
  343. <xsl:variable name="presentation">
  344. <xsl:call-template name="dbhtml-attribute">
  345. <xsl:with-param name="pis"
  346. select="../processing-instruction('dbhtml')"/>
  347. <xsl:with-param name="attribute" select="'term-presentation'"/>
  348. </xsl:call-template>
  349. </xsl:variable>
  350. <xsl:variable name="separator">
  351. <xsl:call-template name="dbhtml-attribute">
  352. <xsl:with-param name="pis"
  353. select="../processing-instruction('dbhtml')"/>
  354. <xsl:with-param name="attribute" select="'term-separator'"/>
  355. </xsl:call-template>
  356. </xsl:variable>
  357. <tr>
  358. <xsl:call-template name="tr.attributes">
  359. <xsl:with-param name="rownum">
  360. <xsl:number from="variablelist" count="varlistentry"/>
  361. </xsl:with-param>
  362. </xsl:call-template>
  363. <td>
  364. <xsl:call-template name="anchor"/>
  365. <xsl:choose>
  366. <xsl:when test="$presentation = 'bold'">
  367. <b>
  368. <xsl:apply-templates select="term"/>
  369. <xsl:value-of select="$separator"/>
  370. </b>
  371. </xsl:when>
  372. <xsl:when test="$presentation = 'italic'">
  373. <i>
  374. <xsl:apply-templates select="term"/>
  375. <xsl:value-of select="$separator"/>
  376. </i>
  377. </xsl:when>
  378. <xsl:when test="$presentation = 'bold-italic'">
  379. <b>
  380. <i>
  381. <xsl:apply-templates select="term"/>
  382. <xsl:value-of select="$separator"/>
  383. </i>
  384. </b>
  385. </xsl:when>
  386. <xsl:otherwise>
  387. <xsl:apply-templates select="term"/>
  388. <xsl:value-of select="$separator"/>
  389. </xsl:otherwise>
  390. </xsl:choose>
  391. </td>
  392. <td>
  393. <xsl:apply-templates select="listitem"/>
  394. </td>
  395. </tr>
  396. </xsl:template>
  397. <xsl:template match="varlistentry/term">
  398. <span class="term">
  399. <xsl:call-template name="anchor"/>
  400. <xsl:apply-templates/>
  401. <xsl:text>, </xsl:text>
  402. </span>
  403. </xsl:template>
  404. <xsl:template match="varlistentry/term[position()=last()]" priority="2">
  405. <span class="term">
  406. <xsl:call-template name="anchor"/>
  407. <xsl:apply-templates/>
  408. </span>
  409. </xsl:template>
  410. <xsl:template match="varlistentry/listitem">
  411. <xsl:choose>
  412. <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  413. <div class="{@revisionflag}">
  414. <xsl:apply-templates/>
  415. </div>
  416. </xsl:when>
  417. <xsl:otherwise>
  418. <xsl:apply-templates/>
  419. </xsl:otherwise>
  420. </xsl:choose>
  421. </xsl:template>
  422. <!-- ==================================================================== -->
  423. <xsl:template match="simplelist">
  424. <!-- with no type specified, the default is 'vert' -->
  425. <xsl:call-template name="anchor"/>
  426. <table class="simplelist" border="0" summary="Simple list">
  427. <xsl:call-template name="simplelist.vert">
  428. <xsl:with-param name="cols">
  429. <xsl:choose>
  430. <xsl:when test="@columns">
  431. <xsl:value-of select="@columns"/>
  432. </xsl:when>
  433. <xsl:otherwise>1</xsl:otherwise>
  434. </xsl:choose>
  435. </xsl:with-param>
  436. </xsl:call-template>
  437. </table>
  438. </xsl:template>
  439. <xsl:template match="simplelist[@type='inline']">
  440. <span class="{name(.)}">
  441. <xsl:call-template name="anchor"/>
  442. <xsl:apply-templates/>
  443. </span>
  444. </xsl:template>
  445. <xsl:template match="simplelist[@type='horiz']">
  446. <xsl:call-template name="anchor"/>
  447. <table class="simplelist" border="0" summary="Simple list">
  448. <xsl:call-template name="simplelist.horiz">
  449. <xsl:with-param name="cols">
  450. <xsl:choose>
  451. <xsl:when test="@columns">
  452. <xsl:value-of select="@columns"/>
  453. </xsl:when>
  454. <xsl:otherwise>1</xsl:otherwise>
  455. </xsl:choose>
  456. </xsl:with-param>
  457. </xsl:call-template>
  458. </table>
  459. </xsl:template>
  460. <xsl:template match="simplelist[@type='vert']">
  461. <xsl:call-template name="anchor"/>
  462. <table class="simplelist" border="0" summary="Simple list">
  463. <xsl:call-template name="simplelist.vert">
  464. <xsl:with-param name="cols">
  465. <xsl:choose>
  466. <xsl:when test="@columns">
  467. <xsl:value-of select="@columns"/>
  468. </xsl:when>
  469. <xsl:otherwise>1</xsl:otherwise>
  470. </xsl:choose>
  471. </xsl:with-param>
  472. </xsl:call-template>
  473. </table>
  474. </xsl:template>
  475. <xsl:template name="simplelist.horiz">
  476. <xsl:param name="cols">1</xsl:param>
  477. <xsl:param name="cell">1</xsl:param>
  478. <xsl:param name="members" select="./member"/>
  479. <xsl:if test="$cell &lt;= count($members)">
  480. <tr>
  481. <xsl:call-template name="tr.attributes">
  482. <xsl:with-param name="row" select="$members[1]"/>
  483. <xsl:with-param name="rownum" select="(($cell - 1) div $cols) + 1"/>
  484. </xsl:call-template>
  485. <xsl:call-template name="simplelist.horiz.row">
  486. <xsl:with-param name="cols" select="$cols"/>
  487. <xsl:with-param name="cell" select="$cell"/>
  488. <xsl:with-param name="members" select="$members"/>
  489. </xsl:call-template>
  490. </tr>
  491. <xsl:call-template name="simplelist.horiz">
  492. <xsl:with-param name="cols" select="$cols"/>
  493. <xsl:with-param name="cell" select="$cell + $cols"/>
  494. <xsl:with-param name="members" select="$members"/>
  495. </xsl:call-template>
  496. </xsl:if>
  497. </xsl:template>
  498. <xsl:template name="simplelist.horiz.row">
  499. <xsl:param name="cols">1</xsl:param>
  500. <xsl:param name="cell">1</xsl:param>
  501. <xsl:param name="members" select="./member"/>
  502. <xsl:param name="curcol">1</xsl:param>
  503. <xsl:if test="$curcol &lt;= $cols">
  504. <td>
  505. <xsl:choose>
  506. <xsl:when test="$members[position()=$cell]">
  507. <xsl:apply-templates select="$members[position()=$cell]"/>
  508. </xsl:when>
  509. <xsl:otherwise>
  510. <xsl:text>&#160;</xsl:text>
  511. </xsl:otherwise>
  512. </xsl:choose>
  513. </td>
  514. <xsl:call-template name="simplelist.horiz.row">
  515. <xsl:with-param name="cols" select="$cols"/>
  516. <xsl:with-param name="cell" select="$cell+1"/>
  517. <xsl:with-param name="members" select="$members"/>
  518. <xsl:with-param name="curcol" select="$curcol+1"/>
  519. </xsl:call-template>
  520. </xsl:if>
  521. </xsl:template>
  522. <xsl:template name="simplelist.vert">
  523. <xsl:param name="cols">1</xsl:param>
  524. <xsl:param name="cell">1</xsl:param>
  525. <xsl:param name="members" select="./member"/>
  526. <xsl:param name="rows"
  527. select="floor((count($members)+$cols - 1) div $cols)"/>
  528. <xsl:if test="$cell &lt;= $rows">
  529. <tr>
  530. <xsl:call-template name="tr.attributes">
  531. <xsl:with-param name="row" select="$members[1]"/>
  532. <xsl:with-param name="rownum" select="$cell"/>
  533. </xsl:call-template>
  534. <xsl:call-template name="simplelist.vert.row">
  535. <xsl:with-param name="cols" select="$cols"/>
  536. <xsl:with-param name="rows" select="$rows"/>
  537. <xsl:with-param name="cell" select="$cell"/>
  538. <xsl:with-param name="members" select="$members"/>
  539. </xsl:call-template>
  540. </tr>
  541. <xsl:call-template name="simplelist.vert">
  542. <xsl:with-param name="cols" select="$cols"/>
  543. <xsl:with-param name="cell" select="$cell+1"/>
  544. <xsl:with-param name="members" select="$members"/>
  545. <xsl:with-param name="rows" select="$rows"/>
  546. </xsl:call-template>
  547. </xsl:if>
  548. </xsl:template>
  549. <xsl:template name="simplelist.vert.row">
  550. <xsl:param name="cols">1</xsl:param>
  551. <xsl:param name="rows">1</xsl:param>
  552. <xsl:param name="cell">1</xsl:param>
  553. <xsl:param name="members" select="./member"/>
  554. <xsl:param name="curcol">1</xsl:param>
  555. <xsl:if test="$curcol &lt;= $cols">
  556. <td>
  557. <xsl:choose>
  558. <xsl:when test="$members[position()=$cell]">
  559. <xsl:apply-templates select="$members[position()=$cell]"/>
  560. </xsl:when>
  561. <xsl:otherwise>
  562. <xsl:text>&#160;</xsl:text>
  563. </xsl:otherwise>
  564. </xsl:choose>
  565. </td>
  566. <xsl:call-template name="simplelist.vert.row">
  567. <xsl:with-param name="cols" select="$cols"/>
  568. <xsl:with-param name="rows" select="$rows"/>
  569. <xsl:with-param name="cell" select="$cell+$rows"/>
  570. <xsl:with-param name="members" select="$members"/>
  571. <xsl:with-param name="curcol" select="$curcol+1"/>
  572. </xsl:call-template>
  573. </xsl:if>
  574. </xsl:template>
  575. <xsl:template match="member">
  576. <xsl:call-template name="anchor"/>
  577. <xsl:apply-templates/>
  578. </xsl:template>
  579. <xsl:template match="simplelist[@type='inline']/member">
  580. <xsl:apply-templates/>
  581. <xsl:text>, </xsl:text>
  582. </xsl:template>
  583. <xsl:template match="simplelist[@type='inline']/member[position()=last()]"
  584. priority="2">
  585. <xsl:apply-templates/>
  586. </xsl:template>
  587. <!-- ==================================================================== -->
  588. <xsl:template match="procedure">
  589. <xsl:variable name="param.placement"
  590. select="substring-after(normalize-space($formal.title.placement),
  591. concat(local-name(.), ' '))"/>
  592. <xsl:variable name="placement">
  593. <xsl:choose>
  594. <xsl:when test="contains($param.placement, ' ')">
  595. <xsl:value-of select="substring-before($param.placement, ' ')"/>
  596. </xsl:when>
  597. <xsl:when test="$param.placement = ''">before</xsl:when>
  598. <xsl:otherwise>
  599. <xsl:value-of select="$param.placement"/>
  600. </xsl:otherwise>
  601. </xsl:choose>
  602. </xsl:variable>
  603. <!-- Preserve order of PIs and comments -->
  604. <xsl:variable name="preamble"
  605. select="*[not(self::step
  606. or self::title
  607. or self::titleabbrev)]
  608. |comment()[not(preceding-sibling::step)]
  609. |processing-instruction()[not(preceding-sibling::step)]"/>
  610. <div class="{name(.)}">
  611. <xsl:call-template name="anchor">
  612. <xsl:with-param name="conditional">
  613. <xsl:choose>
  614. <xsl:when test="title">0</xsl:when>
  615. <xsl:otherwise>1</xsl:otherwise>
  616. </xsl:choose>
  617. </xsl:with-param>
  618. </xsl:call-template>
  619. <xsl:if test="title and $placement = 'before'">
  620. <xsl:call-template name="formal.object.heading"/>
  621. </xsl:if>
  622. <xsl:apply-templates select="$preamble"/>
  623. <xsl:choose>
  624. <xsl:when test="count(step) = 1">
  625. <ul>
  626. <xsl:apply-templates
  627. select="step
  628. |comment()[preceding-sibling::step]
  629. |processing-instruction()[preceding-sibling::step]"/>
  630. </ul>
  631. </xsl:when>
  632. <xsl:otherwise>
  633. <ol>
  634. <xsl:attribute name="type">
  635. <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
  636. </xsl:attribute>
  637. <xsl:apply-templates
  638. select="step
  639. |comment()[preceding-sibling::step]
  640. |processing-instruction()[preceding-sibling::step]"/>
  641. </ol>
  642. </xsl:otherwise>
  643. </xsl:choose>
  644. <xsl:if test="title and $placement != 'before'">
  645. <xsl:call-template name="formal.object.heading"/>
  646. </xsl:if>
  647. </div>
  648. </xsl:template>
  649. <xsl:template match="procedure/title">
  650. <!-- nop -->
  651. </xsl:template>
  652. <xsl:template match="substeps">
  653. <xsl:variable name="numeration">
  654. <xsl:call-template name="procedure.step.numeration"/>
  655. </xsl:variable>
  656. <xsl:call-template name="anchor"/>
  657. <ol type="{$numeration}">
  658. <xsl:apply-templates/>
  659. </ol>
  660. </xsl:template>
  661. <xsl:template match="step">
  662. <li>
  663. <xsl:call-template name="anchor"/>
  664. <xsl:apply-templates/>
  665. </li>
  666. </xsl:template>
  667. <xsl:template match="stepalternatives">
  668. <xsl:call-template name="anchor"/>
  669. <ul>
  670. <xsl:apply-templates/>
  671. </ul>
  672. </xsl:template>
  673. <xsl:template match="step/title">
  674. <p class="title">
  675. <b>
  676. <xsl:apply-templates/>
  677. </b>
  678. </p>
  679. </xsl:template>
  680. <!-- ==================================================================== -->
  681. <xsl:template match="segmentedlist">
  682. <xsl:variable name="presentation">
  683. <xsl:call-template name="dbhtml-attribute">
  684. <xsl:with-param name="pis"
  685. select="processing-instruction('dbhtml')"/>
  686. <xsl:with-param name="attribute" select="'list-presentation'"/>
  687. </xsl:call-template>
  688. </xsl:variable>
  689. <div class="{name(.)}">
  690. <xsl:call-template name="anchor"/>
  691. <xsl:choose>
  692. <xsl:when test="$presentation = 'table'">
  693. <xsl:apply-templates select="." mode="seglist-table"/>
  694. </xsl:when>
  695. <xsl:when test="$presentation = 'list'">
  696. <xsl:apply-templates/>
  697. </xsl:when>
  698. <xsl:when test="$segmentedlist.as.table != 0">
  699. <xsl:apply-templates select="." mode="seglist-table"/>
  700. </xsl:when>
  701. <xsl:otherwise>
  702. <xsl:apply-templates/>
  703. </xsl:otherwise>
  704. </xsl:choose>
  705. </div>
  706. </xsl:template>
  707. <xsl:template match="segmentedlist/title">
  708. <div class="title">
  709. <strong><span class="title"><xsl:apply-templates/></span></strong>
  710. </div>
  711. </xsl:template>
  712. <xsl:template match="segtitle">
  713. </xsl:template>
  714. <xsl:template match="segtitle" mode="segtitle-in-seg">
  715. <xsl:apply-templates/>
  716. </xsl:template>
  717. <xsl:template match="seglistitem">
  718. <div class="seglistitem">
  719. <xsl:call-template name="anchor"/>
  720. <xsl:apply-templates/>
  721. </div>
  722. </xsl:template>
  723. <xsl:template match="seg">
  724. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  725. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  726. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  727. <!--
  728. Note: segtitle is only going to be the right thing in a well formed
  729. SegmentedList. If there are too many Segs or too few SegTitles,
  730. you'll get something odd...maybe an error
  731. -->
  732. <div class="seg">
  733. <strong>
  734. <span class="segtitle">
  735. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  736. mode="segtitle-in-seg"/>
  737. <xsl:text>: </xsl:text>
  738. </span>
  739. </strong>
  740. <xsl:apply-templates/>
  741. </div>
  742. </xsl:template>
  743. <xsl:template match="segmentedlist" mode="seglist-table">
  744. <xsl:variable name="table-summary">
  745. <xsl:call-template name="dbhtml-attribute">
  746. <xsl:with-param name="pis"
  747. select="processing-instruction('dbhtml')"/>
  748. <xsl:with-param name="attribute" select="'table-summary'"/>
  749. </xsl:call-template>
  750. </xsl:variable>
  751. <xsl:variable name="list-width">
  752. <xsl:call-template name="dbhtml-attribute">
  753. <xsl:with-param name="pis"
  754. select="processing-instruction('dbhtml')"/>
  755. <xsl:with-param name="attribute" select="'list-width'"/>
  756. </xsl:call-template>
  757. </xsl:variable>
  758. <xsl:apply-templates select="title"/>
  759. <table border="0">
  760. <xsl:if test="$list-width != ''">
  761. <xsl:attribute name="width">
  762. <xsl:value-of select="$list-width"/>
  763. </xsl:attribute>
  764. </xsl:if>
  765. <xsl:if test="$table-summary != ''">
  766. <xsl:attribute name="summary">
  767. <xsl:value-of select="$table-summary"/>
  768. </xsl:attribute>
  769. </xsl:if>
  770. <thead>
  771. <tr class="segtitle">
  772. <xsl:call-template name="tr.attributes">
  773. <xsl:with-param name="row" select="segtitle[1]"/>
  774. <xsl:with-param name="rownum" select="1"/>
  775. </xsl:call-template>
  776. <xsl:apply-templates select="segtitle" mode="seglist-table"/>
  777. </tr>
  778. </thead>
  779. <tbody>
  780. <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
  781. </tbody>
  782. </table>
  783. </xsl:template>
  784. <xsl:template match="segtitle" mode="seglist-table">
  785. <th><xsl:apply-templates/></th>
  786. </xsl:template>
  787. <xsl:template match="seglistitem" mode="seglist-table">
  788. <xsl:variable name="seglinum">
  789. <xsl:number from="segmentedlist" count="seglistitem"/>
  790. </xsl:variable>
  791. <tr class="seglistitem">
  792. <xsl:call-template name="tr.attributes">
  793. <xsl:with-param name="rownum" select="$seglinum + 1"/>
  794. </xsl:call-template>
  795. <xsl:apply-templates mode="seglist-table"/>
  796. </tr>
  797. </xsl:template>
  798. <xsl:template match="seg" mode="seglist-table">
  799. <td class="seg"><xsl:apply-templates/></td>
  800. </xsl:template>
  801. <xsl:template match="seg[1]" mode="seglist-table">
  802. <td class="seg">
  803. <xsl:call-template name="anchor">
  804. <xsl:with-param name="node" select="ancestor::seglistitem"/>
  805. </xsl:call-template>
  806. <xsl:apply-templates/>
  807. </td>
  808. </xsl:template>
  809. <!-- ==================================================================== -->
  810. <xsl:template match="calloutlist">
  811. <div class="{name(.)}">
  812. <xsl:call-template name="anchor"/>
  813. <xsl:if test="title">
  814. <xsl:call-template name="formal.object.heading"/>
  815. </xsl:if>
  816. <!-- Preserve order of PIs and comments -->
  817. <xsl:apply-templates
  818. select="*[not(self::callout or self::title or self::titleabbrev)]
  819. |comment()[not(preceding-sibling::callout)]
  820. |processing-instruction()[not(preceding-sibling::callout)]"/>
  821. <xsl:choose>
  822. <xsl:when test="$callout.list.table != 0">
  823. <table border="0" summary="Callout list">
  824. <xsl:apply-templates select="callout
  825. |comment()[preceding-sibling::calllout]
  826. |processing-instruction()[preceding-sibling::callout]"/>
  827. </table>
  828. </xsl:when>
  829. <xsl:otherwise>
  830. <dl compact="compact">
  831. <xsl:apply-templates select="callout
  832. |comment()[preceding-sibling::calllout]
  833. |processing-instruction()[preceding-sibling::callout]"/>
  834. </dl>
  835. </xsl:otherwise>
  836. </xsl:choose>
  837. </div>
  838. </xsl:template>
  839. <xsl:template match="calloutlist/title">
  840. </xsl:template>
  841. <xsl:template match="callout">
  842. <xsl:choose>
  843. <xsl:when test="$callout.list.table != 0">
  844. <tr>
  845. <xsl:call-template name="tr.attributes">
  846. <xsl:with-param name="rownum">
  847. <xsl:number from="calloutlist" count="callout"/>
  848. </xsl:with-param>
  849. </xsl:call-template>
  850. <td width="5%" valign="top" align="left">
  851. <xsl:call-template name="anchor"/>
  852. <xsl:call-template name="callout.arearefs">
  853. <xsl:with-param name="arearefs" select="@arearefs"/>
  854. </xsl:call-template>
  855. </td>
  856. <td valign="top" align="left">
  857. <xsl:apply-templates/>
  858. </td>
  859. </tr>
  860. </xsl:when>
  861. <xsl:otherwise>
  862. <dt>
  863. <xsl:call-template name="anchor"/>
  864. <xsl:call-template name="callout.arearefs">
  865. <xsl:with-param name="arearefs" select="@arearefs"/>
  866. </xsl:call-template>
  867. </dt>
  868. <dd><xsl:apply-templates/></dd>
  869. </xsl:otherwise>
  870. </xsl:choose>
  871. </xsl:template>
  872. <xsl:template match="callout/simpara" priority="2">
  873. <!-- If a callout contains only a single simpara, don't output
  874. the <p> wrapper; this has the effect of creating an li
  875. with simple text content. -->
  876. <xsl:choose>
  877. <xsl:when test="not(preceding-sibling::*)
  878. and not (following-sibling::*)">
  879. <xsl:call-template name="anchor"/>
  880. <xsl:apply-templates/>
  881. </xsl:when>
  882. <xsl:otherwise>
  883. <!-- p -->
  884. <xsl:if test="@role and $para.propagates.style != 0">
  885. <xsl:attribute name="class">
  886. <xsl:value-of select="@role"/>
  887. </xsl:attribute>
  888. </xsl:if>
  889. <xsl:call-template name="anchor"/>
  890. <xsl:apply-templates/>
  891. <!-- /p -->
  892. </xsl:otherwise>
  893. </xsl:choose>
  894. </xsl:template>
  895. <xsl:template name="callout.arearefs">
  896. <xsl:param name="arearefs"></xsl:param>
  897. <xsl:if test="$arearefs!=''">
  898. <xsl:choose>
  899. <xsl:when test="substring-before($arearefs,' ')=''">
  900. <xsl:call-template name="callout.arearef">
  901. <xsl:with-param name="arearef" select="$arearefs"/>
  902. </xsl:call-template>
  903. </xsl:when>
  904. <xsl:otherwise>
  905. <xsl:call-template name="callout.arearef">
  906. <xsl:with-param name="arearef"
  907. select="substring-before($arearefs,' ')"/>
  908. </xsl:call-template>
  909. </xsl:otherwise>
  910. </xsl:choose>
  911. <xsl:call-template name="callout.arearefs">
  912. <xsl:with-param name="arearefs"
  913. select="substring-after($arearefs,' ')"/>
  914. </xsl:call-template>
  915. </xsl:if>
  916. </xsl:template>
  917. <xsl:template name="callout.arearef">
  918. <xsl:param name="arearef"></xsl:param>
  919. <xsl:variable name="targets" select="key('id',$arearef)"/>
  920. <xsl:variable name="target" select="$targets[1]"/>
  921. <xsl:call-template name="check.id.unique">
  922. <xsl:with-param name="linkend" select="$arearef"/>
  923. </xsl:call-template>
  924. <xsl:choose>
  925. <xsl:when test="count($target)=0">
  926. <xsl:text>???</xsl:text>
  927. </xsl:when>
  928. <xsl:when test="local-name($target)='co'">
  929. <a>
  930. <xsl:attribute name="href">
  931. <xsl:text>#</xsl:text>
  932. <xsl:value-of select="$arearef"/>
  933. </xsl:attribute>
  934. <xsl:apply-templates select="$target" mode="callout-bug"/>
  935. </a>
  936. <xsl:text> </xsl:text>
  937. </xsl:when>
  938. <xsl:when test="local-name($target)='areaset'">
  939. <xsl:call-template name="callout-bug">
  940. <xsl:with-param name="conum">
  941. <xsl:apply-templates select="$target" mode="conumber"/>
  942. </xsl:with-param>
  943. </xsl:call-template>
  944. </xsl:when>
  945. <xsl:when test="local-name($target)='area'">
  946. <xsl:choose>
  947. <xsl:when test="$target/parent::areaset">
  948. <xsl:call-template name="callout-bug">
  949. <xsl:with-param name="conum">
  950. <xsl:apply-templates select="$target/parent::areaset"
  951. mode="conumber"/>
  952. </xsl:with-param>
  953. </xsl:call-template>
  954. </xsl:when>
  955. <xsl:otherwise>
  956. <xsl:call-template name="callout-bug">
  957. <xsl:with-param name="conum">
  958. <xsl:apply-templates select="$target" mode="conumber"/>
  959. </xsl:with-param>
  960. </xsl:call-template>
  961. </xsl:otherwise>
  962. </xsl:choose>
  963. </xsl:when>
  964. <xsl:otherwise>
  965. <xsl:text>???</xsl:text>
  966. </xsl:otherwise>
  967. </xsl:choose>
  968. </xsl:template>
  969. <!-- ==================================================================== -->
  970. </xsl:stylesheet>