1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
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
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
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, write to the
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
xmlns:db="http://docbook.org/ns/docbook"
21
xmlns="http://www.w3.org/1999/xhtml"
24
<!--!!==========================================================================
25
DocBook to HTML - Class Synopses
26
:Requires: db2html-inline db2html-xref gettext
28
REMARK: Describe this module. Implmentation note: for C++, we expect the first
29
modifier to be the visibility
32
<xsl:variable name="cpp.tab" select="'    '"/>
33
<xsl:variable name="python.tab" select="'    '"/>
36
<!-- FIXME: document PI -->
37
<!--@@==========================================================================
38
db2html.classsynopsis.language
39
The default programming language used to format #{classsynopsis} elements
41
REMARK: Describe this param
43
<xsl:param name="db2html.classsynopsis.language">
45
<xsl:when test="/processing-instruction('db2html.classsynopsis.language')">
47
select="/processing-instruction('db2html.classsynopsis.language')"/>
50
<xsl:value-of select="'cpp'"/>
56
<!-- == Matched Templates == -->
58
<!-- = *synopsis = -->
60
classsynopsis | constructorsynopsis | fieldsynopsis |
61
methodsynopsis | destructorsynopsis |
62
db:classsynopsis | db:constructorsynopsis | db:fieldsynopsis |
63
db:methodsynopsis | db:destructorsynopsis |">
64
<xsl:variable name="language">
66
<xsl:when test="@language">
67
<xsl:value-of select="@language"/>
70
<xsl:value-of select="$db2html.classsynopsis.language"/>
76
<xsl:when test="@lang | @xml:lang">
77
<xsl:attribute name="dir">
78
<xsl:call-template name="l10n.direction">
79
<xsl:with-param name="lang" select="@lang | @xml:lang"/>
84
<xsl:attribute name="dir">
85
<xsl:text>ltr</xsl:text>
89
<xsl:attribute name="class">
90
<xsl:text>synopsis </xsl:text>
91
<xsl:value-of select="local-name(.)"/>
93
<xsl:call-template name="db2html.anchor"/>
94
<pre class="contents {local-name(.)} classsynopsis-{$language}">
96
<xsl:when test="$language = 'cpp'">
97
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
99
<xsl:when test="$language = 'python'">
100
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
104
<xsl:text>No information about the language '</xsl:text>
105
<xsl:value-of select="$language"/>
106
<xsl:text>' for classsynopsis.</xsl:text>
114
<!-- = classsynopsisinfo = -->
115
<xsl:template match="classsynopsisinfo | db:classsynopsisinfo">
116
<xsl:apply-templates/>
118
<xsl:text>
</xsl:text>
121
<!-- = methodparam = -->
122
<xsl:template match="methodparam | db:methodparam">
123
<span class="methodparam">
124
<xsl:for-each select="*">
125
<xsl:if test="position() != 1">
126
<xsl:text> </xsl:text>
128
<xsl:apply-templates select="."/>
133
<!--#* db2html.class.cpp.modifier -->
134
<xsl:template name="db2html.class.cpp.modifier">
135
<!-- For C++, we expect the first modifier to be the visibility -->
136
<xsl:variable name="prec" select="self::*[../self::classsynopsis]/preceding-sibling::constructorsynopsis |
137
self::*[../self::classsynopsis]/preceding-sibling::destructorsynopsis |
138
self::*[../self::classsynopsis]/preceding-sibling::fieldsynopsis |
139
self::*[../self::classsynopsis]/preceding-sibling::methodsynopsis |
140
self::*[../self::db:classsynopsis]/preceding-sibling::db:constructorsynopsis |
141
self::*[../self::db:classsynopsis]/preceding-sibling::db:destructorsynopsis |
142
self::*[../self::db:classsynopsis]/preceding-sibling::db:fieldsynopsis |
143
self::*[../self::db:classsynopsis]/preceding-sibling::db:methodsynopsis "/>
145
<xsl:when test="not($prec[modifier][last()][modifier[1] = current()/modifier[1]]) and
146
not($prec[db:modifier][last()][db:modifier[1] = current()/db:modifier[1]])">
147
<xsl:if test="$prec"><xsl:text>
</xsl:text></xsl:if>
148
<xsl:apply-templates select="(modifier | db:modifier)[1]"/>
149
<xsl:text>:
</xsl:text>
151
<xsl:when test="$prec and (name($prec[last()]) != name(.))">
152
<xsl:text>
</xsl:text>
158
<!--%%==========================================================================
159
db2html.class.cpp.mode
161
REMARK: Describe this mode
163
<xsl:template mode="db2html.class.cpp.mode" match="*">
164
<xsl:apply-templates select="."/>
167
<!-- = classsynopsis % db2html.class.cpp.mode = -->
168
<xsl:template mode="db2html.class.cpp.mode"
169
match="classsynopsis | db:classsynopsis">
170
<!-- classsynopsis = element classsynopsis {
171
attribute language { ... }?,
172
attribute class { ... }?,
174
(classsynopsisinfo | constructorsynopsis |
175
destructorsynopsis | fieldsynopsis |
179
<xsl:if test="@class = 'class' or not(@class)">
180
<span class="ooclass">
181
<xsl:for-each select="ooclass[1]/modifier | db:ooclass[1]/db:modifier">
182
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
183
<xsl:text> </xsl:text>
185
<xsl:text>class </xsl:text>
186
<xsl:apply-templates mode="db2html.class.cpp.mode"
187
select="ooclass[1]/classname |
188
db:ooclass[1]/db:classname"/>
190
<xsl:if test="ooclass[2] or db:ooclass[2]">
191
<xsl:text> : </xsl:text>
192
<xsl:for-each select="ooclass[position() != 1] |
193
db:ooclass[position() != 1]">
194
<xsl:if test="position() != 1">
195
<xsl:text>, </xsl:text>
197
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
200
<xsl:text>
{
</xsl:text>
201
<xsl:apply-templates mode="db2html.class.cpp.mode"
204
constructorsynopsis | destructorsynopsis |
205
fieldsynopsis | methodsynopsis |
206
db:classsynopsisinfo |
207
db:constructorsynopsis | db:destructorsynopsis |
208
db:fieldsynopsis | db:methodsynopsis "/>
209
<xsl:text>}
</xsl:text>
213
<!-- = constructorsynopsis % db2html.class.cpp.mode = -->
214
<xsl:template mode="db2html.class.cpp.mode"
215
match="constructorsynopsis | db:constructorsynopsis">
216
<!-- constructorsynopsis = element constructorsynopsis {
217
attribute language { ... }?,
220
(methodparam+ | void?)
223
<xsl:call-template name="db2html.class.cpp.modifier"/>
224
<xsl:value-of select="$cpp.tab"/>
225
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
226
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
227
<xsl:text> </xsl:text>
230
<xsl:when test="methodname or db:methodname">
231
<xsl:apply-templates mode="db2html.class.cpp.mode"
232
select="methodname | db:methodname"/>
234
<xsl:when test="../self::classsynopsis[ooclass]">
235
<span class="methodname">
236
<xsl:value-of select="../ooclass/classname"/>
239
<xsl:when test="../self::db:classsynopsis[db:ooclass]">
240
<span class="methodname">
241
<xsl:value-of select="../db:ooclass/db:classname"/>
245
<xsl:text>(</xsl:text>
246
<xsl:for-each select="methodparam | db:methodparam">
247
<xsl:if test="position() != 1">
248
<xsl:text>, </xsl:text>
250
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
252
<xsl:text>);
</xsl:text>
255
<!-- = destructorsynopsis % db2html.class.cpp.mode = -->
256
<xsl:template mode="db2html.class.cpp.mode"
257
match="destructorsynopsis | db:destructorsynopsis">
258
<!-- destructorsynopsis = element destructorsynopsis {
259
attribute language { ... }?,
262
(methodparam+ | void?)
265
<xsl:call-template name="db2html.class.cpp.modifier"/>
266
<xsl:value-of select="$cpp.tab"/>
267
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
268
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
269
<xsl:text> </xsl:text>
272
<xsl:when test="methodname">
273
<xsl:apply-templates mode="db2html.class.cpp.mode"
274
select="methodname | db:methodname"/>
276
<xsl:when test="../self::classsynopsis[ooclass]">
277
<span class="methodname">
278
<xsl:text>~</xsl:text>
279
<xsl:value-of select="../ooclass/classname"/>
282
<xsl:when test="../self::db:classsynopsis[db:ooclass]">
283
<span class="methodname">
284
<xsl:value-of select="../db:ooclass/db:classname"/>
288
<xsl:text>(</xsl:text>
289
<xsl:for-each select="methodparam | db:methodparam">
290
<!-- FIXME: should we do each methodparam on its own line? -->
291
<xsl:if test="position() != 1">
292
<xsl:text>, </xsl:text>
294
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
296
<xsl:text>);
</xsl:text>
299
<!-- = fieldsynopsis % db2html.class.cpp.mode = -->
300
<xsl:template mode="db2html.class.cpp.mode"
301
match="fieldsynopsis | db:fieldsynopsis">
302
<!-- fieldsynopsis = element fieldsynopsis {
303
attribute language { ... }?,
310
<xsl:call-template name="db2html.class.cpp.modifier"/>
311
<xsl:value-of select="$cpp.tab"/>
312
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
313
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
314
<xsl:text> </xsl:text>
316
<xsl:if test="type or db:type">
317
<xsl:apply-templates mode="db2html.class.cpp.mode" select="type | db:type"/>
318
<xsl:text> </xsl:text>
320
<xsl:apply-templates mode="db2html.class.cpp.mode"
321
select="varname | db:varname"/>
322
<xsl:if test="initializer or db:initializer">
323
<xsl:text> = </xsl:text>
324
<xsl:apply-templates mode="db2html.class.cpp.mode"
325
select="initializer | db:initializer"/>
327
<xsl:text>;
</xsl:text>
330
<!-- = methodparam % db2html.class.cpp.mode = -->
331
<xsl:template mode="db2html.class.cpp.mode"
332
match="methodparam | db:methodparam">
333
<span class="methodparam">
334
<xsl:for-each select="*">
335
<xsl:if test="position() != 1">
336
<xsl:text> </xsl:text>
338
<xsl:if test="self::initializer or self::db:initializer">
339
<xsl:text>= </xsl:text>
341
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
346
<!-- = methodsynopsis % db2html.class.cpp.mode = -->
347
<xsl:template mode="db2html.class.cpp.mode"
348
match="methodsynopsis | db:methodsynopsis">
349
<!-- methodsynopsis = element methodsynopsis {
350
attribute language { ... }?,
354
(methodparam+ | void?)
357
<xsl:call-template name="db2html.class.cpp.modifier"/>
358
<xsl:value-of select="$cpp.tab"/>
359
<!-- Parens for document order -->
360
<xsl:for-each select="(methodname/preceding-sibling::modifier |
361
db:methodname/preceding-sibling::db:modifier)[position() != 1]">
362
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
363
<xsl:text> </xsl:text>
365
<xsl:apply-templates mode="db2html.class.cpp.mode"
366
select="type | methodname/preceding-sibling::void |
367
db:type | db:methodname/preceding-sibling::db:void"/>
368
<xsl:text> </xsl:text>
369
<xsl:apply-templates mode="db2html.class.cpp.mode"
370
select="methodname | db:methodname"/>
371
<xsl:text>(</xsl:text>
372
<xsl:for-each select="methodparam | db:methodparam">
373
<xsl:if test="position() != 1">
374
<xsl:text>, </xsl:text>
376
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
378
<xsl:text>)</xsl:text>
379
<xsl:for-each select="methodname/following-sibling::modifier |
380
db:methodname/following-sibling::db:modifier">
381
<xsl:text> </xsl:text>
382
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
384
<xsl:text>;
</xsl:text>
388
<!--%%==========================================================================
389
db2html.class.python.mode
391
REMARK: Describe this mode
393
<xsl:template mode="db2html.class.python.mode" match="*">
394
<xsl:apply-templates select="."/>
397
<!-- = classsynopsis % db2html.class.python.mode = -->
398
<xsl:template mode="db2html.class.python.mode"
399
match="classsynopsis | db:classsynopsis">
400
<!-- classsynopsis = element classsynopsis {
401
attribute language { ... }?,
402
attribute class { ... }?,
404
(classsynopsisinfo | constructorsynopsis |
405
destructorsynopsis | fieldsynopsis |
409
<xsl:if test="@class = 'class' or not(@class)">
410
<xsl:text>class </xsl:text>
411
<xsl:apply-templates mode="db2html.class.python.mode"
412
select="ooclass[1] | db:ooclass[1]"/>
413
<xsl:if test="ooclass[2] or db:ooclass[2]">
414
<xsl:text>(</xsl:text>
415
<xsl:for-each select="(ooclass | db:ooclass)[position() != 1]">
416
<xsl:if test="position() != 1">
417
<xsl:text>, </xsl:text>
419
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
421
<xsl:text>)</xsl:text>
423
<xsl:text>:
</xsl:text>
424
<xsl:for-each select="classsynopsisinfo | constructorsynopsis |
425
destructorsynopsis | fieldsynopsis |
427
db:classsynopsisinfo | db:constructorsynopsis |
428
db:destructorsynopsis | db:fieldsynopsis |
430
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
431
<xsl:if test="position() != last() and local-name(following-sibling::*[1]) != local-name(.)">
432
<xsl:text>
</xsl:text>
438
<!-- = constructorsynopsis % db2html.class.python.mode = -->
439
<xsl:template mode="db2html.class.python.mode"
440
match="constructorsynopsis | db:constructorsynopsis">
441
<!-- constructorsynopsis = element constructorsynopsis {
442
attribute language { ... }?,
445
(methodparam+ | void?)
448
<xsl:variable name="tab">
449
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
450
<xsl:value-of select="$python.tab"/>
453
<xsl:for-each select="modifier | db:modifier">
454
<xsl:value-of select="$tab"/>
455
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
456
<xsl:text>
</xsl:text>
458
<xsl:value-of select="$tab"/>
460
<xsl:when test="methodname">
461
<xsl:apply-templates mode="db2html.class.python.mode" select="methodname"/>
463
<xsl:when test="db:methodname">
464
<xsl:apply-templates mode="db2html.class.python.mode" select="db:methodname"/>
466
<xsl:when test="../self::classsynopsis[ooclass]">
467
<span class="methodname">
468
<xsl:value-of select="../ooclass/classname"/>
471
<xsl:when test="../self::db:classsynopsis[db:ooclass]">
472
<span class="methodname">
473
<xsl:value-of select="../db:ooclass/db:classname"/>
477
<xsl:text>(</xsl:text>
478
<xsl:for-each select="methodparam | db:methodparam">
479
<xsl:if test="position() != 1">
480
<xsl:text>, </xsl:text>
482
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
484
<xsl:text>)</xsl:text>
485
<xsl:if test="type or db:type">
486
<xsl:text> -> </xsl:text>
487
<xsl:apply-templates mode="db2html.class.python.mode" select="type | db:type"/>
489
<xsl:text>
</xsl:text>
492
<!-- = destructorsynopsis % db2html.class.python.mode = -->
493
<xsl:template mode="db2html.class.python.mode"
494
match="destructorsynopsis | db:destructorsynopsis">
495
<!-- destructorsynopsis = element destructorsynopsis {
496
attribute language { ... }?,
499
(methodparam+ | void?)
502
<xsl:variable name="tab">
503
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
504
<xsl:value-of select="$python.tab"/>
507
<xsl:for-each select="modifier | db:modifier">
508
<xsl:value-of select="$tab"/>
509
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
510
<xsl:text>
</xsl:text>
512
<xsl:value-of select="$tab"/>
514
<xsl:when test="methodname">
515
<xsl:apply-templates mode="db2html.class.python.mode" select="methodname"/>
517
<xsl:when test="db:methodname">
518
<xsl:apply-templates mode="db2html.class.python.mode" select="db:methodname"/>
521
<span class="methodname">
522
<xsl:text>__del__</xsl:text>
526
<xsl:text>(</xsl:text>
527
<xsl:for-each select="methodparam | db:methodparam">
528
<xsl:if test="position() != 1">
529
<xsl:text>, </xsl:text>
531
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
533
<xsl:text>)</xsl:text>
534
<xsl:if test="type or db:type">
535
<xsl:text> -> </xsl:text>
536
<xsl:apply-templates mode="db2html.class.python.mode" select="type | db:type"/>
538
<xsl:text>
</xsl:text>
541
<!-- = fieldsynopsis % db2html.class.python.mode = -->
542
<xsl:template mode="db2html.class.python.mode"
543
match="fieldsynopsis | db:fieldsynopsis">
544
<!-- fieldsynopsis = element fieldsynopsis {
545
attribute language { ... }?,
552
<xsl:variable name="tab">
553
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
554
<xsl:value-of select="$python.tab"/>
557
<xsl:for-each select="modifier | db:modifier">
558
<xsl:value-of select="$tab"/>
559
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
560
<xsl:text>
</xsl:text>
562
<xsl:value-of select="$tab"/>
563
<xsl:apply-templates mode="db2html.class.python.mode"
564
select="varname | db:varname"/>
565
<xsl:if test="initializer or db:initializer">
566
<xsl:text>=</xsl:text>
567
<xsl:apply-templates mode="db2html.class.python.mode"
568
select="initializer | db:initializer"/>
570
<xsl:text>
</xsl:text>
573
<!-- = methodparam % db2html.class.python.mode = -->
574
<xsl:template mode="db2html.class.python.mode"
575
match="methodparam | db:methodparam">
576
<span class="methodparam">
577
<xsl:apply-templates mode="db2html.class.python.mode"
578
select="parameter | db:parameter"/>
579
<xsl:if test="modifier or type or db:modifier or db:type">
580
<xsl:text>: </xsl:text>
581
<xsl:apply-templates mode="db2html.class.python.mode"
582
select="(modifier | type | db:modifier | db:type)[1]"/>
583
<xsl:if test="initializer or db:initializer">
584
<xsl:text> </xsl:text>
587
<xsl:if test="initializer or db:initializer">
588
<xsl:text>=</xsl:text>
589
<xsl:if test="modifier or type or db:modifier or db:type">
590
<xsl:text> </xsl:text>
592
<xsl:apply-templates mode="db2html.class.python.mode"
593
select="initializer | db:initializer"/>
598
<!-- = methodsynopsis % db2html.class.python.mode = -->
599
<xsl:template mode="db2html.class.python.mode"
600
match="methodsynopsis | db:methodsynopsis">
601
<!-- methodsynopsis = element methodsynopsis {
602
attribute language { ... }?,
606
(methodparam+ | void?)
609
<xsl:variable name="tab">
610
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
611
<xsl:value-of select="$python.tab"/>
614
<xsl:for-each select="modifier | db:modifier">
615
<xsl:value-of select="$tab"/>
616
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
617
<xsl:text>
</xsl:text>
619
<xsl:value-of select="$tab"/>
620
<xsl:text>def </xsl:text>
621
<xsl:apply-templates mode="db2html.class.python.mode"
622
select="methodname | db:methodname"/>
623
<xsl:text>(</xsl:text>
624
<xsl:for-each select="methodparam | db:methodparam">
625
<xsl:if test="position() != 1">
626
<xsl:text>, </xsl:text>
628
<xsl:apply-templates mode="db2html.class.python.mode" select="."/>
630
<xsl:text>)</xsl:text>
631
<xsl:if test="type or db:type">
632
<xsl:text> -> </xsl:text>
633
<xsl:apply-templates mode="db2html.class.python.mode" select="type | db:type"/>
635
<xsl:text>
</xsl:text>