| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
version='1.0'> |
| 4 |
|
| 5 |
<!-- ******************************************************************** |
| 6 |
$Id: lists.xsl 6843 2007-06-20 12:21:13Z xmldoc $ |
| 7 |
******************************************************************** |
| 8 |
|
| 9 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 10 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 11 |
copyright and other information. |
| 12 |
|
| 13 |
******************************************************************** --> |
| 14 |
|
| 15 |
<xsl:variable name="list-indent"> |
| 16 |
<xsl:choose> |
| 17 |
<xsl:when test="not($man.indent.lists = 0)"> |
| 18 |
<xsl:value-of select="$man.indent.width"/> |
| 19 |
</xsl:when> |
| 20 |
<xsl:when test="not($man.indent.refsect = 0)"> |
| 21 |
<!-- * "zq" is the name of a register we set for --> |
| 22 |
<!-- * preserving the original default indent value --> |
| 23 |
<!-- * when $man.indent.refsect is non-zero; --> |
| 24 |
<!-- * "u" is a roff unit specifier --> |
| 25 |
<xsl:text>\n(zqu</xsl:text> |
| 26 |
</xsl:when> |
| 27 |
<xsl:otherwise/> <!-- * otherwise, just leave it empty --> |
| 28 |
</xsl:choose> |
| 29 |
</xsl:variable> |
| 30 |
|
| 31 |
<!-- ================================================================== --> |
| 32 |
|
| 33 |
<xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]| |
| 34 |
simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]| |
| 35 |
remark[ancestor::listitem or ancestor::step or ancestor::glossdef]"> |
| 36 |
<xsl:call-template name="mixed-block"/> |
| 37 |
<xsl:text> </xsl:text> |
| 38 |
<xsl:if test="following-sibling::*[1][ |
| 39 |
self::para or |
| 40 |
self::simpara or |
| 41 |
self::remark |
| 42 |
]"> |
| 43 |
<!-- * Make sure multiple paragraphs within a list item don't --> |
| 44 |
<!-- * merge together. --> |
| 45 |
<xsl:text>.sp </xsl:text> |
| 46 |
</xsl:if> |
| 47 |
</xsl:template> |
| 48 |
|
| 49 |
<xsl:template match="variablelist|glosslist"> |
| 50 |
<xsl:if test="title"> |
| 51 |
<xsl:text>.PP </xsl:text> |
| 52 |
<xsl:call-template name="bold"> |
| 53 |
<xsl:with-param name="node" select="title"/> |
| 54 |
<xsl:with-param name="context" select="."/> |
| 55 |
</xsl:call-template> |
| 56 |
<xsl:text> </xsl:text> |
| 57 |
</xsl:if> |
| 58 |
<xsl:apply-templates/> |
| 59 |
</xsl:template> |
| 60 |
|
| 61 |
<xsl:template match="varlistentry|glossentry"> |
| 62 |
<xsl:text>.PP </xsl:text> |
| 63 |
<xsl:for-each select="term|glossterm"> |
| 64 |
<xsl:variable name="content"> |
| 65 |
<xsl:apply-templates/> |
| 66 |
</xsl:variable> |
| 67 |
<xsl:value-of select="normalize-space($content)"/> |
| 68 |
<xsl:choose> |
| 69 |
<xsl:when test="position() = last()"/> <!-- do nothing --> |
| 70 |
<xsl:otherwise> |
| 71 |
<!-- * if we have multiple terms in the same varlistentry, generate --> |
| 72 |
<!-- * a separator (", " by default) and/or an additional line --> |
| 73 |
<!-- * break after each one except the last --> |
| 74 |
<!-- * --> |
| 75 |
<!-- * note that it is not valid to have multiple glossterms --> |
| 76 |
<!-- * within a glossentry, so this logic never gets exercised --> |
| 77 |
<!-- * for glossterms (every glossterm is always the last in --> |
| 78 |
<!-- * its parent glossentry) --> |
| 79 |
<xsl:value-of select="$variablelist.term.separator"/> |
| 80 |
<xsl:if test="not($variablelist.term.break.after = '0')"> |
| 81 |
<xsl:text> </xsl:text> |
| 82 |
<xsl:text>.br </xsl:text> |
| 83 |
</xsl:if> |
| 84 |
</xsl:otherwise> |
| 85 |
</xsl:choose> |
| 86 |
</xsl:for-each> |
| 87 |
<xsl:text> </xsl:text> |
| 88 |
<xsl:text>.RS</xsl:text> |
| 89 |
<xsl:if test="not($list-indent = '')"> |
| 90 |
<xsl:text> </xsl:text> |
| 91 |
<xsl:value-of select="$list-indent"/> |
| 92 |
</xsl:if> |
| 93 |
<xsl:text> </xsl:text> |
| 94 |
<xsl:apply-templates/> |
| 95 |
<xsl:text>.RE </xsl:text> |
| 96 |
</xsl:template> |
| 97 |
|
| 98 |
<xsl:template match="varlistentry/term"/> |
| 99 |
<xsl:template match="glossentry/glossterm"/> |
| 100 |
|
| 101 |
<xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]| |
| 102 |
glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]"> |
| 103 |
<xsl:apply-templates/> |
| 104 |
<xsl:if test="following-sibling::node() or |
| 105 |
parent::para[following-sibling::node()] or |
| 106 |
parent::simpara[following-sibling::node()] or |
| 107 |
parent::remark[following-sibling::node()]"> |
| 108 |
<xsl:text>.sp</xsl:text> |
| 109 |
<xsl:text> </xsl:text> |
| 110 |
</xsl:if> |
| 111 |
</xsl:template> |
| 112 |
|
| 113 |
<xsl:template match="varlistentry/listitem|glossentry/glossdef"> |
| 114 |
<xsl:apply-templates/> |
| 115 |
</xsl:template> |
| 116 |
|
| 117 |
<xsl:template match="itemizedlist/listitem"> |
| 118 |
<!-- * We output a real bullet here (rather than, "\(bu", --> |
| 119 |
<!-- * the roff bullet) because, when we do character-map --> |
| 120 |
<!-- * processing before final output, the character-map will --> |
| 121 |
<!-- * handle conversion of the • to "\(bu" for us --> |
| 122 |
<xsl:text> </xsl:text> |
| 123 |
<xsl:text>.sp</xsl:text> |
| 124 |
<xsl:text> </xsl:text> |
| 125 |
<xsl:text>.RS</xsl:text> |
| 126 |
<xsl:if test="not($list-indent = '')"> |
| 127 |
<xsl:text> </xsl:text> |
| 128 |
<xsl:value-of select="$list-indent"/> |
| 129 |
</xsl:if> |
| 130 |
<xsl:text> </xsl:text> |
| 131 |
<xsl:text>\h'-</xsl:text> |
| 132 |
<xsl:if test="not($list-indent = '')"> |
| 133 |
<xsl:text>0</xsl:text> |
| 134 |
<xsl:value-of select="$list-indent"/> |
| 135 |
</xsl:if> |
| 136 |
<xsl:text>'</xsl:text> |
| 137 |
<xsl:text>•</xsl:text> |
| 138 |
<xsl:text>\h'+</xsl:text> |
| 139 |
<xsl:if test="not($list-indent = '')"> |
| 140 |
<xsl:text>0</xsl:text> |
| 141 |
<xsl:value-of select="$list-indent - 1"/> |
| 142 |
<xsl:text>'</xsl:text> |
| 143 |
</xsl:if> |
| 144 |
<xsl:apply-templates/> |
| 145 |
<xsl:text>.RE </xsl:text> |
| 146 |
</xsl:template> |
| 147 |
|
| 148 |
<xsl:template match="orderedlist/listitem|procedure/step"> |
| 149 |
<xsl:text> </xsl:text> |
| 150 |
<xsl:text>.sp</xsl:text> |
| 151 |
<xsl:text> </xsl:text> |
| 152 |
<xsl:text>.RS</xsl:text> |
| 153 |
<xsl:if test="not($list-indent = '')"> |
| 154 |
<xsl:text> </xsl:text> |
| 155 |
<xsl:value-of select="$list-indent"/> |
| 156 |
</xsl:if> |
| 157 |
<xsl:text> </xsl:text> |
| 158 |
<xsl:text>\h'-</xsl:text> |
| 159 |
<xsl:if test="not($list-indent = '')"> |
| 160 |
<xsl:text>0</xsl:text> |
| 161 |
<xsl:value-of select="$list-indent"/> |
| 162 |
</xsl:if> |
| 163 |
<xsl:text>'</xsl:text> |
| 164 |
<xsl:if test="count(preceding-sibling::listitem) < 9"> |
| 165 |
<xsl:text> </xsl:text> |
| 166 |
</xsl:if> |
| 167 |
<xsl:number format="1."/> |
| 168 |
<xsl:text>\h'+</xsl:text> |
| 169 |
<xsl:if test="not($list-indent = '')"> |
| 170 |
<xsl:text>0</xsl:text> |
| 171 |
<xsl:value-of select="$list-indent - 2"/> |
| 172 |
<xsl:text>'</xsl:text> |
| 173 |
</xsl:if> |
| 174 |
<xsl:apply-templates/> |
| 175 |
<xsl:text>.RE </xsl:text> |
| 176 |
<xsl:text> </xsl:text> |
| 177 |
</xsl:template> |
| 178 |
|
| 179 |
<xsl:template match="itemizedlist|orderedlist|procedure"> |
| 180 |
<xsl:if test="title"> |
| 181 |
<xsl:text>.PP </xsl:text> |
| 182 |
<xsl:call-template name="bold"> |
| 183 |
<xsl:with-param name="node" select="title"/> |
| 184 |
<xsl:with-param name="context" select="."/> |
| 185 |
</xsl:call-template> |
| 186 |
<xsl:text> </xsl:text> |
| 187 |
</xsl:if> |
| 188 |
<!-- * DocBook allows just about any block content to appear in --> |
| 189 |
<!-- * lists before the actual list items, so we need to get that --> |
| 190 |
<!-- * content (if any) before getting the list items --> |
| 191 |
<xsl:apply-templates |
| 192 |
select="*[not(self::listitem) and not(self::title)]"/> |
| 193 |
<xsl:apply-templates select="listitem"/> |
| 194 |
<!-- * If this list is a child of para and has content following --> |
| 195 |
<!-- * it, within the same para, then add a blank line and move --> |
| 196 |
<!-- * the left margin back to where it was --> |
| 197 |
<xsl:if test="parent::para and following-sibling::node()"> |
| 198 |
<xsl:text>.sp </xsl:text> |
| 199 |
<xsl:text>.RE </xsl:text> |
| 200 |
</xsl:if> |
| 201 |
</xsl:template> |
| 202 |
|
| 203 |
<xsl:template match="itemizedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]| |
| 204 |
orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]| |
| 205 |
procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]"> |
| 206 |
<xsl:if test="title"> |
| 207 |
<xsl:text>.PP </xsl:text> |
| 208 |
<xsl:call-template name="bold"> |
| 209 |
<xsl:with-param name="node" select="title"/> |
| 210 |
<xsl:with-param name="context" select="."/> |
| 211 |
</xsl:call-template> |
| 212 |
<xsl:text> </xsl:text> |
| 213 |
</xsl:if> |
| 214 |
<xsl:apply-templates/> |
| 215 |
<xsl:if test="following-sibling::node() or |
| 216 |
parent::para[following-sibling::node()] or |
| 217 |
parent::simpara[following-sibling::node()] or |
| 218 |
parent::remark[following-sibling::node()]"> |
| 219 |
<xsl:text>.IP ""</xsl:text> |
| 220 |
<xsl:if test="not($list-indent = '')"> |
| 221 |
<xsl:text> </xsl:text> |
| 222 |
<xsl:value-of select="$list-indent"/> |
| 223 |
</xsl:if> |
| 224 |
<xsl:text> </xsl:text> |
| 225 |
</xsl:if> |
| 226 |
</xsl:template> |
| 227 |
|
| 228 |
<!-- ================================================================== --> |
| 229 |
|
| 230 |
<!-- * for simplelist type="inline", render it as a comma-separated list --> |
| 231 |
<xsl:template match="simplelist[@type='inline']"> |
| 232 |
|
| 233 |
<!-- * if dbchoice PI exists, use that to determine the choice separator --> |
| 234 |
<!-- * (that is, equivalent of "and" or "or" in current locale), or literal --> |
| 235 |
<!-- * value of "choice" otherwise --> |
| 236 |
<xsl:variable name="localized-choice-separator"> |
| 237 |
<xsl:choose> |
| 238 |
<xsl:when test="processing-instruction('dbchoice')"> |
| 239 |
<xsl:call-template name="select.choice.separator"/> |
| 240 |
</xsl:when> |
| 241 |
<xsl:otherwise> |
| 242 |
<!-- * empty --> |
| 243 |
</xsl:otherwise> |
| 244 |
</xsl:choose> |
| 245 |
</xsl:variable> |
| 246 |
|
| 247 |
<xsl:for-each select="member"> |
| 248 |
<xsl:apply-templates/> |
| 249 |
<xsl:choose> |
| 250 |
<xsl:when test="position() = last()"/> <!-- do nothing --> |
| 251 |
<xsl:otherwise> |
| 252 |
<xsl:text>, </xsl:text> |
| 253 |
<xsl:if test="position() = last() - 1"> |
| 254 |
<xsl:if test="$localized-choice-separator != ''"> |
| 255 |
<xsl:value-of select="$localized-choice-separator"/> |
| 256 |
<xsl:text> </xsl:text> |
| 257 |
</xsl:if> |
| 258 |
</xsl:if> |
| 259 |
</xsl:otherwise> |
| 260 |
</xsl:choose> |
| 261 |
</xsl:for-each> |
| 262 |
<xsl:text> </xsl:text> |
| 263 |
</xsl:template> |
| 264 |
|
| 265 |
<!-- * if simplelist type is not inline, render it as a one-column vertical --> |
| 266 |
<!-- * list (ignoring the values of the type and columns attributes) --> |
| 267 |
<xsl:template match="simplelist"> |
| 268 |
<xsl:for-each select="member"> |
| 269 |
<xsl:text>.IP ""</xsl:text> |
| 270 |
<xsl:if test="not($list-indent = '')"> |
| 271 |
<xsl:text> </xsl:text> |
| 272 |
<xsl:value-of select="$list-indent"/> |
| 273 |
</xsl:if> |
| 274 |
<xsl:text> </xsl:text> |
| 275 |
<xsl:apply-templates/> |
| 276 |
<xsl:text> </xsl:text> |
| 277 |
</xsl:for-each> |
| 278 |
</xsl:template> |
| 279 |
|
| 280 |
<!-- ================================================================== --> |
| 281 |
|
| 282 |
<!-- * We output Segmentedlist as a table, using tbl(1) markup. There --> |
| 283 |
<!-- * is no option for outputting it in manpages in "list" form. --> |
| 284 |
<xsl:template match="segmentedlist"> |
| 285 |
<xsl:if test="title"> |
| 286 |
<xsl:text>.PP </xsl:text> |
| 287 |
<xsl:call-template name="bold"> |
| 288 |
<xsl:with-param name="node" select="title"/> |
| 289 |
<xsl:with-param name="context" select="."/> |
| 290 |
</xsl:call-template> |
| 291 |
<xsl:text> </xsl:text> |
| 292 |
</xsl:if> |
| 293 |
<xsl:text>.\" line length increase to cope w/ tbl weirdness </xsl:text> |
| 294 |
<xsl:text>.ll +(\n(LLu * 62u / 100u) </xsl:text> |
| 295 |
<!-- * .TS = "Table Start" --> |
| 296 |
<xsl:text>.TS </xsl:text> |
| 297 |
<!-- * first output the table "format" spec, which tells tbl(1) how --> |
| 298 |
<!-- * how to format each row and column. --> |
| 299 |
<xsl:for-each select=".//segtitle"> |
| 300 |
<!-- * l = "left", which hard-codes left-alignment for tabular --> |
| 301 |
<!-- * output of all segmentedlist content --> |
| 302 |
<xsl:text>l</xsl:text> |
| 303 |
</xsl:for-each> |
| 304 |
<!-- * last line of table format section must end with a dot --> |
| 305 |
<xsl:text>. </xsl:text> |
| 306 |
<!-- * optionally suppress output of segtitle --> |
| 307 |
<xsl:choose> |
| 308 |
<xsl:when test="$man.segtitle.suppress != 0"> |
| 309 |
<!-- * non-zero = "suppress", so do nothing --> |
| 310 |
</xsl:when> |
| 311 |
<xsl:otherwise> |
| 312 |
<!-- * "0" = "do not suppress", so output the segtitle(s) --> |
| 313 |
<xsl:apply-templates select=".//segtitle" mode="table-title"/> |
| 314 |
<xsl:text> </xsl:text> |
| 315 |
</xsl:otherwise> |
| 316 |
</xsl:choose> |
| 317 |
<xsl:apply-templates/> |
| 318 |
<!-- * .TE = "Table End" --> |
| 319 |
<xsl:text>.TE </xsl:text> |
| 320 |
<xsl:text>.\" line length decrease back to previous value </xsl:text> |
| 321 |
<xsl:text>.ll -(\n(LLu * 62u / 100u) </xsl:text> |
| 322 |
<!-- * put a blank line of space below the table --> |
| 323 |
<xsl:text>.sp </xsl:text> |
| 324 |
</xsl:template> |
| 325 |
|
| 326 |
<xsl:template match="segmentedlist/segtitle" mode="table-title"> |
| 327 |
<xsl:call-template name="italic"> |
| 328 |
<xsl:with-param name="node" select="."/> |
| 329 |
<xsl:with-param name="context" select="."/> |
| 330 |
</xsl:call-template> |
| 331 |
<xsl:choose> |
| 332 |
<xsl:when test="position() = last()"/> <!-- do nothing --> |
| 333 |
<xsl:otherwise> |
| 334 |
<!-- * tbl(1) treats tab characters as delimiters between --> |
| 335 |
<!-- * cells; so we need to output a tab after each except --> |
| 336 |
<!-- * segtitle except the last one --> |
| 337 |
<xsl:text>	</xsl:text> |
| 338 |
</xsl:otherwise> |
| 339 |
</xsl:choose> |
| 340 |
</xsl:template> |
| 341 |
|
| 342 |
<xsl:template match="segmentedlist/seglistitem"> |
| 343 |
<xsl:apply-templates/> |
| 344 |
<xsl:text> </xsl:text> |
| 345 |
</xsl:template> |
| 346 |
|
| 347 |
<xsl:template match="segmentedlist/seglistitem/seg"> |
| 348 |
<!-- * the “T{" and “T}” stuff are delimiters to tell tbl(1) that --> |
| 349 |
<!-- * the delimited contents are "text blocks" that groff(1) --> |
| 350 |
<!-- * needs to process --> |
| 351 |
<xsl:text>T{ </xsl:text> |
| 352 |
<xsl:variable name="contents"> |
| 353 |
<xsl:apply-templates/> |
| 354 |
</xsl:variable> |
| 355 |
<xsl:value-of select="normalize-space($contents)"/> |
| 356 |
<xsl:text> T}</xsl:text> |
| 357 |
<xsl:choose> |
| 358 |
<xsl:when test="position() = last()"/> <!-- do nothing --> |
| 359 |
<xsl:otherwise> |
| 360 |
<!-- * tbl(1) treats tab characters as delimiters between --> |
| 361 |
<!-- * cells; so we need to output a tab after each except --> |
| 362 |
<!-- * segtitle except the last one --> |
| 363 |
<xsl:text>	</xsl:text> |
| 364 |
</xsl:otherwise> |
| 365 |
</xsl:choose> |
| 366 |
</xsl:template> |
| 367 |
|
| 368 |
</xsl:stylesheet> |