source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/synop.xsl @ f8c4e94

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since f8c4e94 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 30.3 KB
Line 
1<?xml version='1.0'?>
2<!DOCTYPE xsl:stylesheet [
3<!ENTITY RE "&#10;">
4<!ENTITY nbsp "&#160;">
5]>
6<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7                xmlns:fo="http://www.w3.org/1999/XSL/Format"
8                version='1.0'>
9
10<!-- ********************************************************************
11     $Id$
12     ********************************************************************
13
14     This file is part of the XSL DocBook Stylesheet distribution.
15     See ../README or http://docbook.sf.net/release/xsl/current/ for
16     copyright and other information.
17
18     ******************************************************************** -->
19
20<!-- ==================================================================== -->
21
22<!-- synopsis is in verbatim -->
23
24<!-- ==================================================================== -->
25
26<xsl:template match="cmdsynopsis">
27  <fo:block xsl:use-attribute-sets="normal.para.spacing">
28    <xsl:apply-templates/>
29  </fo:block>
30</xsl:template>
31
32<xsl:template match="cmdsynopsis/command">
33  <xsl:call-template name="inline.monoseq"/>
34  <xsl:text> </xsl:text>
35</xsl:template>
36
37<xsl:template match="cmdsynopsis/command[1]" priority="2">
38  <xsl:call-template name="inline.monoseq"/>
39  <xsl:text> </xsl:text>
40</xsl:template>
41
42<xsl:template match="group|arg" name="group-or-arg">
43  <xsl:variable name="choice" select="@choice"/>
44  <xsl:variable name="rep" select="@rep"/>
45  <xsl:variable name="sepchar">
46    <xsl:choose>
47      <xsl:when test="ancestor-or-self::*/@sepchar">
48        <xsl:value-of select="ancestor-or-self::*/@sepchar"/>
49      </xsl:when>
50      <xsl:otherwise>
51        <xsl:text> </xsl:text>
52      </xsl:otherwise>
53    </xsl:choose>
54  </xsl:variable>
55  <xsl:if test="preceding-sibling::*">
56    <xsl:value-of select="$sepchar"/>
57  </xsl:if>
58  <xsl:choose>
59    <xsl:when test="$choice='plain'">
60      <xsl:value-of select="$arg.choice.plain.open.str"/>
61    </xsl:when>
62    <xsl:when test="$choice='req'">
63      <xsl:value-of select="$arg.choice.req.open.str"/>
64    </xsl:when>
65    <xsl:when test="$choice='opt'">
66      <xsl:value-of select="$arg.choice.opt.open.str"/>
67    </xsl:when>
68    <xsl:otherwise>
69      <xsl:value-of select="$arg.choice.def.open.str"/>
70    </xsl:otherwise>
71  </xsl:choose>
72  <xsl:apply-templates/>
73  <xsl:choose>
74    <xsl:when test="$rep='repeat'">
75      <xsl:value-of select="$arg.rep.repeat.str"/>
76    </xsl:when>
77    <xsl:when test="$rep='norepeat'">
78      <xsl:value-of select="$arg.rep.norepeat.str"/>
79    </xsl:when>
80    <xsl:otherwise>
81      <xsl:value-of select="$arg.rep.def.str"/>
82    </xsl:otherwise>
83  </xsl:choose>
84  <xsl:choose>
85    <xsl:when test="$choice='plain'">
86      <xsl:value-of select="$arg.choice.plain.close.str"/>
87    </xsl:when>
88    <xsl:when test="$choice='req'">
89      <xsl:value-of select="$arg.choice.req.close.str"/>
90    </xsl:when>
91    <xsl:when test="$choice='opt'">
92      <xsl:value-of select="$arg.choice.opt.close.str"/>
93    </xsl:when>
94    <xsl:otherwise>
95      <xsl:value-of select="$arg.choice.def.close.str"/>
96    </xsl:otherwise>
97  </xsl:choose>
98</xsl:template>
99
100<xsl:template match="group/arg">
101  <xsl:variable name="choice" select="@choice"/>
102  <xsl:variable name="rep" select="@rep"/>
103  <xsl:if test="preceding-sibling::*">
104    <xsl:value-of select="$arg.or.sep"/>
105  </xsl:if>
106  <xsl:call-template name="group-or-arg"/>
107</xsl:template>
108
109<xsl:template match="sbr">
110  <fo:block/>
111</xsl:template>
112
113<!-- ==================================================================== -->
114
115<xsl:template match="synopfragmentref">
116  <xsl:variable name="target" select="key('id',@linkend)"/>
117  <xsl:variable name="snum">
118    <xsl:apply-templates select="$target" mode="synopfragment.number"/>
119  </xsl:variable>
120  <fo:inline font-style="italic">
121    <fo:basic-link internal-destination="{@linkend}"
122                   xsl:use-attribute-sets="xref.properties">
123      <xsl:text>(</xsl:text>
124      <xsl:value-of select="$snum"/>
125      <xsl:text>)</xsl:text>
126    </fo:basic-link>
127    <xsl:text>&#160;</xsl:text>
128    <xsl:apply-templates/>
129  </fo:inline>
130</xsl:template>
131
132<xsl:template match="synopfragment" mode="synopfragment.number">
133  <xsl:number format="1"/>
134</xsl:template>
135
136<xsl:template match="synopfragment">
137  <xsl:variable name="snum">
138    <xsl:apply-templates select="." mode="synopfragment.number"/>
139  </xsl:variable>
140  <xsl:variable name="id">
141    <xsl:call-template name="object.id"/>
142  </xsl:variable>
143  <fo:block id="{$id}">
144    <xsl:text>(</xsl:text>
145    <xsl:value-of select="$snum"/>
146    <xsl:text>)</xsl:text>
147    <xsl:text> </xsl:text>
148    <xsl:apply-templates/>
149  </fo:block>
150</xsl:template>
151
152<xsl:template match="funcsynopsis">
153  <xsl:call-template name="informal.object"/>
154</xsl:template>
155
156<xsl:template match="funcsynopsisinfo">
157  <fo:block space-after.minimum="0.8em"
158            space-after.optimum="1em"
159            space-after.maximum="1.2em">
160    <xsl:apply-templates/>
161  </fo:block>
162</xsl:template>
163
164<xsl:template match="funcprototype">
165  <fo:block font-family="{$monospace.font.family}"
166          space-before.minimum="0.8em"
167          space-before.optimum="1em"
168          space-before.maximum="1.2em">
169    <xsl:apply-templates/>
170    <xsl:if test="$funcsynopsis.style='kr'">
171      <fo:block
172          space-before.minimum="0.8em"
173          space-before.optimum="1em"
174          space-before.maximum="1.2em">
175      <xsl:apply-templates select="./paramdef" mode="kr-funcsynopsis-mode"/>
176      </fo:block>
177    </xsl:if>
178  </fo:block>
179</xsl:template>
180
181<xsl:template match="funcdef">
182  <fo:inline font-family="{$monospace.font.family}">
183    <xsl:apply-templates/>
184  </fo:inline>
185</xsl:template>
186
187<xsl:template match="funcdef/function">
188  <xsl:choose>
189    <xsl:when test="$funcsynopsis.decoration != 0">
190      <fo:inline font-weight="bold">
191        <xsl:apply-templates/>
192      </fo:inline>
193    </xsl:when>
194    <xsl:otherwise>
195      <xsl:apply-templates/>
196    </xsl:otherwise>
197  </xsl:choose>
198</xsl:template>
199
200<xsl:template match="void">
201  <xsl:choose>
202    <xsl:when test="$funcsynopsis.style='ansi'">
203      <xsl:text>(void);</xsl:text>
204    </xsl:when>
205    <xsl:otherwise>
206      <xsl:text>();</xsl:text>
207    </xsl:otherwise>
208  </xsl:choose>
209</xsl:template>
210
211<xsl:template match="varargs">
212  <xsl:text>(...);</xsl:text>
213</xsl:template>
214
215<xsl:template match="paramdef">
216  <xsl:variable name="paramnum">
217    <xsl:number count="paramdef" format="1"/>
218  </xsl:variable>
219  <xsl:if test="$paramnum=1">(</xsl:if>
220  <xsl:choose>
221    <xsl:when test="$funcsynopsis.style='ansi'">
222      <xsl:apply-templates/>
223    </xsl:when>
224    <xsl:otherwise>
225      <xsl:apply-templates select="./parameter"/>
226    </xsl:otherwise>
227  </xsl:choose>
228  <xsl:choose>
229    <xsl:when test="following-sibling::paramdef">
230      <xsl:text>, </xsl:text>
231    </xsl:when>
232    <xsl:otherwise>
233      <xsl:text>);</xsl:text>
234    </xsl:otherwise>
235  </xsl:choose>
236</xsl:template>
237
238<xsl:template match="paramdef/parameter">
239  <xsl:choose>
240    <xsl:when test="$funcsynopsis.decoration != 0">
241      <xsl:call-template name="inline.italicseq"/>
242    </xsl:when>
243    <xsl:otherwise>
244      <xsl:apply-templates/>
245    </xsl:otherwise>
246  </xsl:choose>
247  <xsl:if test="following-sibling::parameter">
248    <xsl:text>, </xsl:text>
249  </xsl:if>
250</xsl:template>
251
252<xsl:template match="paramdef" mode="kr-funcsynopsis-mode">
253  <fo:block>
254    <xsl:apply-templates/>
255    <xsl:text>;</xsl:text>
256  </fo:block>
257</xsl:template>
258
259<xsl:template match="funcparams">
260  <xsl:text>(</xsl:text>
261  <xsl:apply-templates/>
262  <xsl:text>)</xsl:text>
263</xsl:template>
264
265<!-- ==================================================================== -->
266
267<xsl:variable name="default-classsynopsis-language">java</xsl:variable>
268
269<xsl:template match="classsynopsis
270                     |fieldsynopsis
271                     |methodsynopsis
272                     |constructorsynopsis
273                     |destructorsynopsis">
274  <xsl:param name="language">
275    <xsl:choose>
276      <xsl:when test="@language">
277        <xsl:value-of select="@language"/>
278      </xsl:when>
279      <xsl:otherwise>
280        <xsl:value-of select="$default-classsynopsis-language"/>
281      </xsl:otherwise>
282    </xsl:choose>
283  </xsl:param>
284
285  <!--
286  <xsl:message>process <xsl:value-of select="local-name(.)"/> in <xsl:value-of select="$language"/></xsl:message>
287  -->
288
289  <xsl:choose>
290    <xsl:when test="$language='java' or $language='Java'">
291      <xsl:apply-templates select="." mode="java"/>
292    </xsl:when>
293    <xsl:when test="$language='perl' or $language='Perl'">
294      <xsl:apply-templates select="." mode="perl"/>
295    </xsl:when>
296    <xsl:when test="$language='idl' or $language='IDL'">
297      <xsl:apply-templates select="." mode="idl"/>
298    </xsl:when>
299    <xsl:when test="$language='cpp' or $language='c++' or $language='C++'">
300      <xsl:apply-templates select="." mode="cpp"/>
301    </xsl:when>
302    <xsl:otherwise>
303      <xsl:message>
304        <xsl:text>Unrecognized language on </xsl:text>
305        <xsl:value-of select="local-name(.)"/>
306        <xsl:text>: </xsl:text>
307        <xsl:value-of select="$language"/>
308      </xsl:message>
309      <xsl:apply-templates select=".">
310        <xsl:with-param name="language"
311          select="$default-classsynopsis-language"/>
312      </xsl:apply-templates>
313    </xsl:otherwise>
314  </xsl:choose>
315</xsl:template>
316
317<xsl:template name="synop-break">
318  <xsl:if test="parent::classsynopsis
319                or (following-sibling::fieldsynopsis
320                    |following-sibling::methodsynopsis
321                    |following-sibling::constructorsynopsis
322                    |following-sibling::destructorsynopsis)">
323    <fo:inline>&RE;</fo:inline>
324  </xsl:if>
325</xsl:template>
326
327<!-- ===== Java ======================================================== -->
328
329<xsl:template match="classsynopsis" mode="java">
330  <fo:block wrap-option='no-wrap'
331            white-space-collapse='false'
332            linefeed-treatment="preserve"
333            xsl:use-attribute-sets="monospace.verbatim.properties">
334    <xsl:apply-templates select="ooclass[1]" mode="java"/>
335    <xsl:if test="ooclass[preceding-sibling::*]">
336      <xsl:text> extends</xsl:text>
337      <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="java"/>
338      <xsl:if test="oointerface|ooexception">
339        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
340      </xsl:if>
341    </xsl:if>
342    <xsl:if test="oointerface">
343      <xsl:text>implements</xsl:text>
344      <xsl:apply-templates select="oointerface" mode="java"/>
345      <xsl:if test="ooexception">
346        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
347      </xsl:if>
348    </xsl:if>
349    <xsl:if test="ooexception">
350      <xsl:text>throws</xsl:text>
351      <xsl:apply-templates select="ooexception" mode="java"/>
352    </xsl:if>
353    <xsl:text>&nbsp;{&RE;</xsl:text>
354    <xsl:apply-templates select="constructorsynopsis
355                                 |destructorsynopsis
356                                 |fieldsynopsis
357                                 |methodsynopsis
358                                 |classsynopsisinfo" mode="java"/>
359    <xsl:text>}</xsl:text>
360  </fo:block>
361</xsl:template>
362
363<xsl:template match="classsynopsisinfo" mode="java">
364  <xsl:apply-templates mode="java"/>
365</xsl:template>
366
367<xsl:template match="ooclass|oointerface|ooexception" mode="java">
368  <xsl:choose>
369    <xsl:when test="preceding-sibling::*">
370      <xsl:text>, </xsl:text>
371    </xsl:when>
372    <xsl:otherwise>
373      <xsl:text> </xsl:text>
374    </xsl:otherwise>
375  </xsl:choose>
376  <xsl:apply-templates mode="java"/>
377</xsl:template>
378
379<xsl:template match="modifier|package" mode="java">
380  <xsl:apply-templates mode="java"/>
381  <xsl:if test="following-sibling::*">
382    <xsl:text>&nbsp;</xsl:text>
383  </xsl:if>
384</xsl:template>
385
386<xsl:template match="classname" mode="java">
387  <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
388    <xsl:text>, </xsl:text>
389  </xsl:if>
390  <xsl:apply-templates mode="java"/>
391</xsl:template>
392
393<xsl:template match="interfacename" mode="java">
394  <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
395    <xsl:text>, </xsl:text>
396  </xsl:if>
397  <xsl:apply-templates mode="java"/>
398</xsl:template>
399
400<xsl:template match="exceptionname" mode="java">
401  <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
402    <xsl:text>, </xsl:text>
403  </xsl:if>
404  <xsl:apply-templates mode="java"/>
405</xsl:template>
406
407<xsl:template match="fieldsynopsis" mode="java">
408  <fo:block wrap-option='no-wrap'
409            white-space-collapse='false'
410            linefeed-treatment="preserve"
411            xsl:use-attribute-sets="monospace.verbatim.properties">
412    <xsl:text>&nbsp;&nbsp;</xsl:text>
413    <xsl:apply-templates mode="java"/>
414    <xsl:text>;</xsl:text>
415    <xsl:call-template name="synop-break"/>
416  </fo:block>
417</xsl:template>
418
419<xsl:template match="type" mode="java">
420  <xsl:apply-templates mode="java"/>
421  <xsl:text>&nbsp;</xsl:text>
422</xsl:template>
423
424<xsl:template match="varname" mode="java">
425  <xsl:apply-templates mode="java"/>
426  <xsl:text>&nbsp;</xsl:text>
427</xsl:template>
428
429<xsl:template match="initializer" mode="java">
430  <xsl:text>=&nbsp;</xsl:text>
431  <xsl:apply-templates mode="java"/>
432</xsl:template>
433
434<xsl:template match="void" mode="java">
435  <xsl:text>void&nbsp;</xsl:text>
436</xsl:template>
437
438<xsl:template match="methodname" mode="java">
439  <xsl:apply-templates mode="java"/>
440</xsl:template>
441
442<xsl:template match="methodparam" mode="java">
443  <xsl:param name="indent">0</xsl:param>
444  <xsl:if test="preceding-sibling::methodparam">
445    <xsl:text>,&RE;</xsl:text>
446    <xsl:if test="$indent &gt; 0">
447      <xsl:call-template name="copy-string">
448        <xsl:with-param name="string">&nbsp;</xsl:with-param>
449        <xsl:with-param name="count" select="$indent + 1"/>
450      </xsl:call-template>
451    </xsl:if>
452  </xsl:if>
453  <xsl:apply-templates mode="java"/>
454</xsl:template>
455
456<xsl:template match="parameter" mode="java">
457  <xsl:apply-templates mode="java"/>
458</xsl:template>
459
460<xsl:template mode="java"
461  match="constructorsynopsis|destructorsynopsis|methodsynopsis">
462  <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
463  <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
464  <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
465  <xsl:variable name="decl">
466    <xsl:text>  </xsl:text>
467    <xsl:apply-templates select="$start-modifiers" mode="java"/>
468
469    <!-- type -->
470    <xsl:if test="local-name($notmod[1]) != 'methodname'">
471      <xsl:apply-templates select="$notmod[1]" mode="java"/>
472    </xsl:if>
473
474    <xsl:apply-templates select="methodname" mode="java"/>
475  </xsl:variable>
476
477  <fo:block wrap-option='no-wrap'
478            white-space-collapse='false'
479            linefeed-treatment="preserve"
480            xsl:use-attribute-sets="monospace.verbatim.properties">
481    <xsl:copy-of select="$decl"/>
482    <xsl:text>(</xsl:text>
483    <xsl:apply-templates select="methodparam" mode="java">
484      <xsl:with-param name="indent" select="string-length($decl)"/>
485    </xsl:apply-templates>
486    <xsl:text>)</xsl:text>
487    <xsl:if test="exceptionname">
488      <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
489      <xsl:apply-templates select="exceptionname" mode="java"/>
490    </xsl:if>
491    <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
492      <xsl:text> </xsl:text>
493      <xsl:apply-templates select="$end-modifiers" mode="java"/>
494    </xsl:if>
495    <xsl:text>;</xsl:text>
496  </fo:block>
497  <xsl:call-template name="synop-break"/>
498</xsl:template>
499
500<!-- ===== C++ ========================================================= -->
501
502<xsl:template match="classsynopsis" mode="cpp">
503  <fo:block wrap-option='no-wrap'
504            white-space-collapse='false'
505            linefeed-treatment="preserve"
506            xsl:use-attribute-sets="monospace.verbatim.properties">
507    <xsl:apply-templates select="ooclass[1]" mode="cpp"/>
508    <xsl:if test="ooclass[preceding-sibling::*]">
509      <xsl:text>: </xsl:text>
510      <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="cpp"/>
511      <xsl:if test="oointerface|ooexception">
512        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
513      </xsl:if>
514    </xsl:if>
515    <xsl:if test="oointerface">
516      <xsl:text> implements</xsl:text>
517      <xsl:apply-templates select="oointerface" mode="cpp"/>
518      <xsl:if test="ooexception">
519        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
520      </xsl:if>
521    </xsl:if>
522    <xsl:if test="ooexception">
523      <xsl:text> throws</xsl:text>
524      <xsl:apply-templates select="ooexception" mode="cpp"/>
525    </xsl:if>
526    <xsl:text>&nbsp;{&RE;</xsl:text>
527    <xsl:apply-templates select="constructorsynopsis
528                                 |destructorsynopsis
529                                 |fieldsynopsis
530                                 |methodsynopsis
531                                 |classsynopsisinfo" mode="cpp"/>
532    <xsl:text>}</xsl:text>
533  </fo:block>
534</xsl:template>
535
536<xsl:template match="classsynopsisinfo" mode="cpp">
537  <xsl:apply-templates mode="cpp"/>
538</xsl:template>
539
540<xsl:template match="ooclass|oointerface|ooexception" mode="cpp">
541  <xsl:if test="preceding-sibling::*">
542    <xsl:text>, </xsl:text>
543  </xsl:if>
544  <xsl:apply-templates mode="cpp"/>
545</xsl:template>
546
547<xsl:template match="modifier|package" mode="cpp">
548  <xsl:apply-templates mode="cpp"/>
549    <xsl:if test="following-sibling::*">
550      <xsl:text>&nbsp;</xsl:text>
551    </xsl:if>
552</xsl:template>
553
554<xsl:template match="classname" mode="cpp">
555  <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
556    <xsl:text>, </xsl:text>
557  </xsl:if>
558  <xsl:apply-templates mode="cpp"/>
559</xsl:template>
560
561<xsl:template match="interfacename" mode="cpp">
562  <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
563    <xsl:text>, </xsl:text>
564  </xsl:if>
565  <xsl:apply-templates mode="cpp"/>
566</xsl:template>
567
568<xsl:template match="exceptionname" mode="cpp">
569  <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
570    <xsl:text>, </xsl:text>
571  </xsl:if>
572  <xsl:apply-templates mode="cpp"/>
573</xsl:template>
574
575<xsl:template match="fieldsynopsis" mode="cpp">
576  <fo:block wrap-option='no-wrap'
577            white-space-collapse='false'
578            linefeed-treatment="preserve"
579            xsl:use-attribute-sets="monospace.verbatim.properties">
580    <xsl:text>&nbsp;&nbsp;</xsl:text>
581    <xsl:apply-templates mode="cpp"/>
582    <xsl:text>;</xsl:text>
583  </fo:block>
584  <xsl:call-template name="synop-break"/>
585</xsl:template>
586
587<xsl:template match="type" mode="cpp">
588  <xsl:apply-templates mode="cpp"/>
589  <xsl:text>&nbsp;</xsl:text>
590</xsl:template>
591
592<xsl:template match="varname" mode="cpp">
593  <xsl:apply-templates mode="cpp"/>
594  <xsl:text>&nbsp;</xsl:text>
595</xsl:template>
596
597<xsl:template match="initializer" mode="cpp">
598  <xsl:text>=&nbsp;</xsl:text>
599  <xsl:apply-templates mode="cpp"/>
600</xsl:template>
601
602<xsl:template match="void" mode="cpp">
603  <xsl:text>void&nbsp;</xsl:text>
604</xsl:template>
605
606<xsl:template match="methodname" mode="cpp">
607  <xsl:apply-templates mode="cpp"/>
608</xsl:template>
609
610<xsl:template match="methodparam" mode="cpp">
611  <xsl:if test="preceding-sibling::methodparam">
612    <xsl:text>, </xsl:text>
613  </xsl:if>
614  <xsl:apply-templates mode="cpp"/>
615</xsl:template>
616
617<xsl:template match="parameter" mode="cpp">
618  <xsl:apply-templates mode="cpp"/>
619</xsl:template>
620
621<xsl:template mode="cpp"
622  match="constructorsynopsis|destructorsynopsis|methodsynopsis">
623  <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
624  <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
625  <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
626
627  <fo:block wrap-option='no-wrap'
628            white-space-collapse='false'
629            linefeed-treatment="preserve"
630            xsl:use-attribute-sets="monospace.verbatim.properties">
631    <xsl:text>  </xsl:text>
632    <xsl:apply-templates select="$start-modifiers" mode="cpp"/>
633
634    <!-- type -->
635    <xsl:if test="local-name($notmod[1]) != 'methodname'">
636      <xsl:apply-templates select="$notmod[1]" mode="cpp"/>
637    </xsl:if>
638
639    <xsl:apply-templates select="methodname" mode="cpp"/>
640    <xsl:text>(</xsl:text>
641    <xsl:apply-templates select="methodparam" mode="cpp"/>
642    <xsl:text>)</xsl:text>
643    <xsl:if test="exceptionname">
644      <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
645      <xsl:apply-templates select="exceptionname" mode="cpp"/>
646    </xsl:if>
647    <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
648      <xsl:text> </xsl:text>
649      <xsl:apply-templates select="$end-modifiers" mode="cpp"/>
650    </xsl:if>
651    <xsl:text>;</xsl:text>
652  </fo:block>
653  <xsl:call-template name="synop-break"/>
654</xsl:template>
655
656<!-- ===== IDL ========================================================= -->
657
658<xsl:template match="classsynopsis" mode="idl">
659  <fo:block wrap-option='no-wrap'
660            white-space-collapse='false'
661            linefeed-treatment="preserve"
662            xsl:use-attribute-sets="monospace.verbatim.properties">
663    <xsl:text>interface </xsl:text>
664    <xsl:apply-templates select="ooclass[1]" mode="idl"/>
665    <xsl:if test="ooclass[preceding-sibling::*]">
666      <xsl:text>: </xsl:text>
667      <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="idl"/>
668      <xsl:if test="oointerface|ooexception">
669        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
670      </xsl:if>
671    </xsl:if>
672    <xsl:if test="oointerface">
673      <xsl:text> implements</xsl:text>
674      <xsl:apply-templates select="oointerface" mode="idl"/>
675      <xsl:if test="ooexception">
676        <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
677      </xsl:if>
678    </xsl:if>
679    <xsl:if test="ooexception">
680      <xsl:text> throws</xsl:text>
681      <xsl:apply-templates select="ooexception" mode="idl"/>
682    </xsl:if>
683    <xsl:text>&nbsp;{&RE;</xsl:text>
684    <xsl:apply-templates select="constructorsynopsis
685                                 |destructorsynopsis
686                                 |fieldsynopsis
687                                 |methodsynopsis
688                                 |classsynopsisinfo" mode="idl"/>
689    <xsl:text>}</xsl:text>
690  </fo:block>
691</xsl:template>
692
693<xsl:template match="classsynopsisinfo" mode="idl">
694  <xsl:apply-templates mode="idl"/>
695</xsl:template>
696
697<xsl:template match="ooclass|oointerface|ooexception" mode="idl">
698  <xsl:if test="preceding-sibling::*">
699    <xsl:text>, </xsl:text>
700  </xsl:if>
701  <xsl:apply-templates mode="idl"/>
702</xsl:template>
703
704<xsl:template match="modifier|package" mode="idl">
705  <xsl:apply-templates mode="idl"/>
706    <xsl:if test="following-sibling::*">
707      <xsl:text>&nbsp;</xsl:text>
708    </xsl:if>
709</xsl:template>
710
711<xsl:template match="classname" mode="idl">
712  <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
713    <xsl:text>, </xsl:text>
714  </xsl:if>
715  <xsl:apply-templates mode="idl"/>
716</xsl:template>
717
718<xsl:template match="interfacename" mode="idl">
719  <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
720    <xsl:text>, </xsl:text>
721  </xsl:if>
722  <xsl:apply-templates mode="idl"/>
723</xsl:template>
724
725<xsl:template match="exceptionname" mode="idl">
726  <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
727    <xsl:text>, </xsl:text>
728  </xsl:if>
729  <xsl:apply-templates mode="idl"/>
730</xsl:template>
731
732<xsl:template match="fieldsynopsis" mode="idl">
733  <fo:block wrap-option='no-wrap'
734            white-space-collapse='false'
735            linefeed-treatment="preserve"
736            xsl:use-attribute-sets="monospace.verbatim.properties">
737    <xsl:text>&nbsp;&nbsp;</xsl:text>
738    <xsl:apply-templates mode="idl"/>
739    <xsl:text>;</xsl:text>
740  </fo:block>
741  <xsl:call-template name="synop-break"/>
742</xsl:template>
743
744<xsl:template match="type" mode="idl">
745  <xsl:apply-templates mode="idl"/>
746  <xsl:text>&nbsp;</xsl:text>
747</xsl:template>
748
749<xsl:template match="varname" mode="idl">
750  <xsl:apply-templates mode="idl"/>
751  <xsl:text>&nbsp;</xsl:text>
752</xsl:template>
753
754<xsl:template match="initializer" mode="idl">
755  <xsl:text>=&nbsp;</xsl:text>
756  <xsl:apply-templates mode="idl"/>
757</xsl:template>
758
759<xsl:template match="void" mode="idl">
760  <xsl:text>void&nbsp;</xsl:text>
761</xsl:template>
762
763<xsl:template match="methodname" mode="idl">
764  <xsl:apply-templates mode="idl"/>
765</xsl:template>
766
767<xsl:template match="methodparam" mode="idl">
768  <xsl:if test="preceding-sibling::methodparam">
769    <xsl:text>, </xsl:text>
770  </xsl:if>
771  <xsl:apply-templates mode="idl"/>
772</xsl:template>
773
774<xsl:template match="parameter" mode="idl">
775  <xsl:apply-templates mode="idl"/>
776</xsl:template>
777
778<xsl:template mode="idl"
779  match="constructorsynopsis|destructorsynopsis|methodsynopsis">
780  <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
781  <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
782  <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
783
784  <fo:block wrap-option='no-wrap'
785            white-space-collapse='false'
786            linefeed-treatment="preserve"
787            xsl:use-attribute-sets="monospace.verbatim.properties">
788    <xsl:text>  </xsl:text>
789    <xsl:apply-templates select="$start-modifiers" mode="idl"/>
790
791    <!-- type -->
792    <xsl:if test="local-name($notmod[1]) != 'methodname'">
793      <xsl:apply-templates select="$notmod[1]" mode="idl"/>
794    </xsl:if>
795
796    <xsl:apply-templates select="methodname" mode="idl"/>
797    <xsl:text>(</xsl:text>
798    <xsl:apply-templates select="methodparam" mode="idl"/>
799    <xsl:text>)</xsl:text>
800    <xsl:if test="exceptionname">
801      <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;raises(</xsl:text>
802      <xsl:apply-templates select="exceptionname" mode="idl"/>
803      <xsl:text>)</xsl:text>
804    </xsl:if>
805    <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
806      <xsl:text> </xsl:text>
807      <xsl:apply-templates select="$end-modifiers" mode="idl"/>
808    </xsl:if>
809    <xsl:text>;</xsl:text>
810  </fo:block>
811  <xsl:call-template name="synop-break"/>
812</xsl:template>
813
814<!-- ===== Perl ======================================================== -->
815
816<xsl:template match="classsynopsis" mode="perl">
817  <fo:block wrap-option='no-wrap'
818            white-space-collapse='false'
819            linefeed-treatment="preserve"
820            xsl:use-attribute-sets="monospace.verbatim.properties">
821    <xsl:text>package </xsl:text>
822    <xsl:apply-templates select="ooclass[1]" mode="perl"/>
823    <xsl:text>;&RE;</xsl:text>
824
825    <xsl:if test="ooclass[preceding-sibling::*]">
826      <xsl:text>@ISA = (</xsl:text>
827      <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="perl"/>
828      <xsl:text>);&RE;</xsl:text>
829    </xsl:if>
830
831    <xsl:apply-templates select="constructorsynopsis
832                                 |destructorsynopsis
833                                 |fieldsynopsis
834                                 |methodsynopsis
835                                 |classsynopsisinfo" mode="perl"/>
836  </fo:block>
837</xsl:template>
838
839<xsl:template match="classsynopsisinfo" mode="perl">
840  <xsl:apply-templates mode="perl"/>
841</xsl:template>
842
843<xsl:template match="ooclass|oointerface|ooexception" mode="perl">
844  <xsl:if test="preceding-sibling::*">
845    <xsl:text>, </xsl:text>
846  </xsl:if>
847  <xsl:apply-templates mode="perl"/>
848</xsl:template>
849
850<xsl:template match="modifier|package" mode="perl">
851  <xsl:apply-templates mode="perl"/>
852    <xsl:if test="following-sibling::*">
853      <xsl:text>&nbsp;</xsl:text>
854    </xsl:if>
855</xsl:template>
856
857<xsl:template match="classname" mode="perl">
858  <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
859    <xsl:text>, </xsl:text>
860  </xsl:if>
861  <xsl:apply-templates mode="perl"/>
862</xsl:template>
863
864<xsl:template match="interfacename" mode="perl">
865  <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
866    <xsl:text>, </xsl:text>
867  </xsl:if>
868  <xsl:apply-templates mode="perl"/>
869</xsl:template>
870
871<xsl:template match="exceptionname" mode="perl">
872  <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
873    <xsl:text>, </xsl:text>
874  </xsl:if>
875  <xsl:apply-templates mode="perl"/>
876</xsl:template>
877
878<xsl:template match="fieldsynopsis" mode="perl">
879  <fo:block wrap-option='no-wrap'
880            white-space-collapse='false'
881            linefeed-treatment="preserve"
882            xsl:use-attribute-sets="monospace.verbatim.properties">
883    <xsl:text>&nbsp;&nbsp;</xsl:text>
884    <xsl:apply-templates mode="perl"/>
885    <xsl:text>;</xsl:text>
886  </fo:block>
887  <xsl:call-template name="synop-break"/>
888</xsl:template>
889
890<xsl:template match="type" mode="perl">
891  <xsl:apply-templates mode="perl"/>
892  <xsl:text>&nbsp;</xsl:text>
893</xsl:template>
894
895<xsl:template match="varname" mode="perl">
896  <xsl:apply-templates mode="perl"/>
897  <xsl:text>&nbsp;</xsl:text>
898</xsl:template>
899
900<xsl:template match="initializer" mode="perl">
901  <xsl:text>=&nbsp;</xsl:text>
902  <xsl:apply-templates mode="perl"/>
903</xsl:template>
904
905<xsl:template match="void" mode="perl">
906  <xsl:text>void&nbsp;</xsl:text>
907</xsl:template>
908
909<xsl:template match="methodname" mode="perl">
910  <xsl:apply-templates mode="perl"/>
911</xsl:template>
912
913<xsl:template match="methodparam" mode="perl">
914  <xsl:if test="preceding-sibling::methodparam">
915    <xsl:text>, </xsl:text>
916  </xsl:if>
917  <xsl:apply-templates mode="perl"/>
918</xsl:template>
919
920<xsl:template match="parameter" mode="perl">
921  <xsl:apply-templates mode="perl"/>
922</xsl:template>
923
924<xsl:template mode="perl"
925  match="constructorsynopsis|destructorsynopsis|methodsynopsis">
926  <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
927  <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
928  <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
929
930  <fo:block wrap-option='no-wrap'
931            white-space-collapse='false'
932            linefeed-treatment="preserve"
933            xsl:use-attribute-sets="monospace.verbatim.properties">
934    <xsl:text>sub </xsl:text>
935
936    <xsl:apply-templates select="methodname" mode="perl"/>
937    <xsl:text> { ... };</xsl:text>
938    <xsl:call-template name="synop-break"/>
939  </fo:block>
940</xsl:template>
941
942<!-- ==================================================================== -->
943
944<!-- * DocBook 5 allows linking elements (link, olink, and xref) -->
945<!-- * within the OO *synopsis elements (classsynopsis, fieldsynopsis, -->
946<!-- * methodsynopsis, constructorsynopsis, destructorsynopsis) and -->
947<!-- * their children. So we need to have mode="java|cpp|idl|perl" -->
948<!-- * per-mode matches for those linking elements in order for them -->
949<!-- * to be processed as expected. -->
950
951<xsl:template match="link|olink|xref" mode="java">
952  <xsl:apply-templates select="."/>
953</xsl:template>
954
955<xsl:template match="link|olink|xref" mode="cpp">
956  <xsl:apply-templates select="."/>
957</xsl:template>
958
959<xsl:template match="link|olink|xref" mode="idl">
960  <xsl:apply-templates select="."/>
961</xsl:template>
962
963<xsl:template match="link|olink|xref" mode="perl">
964  <xsl:apply-templates select="."/>
965</xsl:template>
966
967</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.