20
20
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
21
xmlns:db="http://docbook.org/ns/docbook"
21
22
xmlns:set="http://exslt.org/sets"
22
23
xmlns:str="http://exslt.org/strings"
23
xmlns:db="http://docbook.org/ns/docbook"
24
24
xmlns="http://www.w3.org/1999/xhtml"
25
25
exclude-result-prefixes="db set str"
28
28
<!--!!==========================================================================
29
29
DocBook to HTML - Command Synopses
30
:Requires: db2html-xref gettext
30
:Requires: db2html-xref html
31
:Revision:version="1.0" date="2011-05-16" status="final"
32
33
This module contains templates to process DocBook command synopsis elements.
36
<!--@@==========================================================================
38
The default value of the #{choice} parameter for #{arg} elements
40
REMARK: Describe this param
42
<xsl:param name="db2html.arg.choice" select="'opt'"/>
45
<!--@@==========================================================================
47
The default value of the #{rep} parameter for #{arg} elements
49
REMARK: Describe this param
51
<xsl:param name="db2html.arg.rep" select="'norepeat'"/>
54
<!--@@==========================================================================
56
The default value of the #{choice} parameter for #{group} elements
58
REMARK: Describe this param
60
<xsl:param name="db2html.group.choice" select="'opt'"/>
63
<!--@@==========================================================================
65
The default value of the #{rep} parameter for #{group} elements
67
REMARK: Describe this param
69
<xsl:param name="db2html.group.rep" select="'norepeat'"/>
37
<xsl:key name="db2html.cmdsynopsis.synopfragment.key"
38
match="synopfragment | db:synopfragment"
72
42
<!-- == Matched Templates == -->
169
<xsl:when test="@lang or @xml:lang">
170
<xsl:attribute name="dir">
171
<xsl:call-template name="l10n.direction">
172
<xsl:with-param name="lang" select="@lang | @xml:lang"/>
177
<xsl:attribute name="dir">
178
<xsl:text>ltr</xsl:text>
182
138
<xsl:attribute name="class">
183
139
<xsl:text>synopsis cmdsynopsis</xsl:text>
141
<xsl:call-template name="html.lang.attrs"/>
185
142
<xsl:call-template name="db2html.anchor"/>
186
143
<pre class="contents cmdsynopsis">
187
144
<xsl:for-each select="command | arg | group | sbr |
325
282
<div class="synopfragment">
326
283
<xsl:call-template name="db2html.anchor"/>
328
<i><xsl:call-template name="db.label"/></i>
284
<xsl:variable name="count" select="count(preceding-sibling::synopfragment) +
285
count(preceding-sibling::db:synopfragment)"/>
286
<xsl:variable name="countlast" select="count(preceding-sibling::synopfragment) +
287
count(following-sibling::synopfragment) +
288
count(preceding-sibling::db:synopfragment) +
289
count(following-sibling::db:synopfragment)"/>
291
<xsl:text> </xsl:text>
292
<xsl:value-of select="$count + 1"/>
293
<xsl:text> </xsl:text>
295
<xsl:value-of select="str:padding(string-length($countlast + 1) -
296
string-length($count + 1) + 1, ' ')"/>
329
297
<xsl:for-each select="*">
330
298
<xsl:value-of select="$sepchar"/>
331
299
<xsl:apply-templates select=".">
338
306
<!-- = synopfragmentref = -->
339
307
<xsl:template match="synopfragmentref | db:synopfragmentref">
340
<xsl:call-template name="db2html.xref"/>
308
<xsl:for-each select="key('db2html.cmdsynopsis.synopfragment.key', @linkend)[1]">
309
<xsl:variable name="count" select="count(preceding-sibling::synopfragment) +
310
count(preceding-sibling::db:synopfragment)"/>
312
<xsl:text> </xsl:text>
313
<xsl:value-of select="$count + 1"/>
314
<xsl:text> </xsl:text>
344
320
<!--%%==========================================================================
345
321
db2html.cmdsynopsis.sbr.padding.mode
346
Outputs padding for elements leading up to an #{sbr} element
322
Output padding for elements leading up to an #{sbr} element.
323
:Revision:version="1.0" date="2011-05-16" status="final"
347
324
$sbr: The #{sbr} element to pad up to
348
325
$sepchar: The value of the #{sepchar} attribute on the enclosing #{cmdsynopsis}
356
333
in this mode, elements should only output padding for content the leads up to
357
334
the #{sbr} element passed in the ${sbr} parameter. When processing children
358
335
that don't contain the given #{sbr} element, the ${sbr} parameter should be
359
set to #{false()} for those children. This avoids additional ancestor
336
set to #{false()} for those children. This avoids additional descendant
360
337
selectors, which are generally expensive to perform.
362
339
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode" match="node()">
368
345
match="cmdsynopsis | db:cmdsynopsis">
369
346
<xsl:param name="sbr"/>
370
347
<xsl:param name="sepchar"/>
371
<xsl:variable name="child" select="*[set:has-same-node(.|.//sbr, $sbr) or
372
set:has-same-node(.|.//db:sbr, $sbr)][1]"/>
348
<xsl:variable name="child"
349
select="*[$sbr and set:has-same-node(.|.//sbr|.//db:sbr, $sbr)][1]"/>
374
351
<xsl:when test="$child/self::synopfragment |
375
352
$child/self::db:synopfragment">
518
495
match="synopfragment | db:synopfragment">
519
496
<xsl:param name="sbr"/>
520
497
<xsl:param name="sepchar"/>
521
<xsl:variable name="label">
523
<xsl:call-template name="db.label"/>
525
<xsl:value-of select="str:padding(string-length($label), ' ')"/>
498
<xsl:variable name="countlast" select="count(preceding-sibling::synopfragment) +
499
count(following-sibling::synopfragment) +
500
count(preceding-sibling::db:synopfragment) +
501
count(following-sibling::db:synopfragment)"/>
502
<xsl:value-of select="str:padding(string-length($countlast + 1) + 3, ' ')"/>
526
503
<xsl:value-of select="str:padding(string-length($sepchar), ' ')"/>
527
504
<xsl:variable name="child" select="*[set:has-same-node(.|.//sbr|.//db:sbr, $sbr)][1]"/>
528
505
<!-- Process all children that are before $child, but
548
525
<!-- = synopfragmentref % db2html.cmdsynopsis.sbr.padding.mode = -->
549
526
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode"
550
527
match="synopfragmentref | db:synopfragmentref">
551
<xsl:variable name="label">
552
<xsl:call-template name="db2html.xref"/>
554
<xsl:value-of select="str:padding(string-length($label), ' ')"/>
528
<xsl:variable name="node" select="key('db2html.cmdsynopsis.synopfragment.key', @linkend)"/>
529
<xsl:variable name="count" select="count($node/preceding-sibling::synopfragment) +
530
count($node/preceding-sibling::db:synopfragment) + 1"/>
531
<xsl:value-of select="str:padding(string-length($count) + 2, ' ')"/>
557
534
</xsl:stylesheet>