| 1 |
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> |
| 2 |
<!-- |
| 3 |
This program is free software; you can redistribute it and/or modify it under |
| 4 |
the terms of the GNU Lesser General Public License as published by the Free |
| 5 |
Software Foundation; either version 2 of the License, or (at your option) any |
| 6 |
later version. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 11 |
details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU Lesser General Public License |
| 14 |
along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
--> |
| 16 |
|
| 17 |
|
| 18 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 19 |
xmlns:db="http://docbook.org/ns/docbook" |
| 20 |
xmlns:set="http://exslt.org/sets" |
| 21 |
xmlns:str="http://exslt.org/strings" |
| 22 |
xmlns="http://www.w3.org/1999/xhtml" |
| 23 |
exclude-result-prefixes="db set str" |
| 24 |
version="1.0"> |
| 25 |
|
| 26 |
<!--!!========================================================================== |
| 27 |
DocBook to HTML - Command Synopses |
| 28 |
@revision[version=1.0 date=2011-05-16 status=final] |
| 29 |
|
| 30 |
This module contains templates to process DocBook command synopsis elements. |
| 31 |
--> |
| 32 |
|
| 33 |
|
| 34 |
<!-- == Matched Templates == --> |
| 35 |
|
| 36 |
<!-- = arg = --> |
| 37 |
<xsl:template match="arg | db:arg"> |
| 38 |
<xsl:param name="sepchar"> |
| 39 |
<xsl:choose> |
| 40 |
<xsl:when test="ancestor::cmdsynopsis[1][@sepchar]"> |
| 41 |
<xsl:value-of select="ancestor::cmdsynopsis[1]/@sepchar"/> |
| 42 |
</xsl:when> |
| 43 |
<xsl:when test="ancestor::db:cmdsynopsis[1][@sepchar]"> |
| 44 |
<xsl:value-of select="ancestor::db:cmdsynopsis[1]/@sepchar"/> |
| 45 |
</xsl:when> |
| 46 |
<xsl:otherwise> |
| 47 |
<xsl:text> </xsl:text> |
| 48 |
</xsl:otherwise> |
| 49 |
</xsl:choose> |
| 50 |
</xsl:param> |
| 51 |
<xsl:param name="choice"> |
| 52 |
<xsl:choose> |
| 53 |
<xsl:when test="@choice"> |
| 54 |
<xsl:value-of select="@choice"/> |
| 55 |
</xsl:when> |
| 56 |
<xsl:otherwise> |
| 57 |
<xsl:value-of select="'opt'"/> |
| 58 |
</xsl:otherwise> |
| 59 |
</xsl:choose> |
| 60 |
</xsl:param> |
| 61 |
<xsl:param name="rep"> |
| 62 |
<xsl:choose> |
| 63 |
<xsl:when test="@rep"> |
| 64 |
<xsl:value-of select="@rep"/> |
| 65 |
</xsl:when> |
| 66 |
<xsl:otherwise> |
| 67 |
<xsl:value-of select="'norepeat'"/> |
| 68 |
</xsl:otherwise> |
| 69 |
</xsl:choose> |
| 70 |
</xsl:param> |
| 71 |
|
| 72 |
<span class="arg-punc"> |
| 73 |
<xsl:choose> |
| 74 |
<xsl:when test="$choice = 'plain'"/> |
| 75 |
<xsl:when test="$choice = 'req'"> |
| 76 |
<xsl:text>{</xsl:text> |
| 77 |
</xsl:when> |
| 78 |
<xsl:otherwise> |
| 79 |
<xsl:text>[</xsl:text> |
| 80 |
</xsl:otherwise> |
| 81 |
</xsl:choose> |
| 82 |
<span> |
| 83 |
<xsl:call-template name="html.class.attr"> |
| 84 |
<xsl:with-param name="class" select="'arg'"/> |
| 85 |
</xsl:call-template> |
| 86 |
<xsl:for-each select="node()"> |
| 87 |
<xsl:choose> |
| 88 |
<xsl:when test="self::sbr or self::db:sbr"> |
| 89 |
<xsl:text>
</xsl:text> |
| 90 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 91 |
select="ancestor::cmdsynopsis[1] | |
| 92 |
ancestor::db:cmdsynopsis[1]"> |
| 93 |
<xsl:with-param name="sbr" select="."/> |
| 94 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 95 |
</xsl:apply-templates> |
| 96 |
</xsl:when> |
| 97 |
<xsl:otherwise> |
| 98 |
<xsl:apply-templates select="."> |
| 99 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 100 |
</xsl:apply-templates> |
| 101 |
</xsl:otherwise> |
| 102 |
</xsl:choose> |
| 103 |
</xsl:for-each> |
| 104 |
</span> |
| 105 |
<xsl:if test="$rep = 'repeat'"> |
| 106 |
<xsl:text>...</xsl:text> |
| 107 |
</xsl:if> |
| 108 |
<xsl:choose> |
| 109 |
<xsl:when test="$choice = 'plain'"/> |
| 110 |
<xsl:when test="$choice = 'req'"> |
| 111 |
<xsl:text>}</xsl:text> |
| 112 |
</xsl:when> |
| 113 |
<xsl:otherwise> |
| 114 |
<xsl:text>]</xsl:text> |
| 115 |
</xsl:otherwise> |
| 116 |
</xsl:choose> |
| 117 |
</span> |
| 118 |
</xsl:template> |
| 119 |
|
| 120 |
<!-- = cmdsynopsis = --> |
| 121 |
<xsl:template match="cmdsynopsis | db:cmdsynopsis"> |
| 122 |
<xsl:param name="sepchar"> |
| 123 |
<xsl:choose> |
| 124 |
<xsl:when test="@sepchar"> |
| 125 |
<xsl:value-of select="@sepchar"/> |
| 126 |
</xsl:when> |
| 127 |
<xsl:otherwise> |
| 128 |
<xsl:text> </xsl:text> |
| 129 |
</xsl:otherwise> |
| 130 |
</xsl:choose> |
| 131 |
</xsl:param> |
| 132 |
<xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable> |
| 133 |
<xsl:if test="$if != ''"> |
| 134 |
<div> |
| 135 |
<xsl:call-template name="html.class.attr"> |
| 136 |
<xsl:with-param name="class" select="'synopsis cmdsynopsis'"/> |
| 137 |
</xsl:call-template> |
| 138 |
<xsl:call-template name="html.lang.attrs"/> |
| 139 |
<xsl:call-template name="db2html.anchor"/> |
| 140 |
<pre class="contents cmdsynopsis"> |
| 141 |
<xsl:for-each select="command | arg | group | sbr | |
| 142 |
db:command | db:arg | db:group | db:sbr"> |
| 143 |
<xsl:choose> |
| 144 |
<xsl:when test="position() = 1"/> |
| 145 |
<xsl:when test="self::sbr"> |
| 146 |
<xsl:text>
</xsl:text> |
| 147 |
<xsl:value-of select="str:padding(string-length(preceding-sibling::command[1]), ' ')"/> |
| 148 |
</xsl:when> |
| 149 |
<xsl:when test="self::db:sbr"> |
| 150 |
<xsl:text>
</xsl:text> |
| 151 |
<xsl:value-of select="str:padding(string-length(preceding-sibling::db:command[1]), ' ')"/> |
| 152 |
</xsl:when> |
| 153 |
<xsl:when test="self::command or self::db:command"> |
| 154 |
<xsl:text>
</xsl:text> |
| 155 |
</xsl:when> |
| 156 |
<xsl:otherwise> |
| 157 |
<xsl:value-of select="$sepchar"/> |
| 158 |
</xsl:otherwise> |
| 159 |
</xsl:choose> |
| 160 |
<xsl:apply-templates select="."> |
| 161 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 162 |
</xsl:apply-templates> |
| 163 |
</xsl:for-each> |
| 164 |
<xsl:apply-templates select="synopfragment | db:synopfragment"> |
| 165 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 166 |
</xsl:apply-templates> |
| 167 |
</pre> |
| 168 |
</div> |
| 169 |
</xsl:if> |
| 170 |
</xsl:template> |
| 171 |
|
| 172 |
<!-- = group = --> |
| 173 |
<xsl:template match="group | db:group"> |
| 174 |
<xsl:param name="sepchar"> |
| 175 |
<xsl:choose> |
| 176 |
<xsl:when test="ancestor::cmdsynopsis[1][@sepchar]"> |
| 177 |
<xsl:value-of select="ancestor::cmdsynopsis[1]/@sepchar"/> |
| 178 |
</xsl:when> |
| 179 |
<xsl:when test="ancestor::db:cmdsynopsis[1][@sepchar]"> |
| 180 |
<xsl:value-of select="ancestor::db:cmdsynopsis[1]/@sepchar"/> |
| 181 |
</xsl:when> |
| 182 |
<xsl:otherwise> |
| 183 |
<xsl:text> </xsl:text> |
| 184 |
</xsl:otherwise> |
| 185 |
</xsl:choose> |
| 186 |
</xsl:param> |
| 187 |
<xsl:param name="choice"> |
| 188 |
<xsl:choose> |
| 189 |
<xsl:when test="@choice"> |
| 190 |
<xsl:value-of select="@choice"/> |
| 191 |
</xsl:when> |
| 192 |
<xsl:otherwise> |
| 193 |
<xsl:value-of select="'opt'"/> |
| 194 |
</xsl:otherwise> |
| 195 |
</xsl:choose> |
| 196 |
</xsl:param> |
| 197 |
<xsl:param name="rep"> |
| 198 |
<xsl:choose> |
| 199 |
<xsl:when test="@rep"> |
| 200 |
<xsl:value-of select="@rep"/> |
| 201 |
</xsl:when> |
| 202 |
<xsl:otherwise> |
| 203 |
<xsl:value-of select="'norepeat'"/> |
| 204 |
</xsl:otherwise> |
| 205 |
</xsl:choose> |
| 206 |
</xsl:param> |
| 207 |
<xsl:variable name="padding"> |
| 208 |
<xsl:if test="sbr or db:sbr"> |
| 209 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 210 |
select="ancestor::cmdsynopsis[1] | |
| 211 |
ancestor::db:cmdsynopsis[1]"> |
| 212 |
<xsl:with-param name="sbr" select="sbr[1] | db:sbr[1]"/> |
| 213 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 214 |
</xsl:apply-templates> |
| 215 |
</xsl:if> |
| 216 |
</xsl:variable> |
| 217 |
|
| 218 |
<span class="group-punc"> |
| 219 |
<xsl:choose> |
| 220 |
<xsl:when test="$choice = 'plain'"> |
| 221 |
<xsl:text>(</xsl:text> |
| 222 |
</xsl:when> |
| 223 |
<xsl:when test="$choice = 'req'"> |
| 224 |
<xsl:text>{</xsl:text> |
| 225 |
</xsl:when> |
| 226 |
<xsl:otherwise> |
| 227 |
<xsl:text>[</xsl:text> |
| 228 |
</xsl:otherwise> |
| 229 |
</xsl:choose> |
| 230 |
<span> |
| 231 |
<xsl:call-template name="html.class.attr"> |
| 232 |
<xsl:with-param name="class" select="'group'"/> |
| 233 |
</xsl:call-template> |
| 234 |
<xsl:for-each select="*"> |
| 235 |
<xsl:choose> |
| 236 |
<xsl:when test="self::sbr or self::db:sbr"> |
| 237 |
<xsl:text>
</xsl:text> |
| 238 |
<xsl:value-of select="$padding"/> |
| 239 |
</xsl:when> |
| 240 |
<xsl:otherwise> |
| 241 |
<xsl:apply-templates select="."> |
| 242 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 243 |
</xsl:apply-templates> |
| 244 |
<xsl:if test="position() != last()"> |
| 245 |
<xsl:value-of select="concat($sepchar, '|', $sepchar)"/> |
| 246 |
</xsl:if> |
| 247 |
</xsl:otherwise> |
| 248 |
</xsl:choose> |
| 249 |
</xsl:for-each> |
| 250 |
</span> |
| 251 |
<xsl:choose> |
| 252 |
<xsl:when test="$choice = 'plain'"> |
| 253 |
<xsl:text>)</xsl:text> |
| 254 |
</xsl:when> |
| 255 |
<xsl:when test="$choice = 'req'"> |
| 256 |
<xsl:text>}</xsl:text> |
| 257 |
</xsl:when> |
| 258 |
<xsl:otherwise> |
| 259 |
<xsl:text>]</xsl:text> |
| 260 |
</xsl:otherwise> |
| 261 |
</xsl:choose> |
| 262 |
<xsl:if test="$rep = 'repeat'"> |
| 263 |
<xsl:text>...</xsl:text> |
| 264 |
</xsl:if> |
| 265 |
</span> |
| 266 |
</xsl:template> |
| 267 |
|
| 268 |
<!-- = synopfragment = --> |
| 269 |
<xsl:template match="synopfragment | db:synopfragment"> |
| 270 |
<xsl:param name="sepchar"> |
| 271 |
<xsl:choose> |
| 272 |
<xsl:when test="ancestor::cmdsynopsis[1][@sepchar]"> |
| 273 |
<xsl:value-of select="ancestor::cmdsynopsis[1]/@sepchar"/> |
| 274 |
</xsl:when> |
| 275 |
<xsl:when test="ancestor::db:cmdsynopsis[1][@sepchar]"> |
| 276 |
<xsl:value-of select="ancestor::db:cmdsynopsis[1]/@sepchar"/> |
| 277 |
</xsl:when> |
| 278 |
<xsl:otherwise> |
| 279 |
<xsl:text> </xsl:text> |
| 280 |
</xsl:otherwise> |
| 281 |
</xsl:choose> |
| 282 |
</xsl:param> |
| 283 |
<div> |
| 284 |
<xsl:call-template name="html.class.attr"> |
| 285 |
<xsl:with-param name="class" select="'synopfragment'"/> |
| 286 |
</xsl:call-template> |
| 287 |
<xsl:call-template name="db2html.anchor"/> |
| 288 |
<xsl:variable name="count" select="count(preceding-sibling::synopfragment) + |
| 289 |
count(preceding-sibling::db:synopfragment)"/> |
| 290 |
<xsl:variable name="countlast" select="count(preceding-sibling::synopfragment) + |
| 291 |
count(following-sibling::synopfragment) + |
| 292 |
count(preceding-sibling::db:synopfragment) + |
| 293 |
count(following-sibling::db:synopfragment)"/> |
| 294 |
<span class="co"> |
| 295 |
<xsl:text> </xsl:text> |
| 296 |
<xsl:value-of select="$count + 1"/> |
| 297 |
<xsl:text> </xsl:text> |
| 298 |
</span> |
| 299 |
<xsl:value-of select="str:padding(string-length($countlast + 1) - |
| 300 |
string-length($count + 1) + 1, ' ')"/> |
| 301 |
<xsl:for-each select="*"> |
| 302 |
<xsl:value-of select="$sepchar"/> |
| 303 |
<xsl:apply-templates select="."> |
| 304 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 305 |
</xsl:apply-templates> |
| 306 |
</xsl:for-each> |
| 307 |
</div> |
| 308 |
</xsl:template> |
| 309 |
|
| 310 |
<!-- = synopfragmentref = --> |
| 311 |
<xsl:template match="synopfragmentref | db:synopfragmentref"> |
| 312 |
<xsl:for-each select="key('db.id.key', @linkend)[1]"> |
| 313 |
<xsl:if test="self::synopfragment or self::db:synopfragment"> |
| 314 |
<xsl:variable name="count" select="count(preceding-sibling::synopfragment) + |
| 315 |
count(preceding-sibling::db:synopfragment)"/> |
| 316 |
<span class="co"> |
| 317 |
<xsl:text> </xsl:text> |
| 318 |
<xsl:value-of select="$count + 1"/> |
| 319 |
<xsl:text> </xsl:text> |
| 320 |
</span> |
| 321 |
</xsl:if> |
| 322 |
</xsl:for-each> |
| 323 |
</xsl:template> |
| 324 |
|
| 325 |
|
| 326 |
<!--%%========================================================================== |
| 327 |
db2html.cmdsynopsis.sbr.padding.mode |
| 328 |
Output padding for elements leading up to an `sbr` element. |
| 329 |
@revision[version=1.0 date=2011-05-16 status=final] |
| 330 |
|
| 331 |
[xsl:params] |
| 332 |
$sbr: The `sbr` element to pad up to |
| 333 |
$sepchar: The value of the `sepchar` attribute on the enclosing `cmdsynopsis` |
| 334 |
|
| 335 |
When processed in this mode, elements output whitespace to the length of the |
| 336 |
textual output they would normally produce. This allows options to be aligned |
| 337 |
when explicit line breaks are inserted with `sbr` elements. |
| 338 |
|
| 339 |
To create the padding for a given `sbr` element, this mode is called on the |
| 340 |
enclosing `cmdsynopsis` element, passing the `sbr` element. When processed |
| 341 |
in this mode, elements should only output padding for content the leads up to |
| 342 |
the `sbr` element passed in the $sbr parameter. When processing children |
| 343 |
that don't contain the given `sbr` element, the $sbr parameter should be |
| 344 |
set to `false()` for those children. This avoids additional descendant |
| 345 |
selectors, which are generally expensive to perform. |
| 346 |
--> |
| 347 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" match="node()"> |
| 348 |
<xsl:value-of select="str:padding(string-length(.), ' ')"/> |
| 349 |
</xsl:template> |
| 350 |
|
| 351 |
<!-- = cmdsynopsis % db2html.cmdsynopsis.sbr.padding.mode = --> |
| 352 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 353 |
match="cmdsynopsis | db:cmdsynopsis"> |
| 354 |
<xsl:param name="sbr"/> |
| 355 |
<xsl:param name="sepchar"/> |
| 356 |
<xsl:variable name="child" |
| 357 |
select="*[$sbr and set:has-same-node(.|.//sbr|.//db:sbr, $sbr)][1]"/> |
| 358 |
<xsl:choose> |
| 359 |
<xsl:when test="$child/self::synopfragment | |
| 360 |
$child/self::db:synopfragment"> |
| 361 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="$child"> |
| 362 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 363 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 364 |
</xsl:apply-templates> |
| 365 |
</xsl:when> |
| 366 |
<xsl:otherwise> |
| 367 |
<!-- Output padding for the preceding command --> |
| 368 |
<xsl:variable name="cmd" select="$child/preceding-sibling::command[1] | |
| 369 |
$child/preceding-sibling::db:command[1]"/> |
| 370 |
<xsl:value-of select="str:padding(string-length($cmd), ' ')"/> |
| 371 |
<xsl:value-of select="str:padding(string-length($sepchar), ' ')"/> |
| 372 |
<!-- Process all children that are between $cmd and $child, but |
| 373 |
after any sbr elements between $cmd and $child --> |
| 374 |
<xsl:for-each select="$cmd/following-sibling::* |
| 375 |
[set:has-same-node(following-sibling::*, $child)] |
| 376 |
[not(set:has-same-node(. | following-sibling::sbr, |
| 377 |
$child/preceding-sibling::sbr)) and |
| 378 |
not(set:has-same-node(. | following-sibling::db:sbr, |
| 379 |
$child/preceding-sibling::db:sbr))]"> |
| 380 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="."> |
| 381 |
<xsl:with-param name="sbr" select="false()"/> |
| 382 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 383 |
</xsl:apply-templates> |
| 384 |
<xsl:value-of select="str:padding(string-length($sepchar), ' ')"/> |
| 385 |
</xsl:for-each> |
| 386 |
<!-- And process $child itself --> |
| 387 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="$child"> |
| 388 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 389 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 390 |
</xsl:apply-templates> |
| 391 |
</xsl:otherwise> |
| 392 |
</xsl:choose> |
| 393 |
</xsl:template> |
| 394 |
|
| 395 |
<!-- = arg % db2html.cmdsynopsis.sbr.padding.mode = --> |
| 396 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" match="arg | db:arg"> |
| 397 |
<xsl:param name="sbr"/> |
| 398 |
<xsl:param name="sepchar"/> |
| 399 |
<xsl:if test="@choice != 'plain'"> |
| 400 |
<xsl:text> </xsl:text> |
| 401 |
</xsl:if> |
| 402 |
<xsl:choose> |
| 403 |
<xsl:when test="not($sbr)"> |
| 404 |
<!-- The sbr is outside this element. The total width an arg is whatever |
| 405 |
comes before an sbr plus whatever comes after an sbr plus possible |
| 406 |
punctuation spacing. --> |
| 407 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 408 |
select="node()[not(preceding-sibling::sbr) and |
| 409 |
not(preceding-sibling::db:sbr)]"> |
| 410 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 411 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 412 |
</xsl:apply-templates> |
| 413 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 414 |
select="(sbr | db:sbr)[last()]/following-sibling::node()"> |
| 415 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 416 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 417 |
</xsl:apply-templates> |
| 418 |
<xsl:if test="@choice != 'plain'"> |
| 419 |
<xsl:text> </xsl:text> |
| 420 |
</xsl:if> |
| 421 |
</xsl:when> |
| 422 |
<xsl:otherwise> |
| 423 |
<xsl:variable name="child" select="*[set:has-same-node(.|.//sbr|.//db:sbr, |
| 424 |
$sbr)][1]"/> |
| 425 |
<!-- Process all children that are before $child, but after |
| 426 |
any sbr elements before $child. Process any children |
| 427 |
before the initial sbr before $child, if it exists. --> |
| 428 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 429 |
select="$child/preceding-sibling::sbr[last()]/preceding-sibling::node() |
| 430 |
| $child/preceding-sibling::db:sbr[last()]/preceding-sibling::node() |
| 431 |
| ($child/preceding-sibling::node()) |
| 432 |
[not(set:has-same-node(. | following-sibling::sbr, |
| 433 |
$child/preceding-sibling::sbr)) and |
| 434 |
not(set:has-same-node(. | following-sibling::db:sbr, |
| 435 |
$child/preceding-sibling::db:sbr))]"> |
| 436 |
<xsl:with-param name="sbr" select="false()"/> |
| 437 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 438 |
</xsl:apply-templates> |
| 439 |
<!-- And process $child itself --> |
| 440 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="$child"> |
| 441 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 442 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 443 |
</xsl:apply-templates> |
| 444 |
</xsl:otherwise> |
| 445 |
</xsl:choose> |
| 446 |
</xsl:template> |
| 447 |
|
| 448 |
<!-- = group % db2html.cmdsynopsis.sbr.padding.mode = --> |
| 449 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" match="group | |
| 450 |
db:group"> |
| 451 |
<xsl:param name="sbr"/> |
| 452 |
<xsl:param name="sepchar"/> |
| 453 |
<xsl:text> </xsl:text> |
| 454 |
<xsl:choose> |
| 455 |
<xsl:when test="not($sbr)"> |
| 456 |
<!-- The sbr is outside this element. The total width a group is |
| 457 |
calculated by taking all children after the last sbr (or all |
| 458 |
children if there is no sbr), adding their widths, and adding |
| 459 |
width for joining punctuation for all but one of them. Add |
| 460 |
to this punctuation spacing for the group as a whole. --> |
| 461 |
<xsl:for-each select="*[not(following-sibling::sbr) and not(self::sbr) and |
| 462 |
not(following-sibling::db:sbr) and not(self::db:sbr)]"> |
| 463 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="."> |
| 464 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 465 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 466 |
</xsl:apply-templates> |
| 467 |
<xsl:if test="position() != 1"> |
| 468 |
<xsl:value-of select="str:padding(2 * string-length($sepchar) + 1, ' ')"/> |
| 469 |
</xsl:if> |
| 470 |
</xsl:for-each> |
| 471 |
<xsl:text> </xsl:text> |
| 472 |
</xsl:when> |
| 473 |
<xsl:when test="set:has-same-node(., $sbr/..)"/> |
| 474 |
<xsl:otherwise> |
| 475 |
<xsl:variable name="child" select="*[set:has-same-node(.|.//sbr|.//db:sbr, $sbr)][1]"/> |
| 476 |
<!-- Process all children that are before $child, but after |
| 477 |
any sbr elements before $child. Add joining punctuation |
| 478 |
padding for all but one of them. --> |
| 479 |
<xsl:for-each select="($child/preceding-sibling::*) |
| 480 |
[not(set:has-same-node(. | following-sibling::sbr, |
| 481 |
$child/preceding-sibling::sbr)) and |
| 482 |
not(set:has-same-node(. | following-sibling::db:sbr, |
| 483 |
$child/preceding-sibling::db:sbr))]"> |
| 484 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="."> |
| 485 |
<xsl:with-param name="sbr" select="false()"/> |
| 486 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 487 |
</xsl:apply-templates> |
| 488 |
<xsl:if test="position() != 1"> |
| 489 |
<xsl:value-of select="str:padding(2 * string-length($sepchar) + 1, ' ')"/> |
| 490 |
</xsl:if> |
| 491 |
</xsl:for-each> |
| 492 |
<!-- And process $child itself --> |
| 493 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="$child"> |
| 494 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 495 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 496 |
</xsl:apply-templates> |
| 497 |
</xsl:otherwise> |
| 498 |
</xsl:choose> |
| 499 |
</xsl:template> |
| 500 |
|
| 501 |
<!-- = synopfragment % db2html.cmdsynopsis.sbr.padding.mode = --> |
| 502 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 503 |
match="synopfragment | db:synopfragment"> |
| 504 |
<xsl:param name="sbr"/> |
| 505 |
<xsl:param name="sepchar"/> |
| 506 |
<xsl:variable name="countlast" select="count(preceding-sibling::synopfragment) + |
| 507 |
count(following-sibling::synopfragment) + |
| 508 |
count(preceding-sibling::db:synopfragment) + |
| 509 |
count(following-sibling::db:synopfragment)"/> |
| 510 |
<xsl:value-of select="str:padding(string-length($countlast + 1) + 3, ' ')"/> |
| 511 |
<xsl:value-of select="str:padding(string-length($sepchar), ' ')"/> |
| 512 |
<xsl:variable name="child" select="*[set:has-same-node(.|.//sbr|.//db:sbr, $sbr)][1]"/> |
| 513 |
<!-- Process all children that are before $child, but |
| 514 |
after any sbr elements before $child --> |
| 515 |
<xsl:for-each select="$child/preceding-sibling::* |
| 516 |
[not(set:has-same-node(. | following-sibling::sbr, |
| 517 |
$child/preceding-sibling::sbr)) and |
| 518 |
not(set:has-same-node(. | following-sibling::db:sbr, |
| 519 |
$child/preceding-sibling::db:sbr))]"> |
| 520 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="."> |
| 521 |
<xsl:with-param name="sbr" select="false()"/> |
| 522 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 523 |
</xsl:apply-templates> |
| 524 |
<xsl:value-of select="str:padding(string-length($sepchar), ' ')"/> |
| 525 |
</xsl:for-each> |
| 526 |
<!-- And process $child itself --> |
| 527 |
<xsl:apply-templates mode="db2html.cmdsynopsis.sbr.padding.mode" select="$child"> |
| 528 |
<xsl:with-param name="sbr" select="$sbr"/> |
| 529 |
<xsl:with-param name="sepchar" select="$sepchar"/> |
| 530 |
</xsl:apply-templates> |
| 531 |
</xsl:template> |
| 532 |
|
| 533 |
<!-- = synopfragmentref % db2html.cmdsynopsis.sbr.padding.mode = --> |
| 534 |
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" |
| 535 |
match="synopfragmentref | db:synopfragmentref"> |
| 536 |
<xsl:variable name="node" select="key('db.id.key', @linkend)"/> |
| 537 |
<xsl:variable name="count" select="count($node/preceding-sibling::synopfragment) + |
| 538 |
count($node/preceding-sibling::db:synopfragment) + 1"/> |
| 539 |
<xsl:value-of select="str:padding(string-length($count) + 2, ' ')"/> |
| 540 |
</xsl:template> |
| 541 |
|
| 542 |
</xsl:stylesheet> |