lists.xsl 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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 9684 2012-12-12 17:05:54Z bobstayton $
  6. ********************************************************************
  7. This file is part of the XSL DocBook Stylesheet distribution.
  8. See ../README or http://docbook.sf.net/release/xsl/current/ for
  9. copyright and other information.
  10. ******************************************************************** -->
  11. <xsl:variable name="list-indent">
  12. <xsl:choose>
  13. <xsl:when test="not($man.indent.lists = 0)">
  14. <xsl:value-of select="$man.indent.width"/>
  15. </xsl:when>
  16. <xsl:when test="not($man.indent.refsect = 0)">
  17. <!-- * "zq" is the name of a register we set for -->
  18. <!-- * preserving the original default indent value -->
  19. <!-- * when $man.indent.refsect is non-zero; -->
  20. <!-- * "u" is a roff unit specifier -->
  21. <xsl:text>\n(zqu</xsl:text>
  22. </xsl:when>
  23. <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
  24. </xsl:choose>
  25. </xsl:variable>
  26. <!-- ================================================================== -->
  27. <xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  28. simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  29. remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  30. <xsl:call-template name="mixed-block"/>
  31. <xsl:text>&#10;</xsl:text>
  32. <xsl:if test="following-sibling::*[1][
  33. self::para or
  34. self::simpara or
  35. self::remark
  36. ]">
  37. <!-- * Make sure multiple paragraphs within a list item don't -->
  38. <!-- * merge together. -->
  39. <xsl:text>.sp&#10;</xsl:text>
  40. </xsl:if>
  41. </xsl:template>
  42. <xsl:template match="bibliolist">
  43. <xsl:apply-templates/>
  44. <xsl:text>&#10;</xsl:text>
  45. </xsl:template>
  46. <xsl:template match="variablelist|glosslist">
  47. <xsl:text>&#10;</xsl:text>
  48. <xsl:if test="title">
  49. <xsl:text>.PP&#10;</xsl:text>
  50. <xsl:call-template name="bold">
  51. <xsl:with-param name="node" select="title"/>
  52. <xsl:with-param name="context" select="."/>
  53. </xsl:call-template>
  54. <xsl:text>&#10;</xsl:text>
  55. </xsl:if>
  56. <xsl:apply-templates/>
  57. </xsl:template>
  58. <xsl:template match="varlistentry|glossentry">
  59. <xsl:text>.PP&#10;</xsl:text>
  60. <xsl:for-each select="term|glossterm">
  61. <xsl:variable name="content">
  62. <xsl:apply-templates/>
  63. </xsl:variable>
  64. <xsl:value-of select="normalize-space($content)"/>
  65. <xsl:choose>
  66. <xsl:when test="position() = last()"/> <!-- do nothing -->
  67. <xsl:otherwise>
  68. <!-- * if we have multiple terms in the same varlistentry, generate -->
  69. <!-- * a separator (", " by default) and/or an additional line -->
  70. <!-- * break after each one except the last -->
  71. <!-- * -->
  72. <!-- * note that it is not valid to have multiple glossterms -->
  73. <!-- * within a glossentry, so this logic never gets exercised -->
  74. <!-- * for glossterms (every glossterm is always the last in -->
  75. <!-- * its parent glossentry) -->
  76. <xsl:value-of select="$variablelist.term.separator"/>
  77. <xsl:if test="not($variablelist.term.break.after = '0')">
  78. <xsl:text>&#10;</xsl:text>
  79. <xsl:text>.br&#10;</xsl:text>
  80. </xsl:if>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:for-each>
  84. <xsl:text>&#10;</xsl:text>
  85. <xsl:text>.RS</xsl:text>
  86. <xsl:if test="not($list-indent = '')">
  87. <xsl:text> </xsl:text>
  88. <xsl:value-of select="$list-indent"/>
  89. </xsl:if>
  90. <xsl:text>&#10;</xsl:text>
  91. <xsl:apply-templates/>
  92. <xsl:text>.RE&#10;</xsl:text>
  93. </xsl:template>
  94. <xsl:template match="varlistentry/term"/>
  95. <xsl:template match="glossentry/glossterm"/>
  96. <xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  97. glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  98. <xsl:apply-templates/>
  99. <xsl:if test="following-sibling::node() or
  100. parent::para[following-sibling::node()] or
  101. parent::simpara[following-sibling::node()] or
  102. parent::remark[following-sibling::node()]">
  103. <xsl:text>.sp</xsl:text>
  104. <xsl:text>&#10;</xsl:text>
  105. </xsl:if>
  106. </xsl:template>
  107. <xsl:template match="varlistentry/listitem|glossentry/glossdef">
  108. <xsl:apply-templates/>
  109. </xsl:template>
  110. <xsl:template match="itemizedlist/listitem">
  111. <!-- * We output a real bullet here (rather than, "\(bu", -->
  112. <!-- * the roff bullet) because, when we do character-map -->
  113. <!-- * processing before final output, the character-map will -->
  114. <!-- * handle conversion of the &#x2022; to "\(bu" for us -->
  115. <xsl:text>&#10;</xsl:text>
  116. <xsl:text>.sp</xsl:text>
  117. <xsl:text>&#10;</xsl:text>
  118. <xsl:text>.RS</xsl:text>
  119. <xsl:if test="not($list-indent = '')">
  120. <xsl:text> </xsl:text>
  121. <xsl:value-of select="$list-indent"/>
  122. </xsl:if>
  123. <xsl:text>&#10;</xsl:text>
  124. <!-- * if "n" then we are using "nroff", which means the output is for -->
  125. <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
  126. <!-- * hanging indent (instead of using .IP, which has some -->
  127. <!-- * undesirable side effects under certain circumstances) -->
  128. <xsl:call-template name="roff-if-else-start"/>
  129. <xsl:text>\h'-</xsl:text>
  130. <xsl:choose>
  131. <xsl:when test="not($list-indent = '')">
  132. <xsl:text>0</xsl:text>
  133. <xsl:value-of select="$list-indent"/>
  134. </xsl:when>
  135. <xsl:otherwise>
  136. <xsl:text>\n(INu</xsl:text>
  137. </xsl:otherwise>
  138. </xsl:choose>
  139. <xsl:text>'</xsl:text>
  140. <xsl:text>&#x2022;</xsl:text>
  141. <xsl:text>\h'+</xsl:text>
  142. <xsl:choose>
  143. <xsl:when test="not($list-indent = '')">
  144. <xsl:text>0</xsl:text>
  145. <xsl:value-of select="$list-indent - 1"/>
  146. </xsl:when>
  147. <xsl:otherwise>
  148. <xsl:text>\n(INu-1</xsl:text>
  149. </xsl:otherwise>
  150. </xsl:choose>
  151. <xsl:text>'\c&#10;</xsl:text>
  152. <!-- * else, we are not using for "nroff", but instead "troff" - which -->
  153. <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
  154. <!-- * fixed-width font, so use a real .IP instead -->
  155. <xsl:call-template name="roff-else"/>
  156. <!-- * .IP generates a blank like of space, so let’s go backwards one -->
  157. <!-- * line up to compensate for that -->
  158. <xsl:text>.sp -1&#10;</xsl:text>
  159. <xsl:text>.IP \(bu 2.3&#10;</xsl:text>
  160. <!-- * The value 2.3 is the amount of indentation; we use 2.3 instead -->
  161. <!-- * of 2 because when the font family is New Century Schoolbook it -->
  162. <!-- * seems to require the extra space. -->
  163. <xsl:call-template name="roff-if-end"/>
  164. <xsl:apply-templates/>
  165. <xsl:text>.RE&#10;</xsl:text>
  166. </xsl:template>
  167. <xsl:template match="orderedlist/listitem/title|
  168. procedure/step/title">
  169. <xsl:call-template name="bold">
  170. <xsl:with-param name="node" select="."/>
  171. <xsl:with-param name="context" select=".."/>
  172. </xsl:call-template>
  173. <xsl:text>&#10;</xsl:text>
  174. <xsl:text>.PP&#10;</xsl:text>
  175. </xsl:template>
  176. <xsl:template match="orderedlist/listitem|procedure/step">
  177. <xsl:text>&#10;</xsl:text>
  178. <xsl:text>.sp</xsl:text>
  179. <xsl:text>&#10;</xsl:text>
  180. <xsl:text>.RS</xsl:text>
  181. <xsl:if test="not($list-indent = '')">
  182. <xsl:text> </xsl:text>
  183. <xsl:value-of select="$list-indent"/>
  184. </xsl:if>
  185. <xsl:text>&#10;</xsl:text>
  186. <!-- * if "n" then we are using "nroff", which means the output is for -->
  187. <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
  188. <!-- * hanging indents (instead of using .IP, which has some -->
  189. <!-- * undesirable side effects under certain circumstances) -->
  190. <xsl:call-template name="roff-if-else-start"/>
  191. <xsl:text>\h'-</xsl:text>
  192. <xsl:choose>
  193. <xsl:when test="not($list-indent = '')">
  194. <xsl:text>0</xsl:text>
  195. <xsl:value-of select="$list-indent"/>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <xsl:text>\n(INu+3n</xsl:text>
  199. </xsl:otherwise>
  200. </xsl:choose>
  201. <xsl:text>'</xsl:text>
  202. <xsl:if test="count(preceding-sibling::listitem) &lt; 9">
  203. <xsl:text> </xsl:text>
  204. </xsl:if>
  205. <xsl:number format="1."/>
  206. <xsl:text>\h'+</xsl:text>
  207. <xsl:choose>
  208. <xsl:when test="not($list-indent = '')">
  209. <xsl:text>0</xsl:text>
  210. <xsl:value-of select="$list-indent - 3"/>
  211. </xsl:when>
  212. <xsl:otherwise>
  213. <xsl:text>1n</xsl:text>
  214. </xsl:otherwise>
  215. </xsl:choose>
  216. <xsl:text>'\c&#10;</xsl:text>
  217. <!-- * else, we are not using for "nroff", but instead "troff" - which -->
  218. <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
  219. <!-- * fixed-width font, so use a real .IP instead -->
  220. <xsl:call-template name="roff-else"/>
  221. <!-- * .IP generates a blank line of space, so let’s go backwards one -->
  222. <!-- * line up to compensate for that -->
  223. <xsl:text>.sp -1&#10;</xsl:text>
  224. <xsl:text>.IP "</xsl:text>
  225. <xsl:if test="count(preceding-sibling::listitem) &lt; 9">
  226. <xsl:text> </xsl:text>
  227. </xsl:if>
  228. <xsl:number format="1."/>
  229. <xsl:text>" 4.2&#10;</xsl:text>
  230. <!-- * The value 4.2 is the amount of indentation; we use 4.2 instead -->
  231. <!-- * of 4 because when the font family is Bookman it seems to require -->
  232. <!-- * the extra space. -->
  233. <xsl:call-template name="roff-if-end"/>
  234. <xsl:apply-templates/>
  235. <xsl:text>.RE&#10;</xsl:text>
  236. <xsl:text>&#10;</xsl:text>
  237. </xsl:template>
  238. <xsl:template match="itemizedlist|orderedlist|procedure">
  239. <xsl:if test="title">
  240. <xsl:text>.PP&#10;</xsl:text>
  241. <xsl:call-template name="bold">
  242. <xsl:with-param name="node" select="title"/>
  243. <xsl:with-param name="context" select="."/>
  244. </xsl:call-template>
  245. <xsl:text>&#10;</xsl:text>
  246. </xsl:if>
  247. <!-- * DocBook allows just about any block content to appear in -->
  248. <!-- * lists before the actual list items, so we need to get that -->
  249. <!-- * content (if any) before getting the list items -->
  250. <xsl:apply-templates
  251. select="*[not(self::listitem) and not(self::title)]"/>
  252. <xsl:apply-templates select="listitem"/>
  253. <!-- * If this list is a child of para and has content following -->
  254. <!-- * it, within the same para, then add a blank line and move -->
  255. <!-- * the left margin back to where it was -->
  256. <xsl:if test="parent::para and following-sibling::node()">
  257. <xsl:text>.sp</xsl:text>
  258. <xsl:text>&#10;</xsl:text>
  259. </xsl:if>
  260. </xsl:template>
  261. <xsl:template match="itemizedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  262. orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  263. procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  264. <xsl:if test="title">
  265. <xsl:text>.PP&#10;</xsl:text>
  266. <xsl:call-template name="bold">
  267. <xsl:with-param name="node" select="title"/>
  268. <xsl:with-param name="context" select="."/>
  269. </xsl:call-template>
  270. <xsl:text>&#10;</xsl:text>
  271. </xsl:if>
  272. <xsl:apply-templates/>
  273. <xsl:if test="following-sibling::node() or
  274. parent::para[following-sibling::node()] or
  275. parent::simpara[following-sibling::node()] or
  276. parent::remark[following-sibling::node()]">
  277. <xsl:text>.sp</xsl:text>
  278. <xsl:text>&#10;</xsl:text>
  279. </xsl:if>
  280. </xsl:template>
  281. <!-- ================================================================== -->
  282. <!-- * for simplelist type="inline", render it as a comma-separated list -->
  283. <xsl:template match="simplelist[@type='inline']">
  284. <!-- * if dbchoice PI exists, use that to determine the choice separator -->
  285. <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
  286. <!-- * value of "choice" otherwise -->
  287. <xsl:variable name="localized-choice-separator">
  288. <xsl:choose>
  289. <xsl:when test="processing-instruction('dbchoice')">
  290. <xsl:call-template name="select.choice.separator"/>
  291. </xsl:when>
  292. <xsl:otherwise>
  293. <!-- * empty -->
  294. </xsl:otherwise>
  295. </xsl:choose>
  296. </xsl:variable>
  297. <xsl:for-each select="member">
  298. <xsl:apply-templates/>
  299. <xsl:choose>
  300. <xsl:when test="position() = last()"/> <!-- do nothing -->
  301. <xsl:otherwise>
  302. <xsl:text>, </xsl:text>
  303. <xsl:if test="position() = last() - 1">
  304. <xsl:if test="$localized-choice-separator != ''">
  305. <xsl:value-of select="$localized-choice-separator"/>
  306. <xsl:text> </xsl:text>
  307. </xsl:if>
  308. </xsl:if>
  309. </xsl:otherwise>
  310. </xsl:choose>
  311. </xsl:for-each>
  312. <xsl:text>&#10;</xsl:text>
  313. </xsl:template>
  314. <!-- * if simplelist type is not inline, render it as a one-column vertical -->
  315. <!-- * list (ignoring the values of the type and columns attributes) -->
  316. <xsl:template match="simplelist">
  317. <xsl:for-each select="member">
  318. <xsl:text>.RS</xsl:text>
  319. <xsl:if test="not($list-indent = '')">
  320. <xsl:text> </xsl:text>
  321. <xsl:value-of select="$list-indent"/>
  322. </xsl:if>
  323. <xsl:text>&#10;</xsl:text>
  324. <xsl:apply-templates/>
  325. <xsl:text>&#10;</xsl:text>
  326. <xsl:text>.RE&#10;</xsl:text>
  327. </xsl:for-each>
  328. </xsl:template>
  329. <!-- ================================================================== -->
  330. <!-- * We output Segmentedlist as a table, using tbl(1) markup. There -->
  331. <!-- * is no option for outputting it in manpages in "list" form. -->
  332. <xsl:template match="segmentedlist">
  333. <xsl:if test="title">
  334. <xsl:text>.PP&#10;</xsl:text>
  335. <xsl:call-template name="bold">
  336. <xsl:with-param name="node" select="title"/>
  337. <xsl:with-param name="context" select="."/>
  338. </xsl:call-template>
  339. <xsl:text>&#10;</xsl:text>
  340. </xsl:if>
  341. <xsl:text>.\" line length increase to cope w/ tbl weirdness&#10;</xsl:text>
  342. <xsl:text>.ll +(\n(LLu * 62u / 100u)&#10;</xsl:text>
  343. <!-- * .TS = "Table Start" -->
  344. <xsl:text>.TS&#10;</xsl:text>
  345. <!-- * first output the table "format" spec, which tells tbl(1) how -->
  346. <!-- * how to format each row and column. -->
  347. <xsl:for-each select=".//segtitle">
  348. <!-- * l = "left", which hard-codes left-alignment for tabular -->
  349. <!-- * output of all segmentedlist content -->
  350. <xsl:text>l</xsl:text>
  351. </xsl:for-each>
  352. <!-- * last line of table format section must end with a dot -->
  353. <xsl:text>.&#10;</xsl:text>
  354. <!-- * optionally suppress output of segtitle -->
  355. <xsl:choose>
  356. <xsl:when test="$man.segtitle.suppress != 0">
  357. <!-- * non-zero = "suppress", so do nothing -->
  358. </xsl:when>
  359. <xsl:otherwise>
  360. <!-- * "0" = "do not suppress", so output the segtitle(s) -->
  361. <xsl:apply-templates select=".//segtitle" mode="table-title"/>
  362. <xsl:text>&#10;</xsl:text>
  363. </xsl:otherwise>
  364. </xsl:choose>
  365. <xsl:apply-templates/>
  366. <!-- * .TE = "Table End" -->
  367. <xsl:text>.TE&#10;</xsl:text>
  368. <xsl:text>.\" line length decrease back to previous value&#10;</xsl:text>
  369. <xsl:text>.ll -(\n(LLu * 62u / 100u)&#10;</xsl:text>
  370. <!-- * put a blank line of space below the table -->
  371. <xsl:text>.sp&#10;</xsl:text>
  372. </xsl:template>
  373. <xsl:template match="segmentedlist/segtitle" mode="table-title">
  374. <xsl:call-template name="italic">
  375. <xsl:with-param name="node" select="."/>
  376. <xsl:with-param name="context" select="."/>
  377. </xsl:call-template>
  378. <xsl:choose>
  379. <xsl:when test="position() = last()"/> <!-- do nothing -->
  380. <xsl:otherwise>
  381. <!-- * tbl(1) treats tab characters as delimiters between -->
  382. <!-- * cells; so we need to output a tab after each -->
  383. <!-- * segtitle except the last one -->
  384. <xsl:text>&#09;</xsl:text>
  385. </xsl:otherwise>
  386. </xsl:choose>
  387. </xsl:template>
  388. <xsl:template match="segmentedlist/seglistitem">
  389. <xsl:apply-templates/>
  390. <xsl:text>&#10;</xsl:text>
  391. </xsl:template>
  392. <xsl:template match="segmentedlist/seglistitem/seg">
  393. <!-- * the T{ and T} stuff are delimiters to tell tbl(1) that -->
  394. <!-- * the delimited contents are "text blocks" that groff(1) -->
  395. <!-- * needs to process -->
  396. <xsl:text>T{&#10;</xsl:text>
  397. <xsl:variable name="contents">
  398. <xsl:apply-templates/>
  399. </xsl:variable>
  400. <xsl:value-of select="normalize-space($contents)"/>
  401. <xsl:text>&#10;T}</xsl:text>
  402. <xsl:choose>
  403. <xsl:when test="position() = last()"/> <!-- do nothing -->
  404. <xsl:otherwise>
  405. <!-- * tbl(1) treats tab characters as delimiters between -->
  406. <!-- * cells; so we need to output a tab after each -->
  407. <!-- * segtitle except the last one -->
  408. <xsl:text>&#09;</xsl:text>
  409. </xsl:otherwise>
  410. </xsl:choose>
  411. </xsl:template>
  412. <!-- ==================================================================== -->
  413. <xsl:template match="calloutlist">
  414. <xsl:if test="title|info/title">
  415. <xsl:call-template name="formal.object.heading"/>
  416. </xsl:if>
  417. <!-- * This template was originally copied over from the HTML -->
  418. <!-- * calloutlist template, which precedes the following -->
  419. <!-- * apply-templates with the comment "Preserve order of PIs and -->
  420. <!-- * comments"; I'm not certain that it will actually have that -->
  421. <!-- * effect for all cases, and it seems like there is probably a -->
  422. <!-- * better way to do it, but anyway, I’m preserving it here for -->
  423. <!-- * consistency. -->
  424. <xsl:apply-templates
  425. select="*[not(self::callout or self::title or self::titleabbrev)]
  426. |comment()[not(preceding-sibling::callout)]
  427. |processing-instruction()[not(preceding-sibling::callout)]"/>
  428. <!-- * put callout list into a table -->
  429. <xsl:text>.TS&#10;</xsl:text>
  430. <xsl:text>tab(:);&#10;</xsl:text>
  431. <!-- * the following defines the row layout for the table: two columns, -->
  432. <!-- * with the first cell in each row right-aligned, and the second -->
  433. <!-- * cell left aligned with a width of 75% of the line length -->
  434. <xsl:text>r lw(\n(.lu*75u/100u).&#10;</xsl:text>
  435. <xsl:apply-templates select="callout
  436. |comment()[preceding-sibling::callout]
  437. |processing-instruction()[preceding-sibling::callout]"/>
  438. <xsl:text>.TE&#10;</xsl:text>
  439. </xsl:template>
  440. <xsl:template match="calloutlist/title"/>
  441. <xsl:template match="callout">
  442. <!-- * first cell of each row is the set of callout numbers for this -->
  443. <!-- * particular callout -->
  444. <xsl:call-template name="callout.arearefs">
  445. <xsl:with-param name="arearefs" select="@arearefs"/>
  446. </xsl:call-template>
  447. <!-- * end of the first cell in the row; the \h hackery is to correct -->
  448. <!-- * for the excessive horizontal whitespace that tbl(1) adds between -->
  449. <!-- * cells in the same row -->
  450. <xsl:text>\h'-2n':</xsl:text>
  451. <!-- * start the next cell in the row, which has the prose contents -->
  452. <!-- * (description/explanation) for the callout -->
  453. <xsl:text>T{&#10;</xsl:text>
  454. <xsl:apply-templates/>
  455. <xsl:text>T}&#10;</xsl:text>
  456. <!-- * end of the last cell and end of the row -->
  457. </xsl:template>
  458. <xsl:template name="callout.arearefs">
  459. <xsl:param name="arearefs"></xsl:param>
  460. <!-- * callout can have multiple values in its arearefs attribute, so -->
  461. <!-- * we use the position param to track the postion of each value -->
  462. <xsl:param name="position">1</xsl:param>
  463. <xsl:if test="$arearefs!=''">
  464. <xsl:choose>
  465. <xsl:when test="substring-before($arearefs,' ')=''">
  466. <xsl:call-template name="callout.arearef">
  467. <xsl:with-param name="arearef" select="$arearefs"/>
  468. <xsl:with-param name="position" select="$position"/>
  469. </xsl:call-template>
  470. </xsl:when>
  471. <xsl:otherwise>
  472. <xsl:call-template name="callout.arearef">
  473. <xsl:with-param name="arearef"
  474. select="substring-before($arearefs,' ')"/>
  475. <xsl:with-param name="position" select="$position"/>
  476. </xsl:call-template>
  477. </xsl:otherwise>
  478. </xsl:choose>
  479. <xsl:call-template name="callout.arearefs">
  480. <xsl:with-param name="arearefs"
  481. select="substring-after($arearefs,' ')"/>
  482. <xsl:with-param name="position" select="$position + 1"/>
  483. </xsl:call-template>
  484. </xsl:if>
  485. </xsl:template>
  486. <xsl:template name="callout.arearef">
  487. <xsl:param name="arearef"></xsl:param>
  488. <!-- * callout can have multiple values in its arearefs attribute, so -->
  489. <!-- * we use the position param to track the postion of each value -->
  490. <xsl:param name="position"></xsl:param>
  491. <xsl:variable name="targets" select="key('id',$arearef)"/>
  492. <xsl:variable name="target" select="$targets[1]"/>
  493. <xsl:call-template name="check.id.unique">
  494. <xsl:with-param name="linkend" select="$arearef"/>
  495. </xsl:call-template>
  496. <xsl:choose>
  497. <xsl:when test="count($target)=0">
  498. <xsl:text>???</xsl:text>
  499. </xsl:when>
  500. <xsl:when test="local-name($target)='co'">
  501. <!-- * if this is not the first value in the set of values in the -->
  502. <!-- * arearef attribute for this callout, then we prepend a groff -->
  503. <!-- * non-breaking space to it, to prevent groff from injecting -->
  504. <!-- * linebreaks into the output. For callout instances with -->
  505. <!-- * multiple values in their arearefs attributes, that results -->
  506. <!-- * in all of callout numbers beings listed on the same line. -->
  507. <xsl:if test="not($position = 1)">
  508. <xsl:text>\ </xsl:text>
  509. </xsl:if>
  510. <xsl:apply-templates select="$target"
  511. mode="calloutlist-callout-number"/>
  512. </xsl:when>
  513. <!-- * the manpages stylesheet does not really support areaset and -->
  514. <!-- * area (because we can't/don't actually render the callout bugs -->
  515. <!-- * at the specified coordinates); however, the following (for -->
  516. <!-- * what it's worth) might cause the callout numbers in the -->
  517. <!-- * calloutlist to be render at least (then again, maybe it won't; -->
  518. <!-- * it's not actually been tested... -->
  519. <xsl:when test="local-name($target)='areaset'">
  520. <xsl:call-template name="callout-bug">
  521. <xsl:with-param name="conum">
  522. <xsl:apply-templates select="$target" mode="conumber"/>
  523. </xsl:with-param>
  524. </xsl:call-template>
  525. </xsl:when>
  526. <xsl:when test="local-name($target)='area'">
  527. <xsl:choose>
  528. <xsl:when test="$target/parent::areaset">
  529. <xsl:call-template name="callout-bug">
  530. <xsl:with-param name="conum">
  531. <xsl:apply-templates
  532. select="$target/parent::areaset" mode="conumber"/>
  533. </xsl:with-param>
  534. </xsl:call-template>
  535. </xsl:when>
  536. <xsl:otherwise>
  537. <xsl:call-template name="callout-bug">
  538. <xsl:with-param name="conum">
  539. <xsl:apply-templates select="$target"
  540. mode="conumber"/>
  541. </xsl:with-param>
  542. </xsl:call-template>
  543. </xsl:otherwise>
  544. </xsl:choose>
  545. </xsl:when>
  546. <xsl:otherwise>
  547. <xsl:text>???</xsl:text>
  548. </xsl:otherwise>
  549. </xsl:choose>
  550. </xsl:template>
  551. <!-- * we bold the actual callout bugs and put -->
  552. <!-- * parenthesis around them -->
  553. <xsl:template name="callout-bug">
  554. <xsl:param name="conum" select='1'/>
  555. <xsl:text>\fB(</xsl:text>
  556. <xsl:value-of select="$conum"/>
  557. <xsl:text>)\fR</xsl:text>
  558. </xsl:template>
  559. <!-- * we bold the callout numbers and follow each -->
  560. <!-- * with a period -->
  561. <xsl:template name="calloutlist-callout-number">
  562. <xsl:param name="conum" select='1'/>
  563. <xsl:text>\fB</xsl:text>
  564. <xsl:value-of select="$conum"/>
  565. <xsl:text>.\fR</xsl:text>
  566. </xsl:template>
  567. <xsl:template match="co" mode="calloutlist-callout-number">
  568. <xsl:call-template name="calloutlist-callout-number">
  569. <xsl:with-param name="conum">
  570. <xsl:number count="co"
  571. level="any"
  572. from="programlisting|screen|literallayout|synopsis"
  573. format="1"/>
  574. </xsl:with-param>
  575. </xsl:call-template>
  576. </xsl:template>
  577. </xsl:stylesheet>