~ubuntu-branches/debian/experimental/yelp-xsl/experimental

« back to all changes in this revision

Viewing changes to xslt/docbook/html/db2html-cmdsynopsis.xsl

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-03-17 15:12:22 UTC
  • mfrom: (1.1.16) (11.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20120317151222-pnzcgh4actzfkwdb
Tags: 3.3.3-1
New upstream development release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
 
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"
26
26
                version="1.0">
27
27
 
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"
31
32
 
32
33
This module contains templates to process DocBook command synopsis elements.
33
34
-->
34
35
 
35
36
 
36
 
<!--@@==========================================================================
37
 
db2html.arg.choice
38
 
The default value of the #{choice} parameter for #{arg} elements
39
 
 
40
 
REMARK: Describe this param
41
 
-->
42
 
<xsl:param name="db2html.arg.choice" select="'opt'"/>
43
 
 
44
 
 
45
 
<!--@@==========================================================================
46
 
db2html.arg.rep
47
 
The default value of the #{rep} parameter for #{arg} elements
48
 
 
49
 
REMARK: Describe this param
50
 
-->
51
 
<xsl:param name="db2html.arg.rep" select="'norepeat'"/>
52
 
 
53
 
 
54
 
<!--@@==========================================================================
55
 
db2html.group.choice
56
 
The default value of the #{choice} parameter for #{group} elements
57
 
 
58
 
REMARK: Describe this param
59
 
-->
60
 
<xsl:param name="db2html.group.choice" select="'opt'"/>
61
 
 
62
 
 
63
 
<!--@@==========================================================================
64
 
db2html.group.rep
65
 
The default value of the #{rep} parameter for #{group} elements
66
 
 
67
 
REMARK: Describe this param
68
 
-->
69
 
<xsl:param name="db2html.group.rep" select="'norepeat'"/>
 
37
<xsl:key name="db2html.cmdsynopsis.synopfragment.key"
 
38
         match="synopfragment | db:synopfragment"
 
39
         use="@id | @xml:id"/>
70
40
 
71
41
 
72
42
<!-- == Matched Templates == -->
92
62
        <xsl:value-of select="@choice"/>
93
63
      </xsl:when>
94
64
      <xsl:otherwise>
95
 
        <xsl:value-of select="$db2html.arg.choice"/>
 
65
        <xsl:value-of select="'opt'"/>
96
66
      </xsl:otherwise>
97
67
    </xsl:choose>
98
68
  </xsl:param>
102
72
        <xsl:value-of select="@rep"/>
103
73
      </xsl:when>
104
74
      <xsl:otherwise>
105
 
        <xsl:value-of select="$db2html.arg.rep"/>
 
75
        <xsl:value-of select="'norepeat'"/>
106
76
      </xsl:otherwise>
107
77
    </xsl:choose>
108
78
  </xsl:param>
165
135
    </xsl:choose>
166
136
  </xsl:param>
167
137
  <div>
168
 
    <xsl:choose>
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"/>
173
 
          </xsl:call-template>
174
 
        </xsl:attribute>
175
 
      </xsl:when>
176
 
      <xsl:otherwise>
177
 
        <xsl:attribute name="dir">
178
 
          <xsl:text>ltr</xsl:text>
179
 
        </xsl:attribute>
180
 
      </xsl:otherwise>
181
 
    </xsl:choose>
182
138
    <xsl:attribute name="class">
183
139
      <xsl:text>synopsis cmdsynopsis</xsl:text>
184
140
    </xsl:attribute>
 
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 |
235
192
        <xsl:value-of select="@choice"/>
236
193
      </xsl:when>
237
194
      <xsl:otherwise>
238
 
        <xsl:value-of select="$db2html.group.choice"/>
 
195
        <xsl:value-of select="'opt'"/>
239
196
      </xsl:otherwise>
240
197
    </xsl:choose>
241
198
  </xsl:param>
245
202
        <xsl:value-of select="@rep"/>
246
203
      </xsl:when>
247
204
      <xsl:otherwise>
248
 
        <xsl:value-of select="$db2html.group.rep"/>
 
205
        <xsl:value-of select="'norepeat'"/>
249
206
      </xsl:otherwise>
250
207
    </xsl:choose>
251
208
  </xsl:param>
324
281
  </xsl:param>
325
282
  <div class="synopfragment">
326
283
    <xsl:call-template name="db2html.anchor"/>
327
 
    <!-- FIXME -->
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)"/>
 
290
    <span class="co">
 
291
      <xsl:text> </xsl:text>
 
292
      <xsl:value-of select="$count + 1"/>
 
293
      <xsl:text> </xsl:text>
 
294
    </span>
 
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=".">
337
305
 
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)"/>
 
311
    <span class="co">
 
312
      <xsl:text> </xsl:text>
 
313
      <xsl:value-of select="$count + 1"/>
 
314
      <xsl:text> </xsl:text>
 
315
    </span>
 
316
  </xsl:for-each>
341
317
</xsl:template>
342
318
 
343
319
 
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}
349
326
 
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.
361
338
-->
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]"/>
373
350
  <xsl:choose>
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">
522
 
    <!-- FIXME -->
523
 
    <xsl:call-template name="db.label"/>
524
 
  </xsl:variable>
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"/>
553
 
  </xsl:variable>
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, ' ')"/>
555
532
</xsl:template>
556
533
 
557
534
</xsl:stylesheet>