1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:fo="http://www.w3.org/1999/XSL/Format"
4                version='1.0'>
5
6<!-- ********************************************************************
7     $Id$
8     ********************************************************************
9
10     This file is part of the XSL DocBook Stylesheet distribution.
11     See /README or http://nwalsh.com/docbook/xsl/ for copyright
12     and other information.
13
14     ******************************************************************** -->
15
16<!-- ==================================================================== -->
17
18<xsl:template match="synopsis">
19  <fo:block>
20    <xsl:apply-templates/>
21  </fo:block>
22</xsl:template>
23
24<!-- ==================================================================== -->
25
26<xsl:template match="cmdsynopsis">
27  <fo:block>
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">
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="position()>1"><xsl:value-of select="$sepchar"/></xsl:if>
56  <xsl:choose>
57    <xsl:when test="$choice='plain'">
58      <xsl:value-of select="$arg.choice.plain.open.str"/>
59    </xsl:when>
60    <xsl:when test="$choice='req'">
61      <xsl:value-of select="$arg.choice.req.open.str"/>
62    </xsl:when>
63    <xsl:when test="$choice='opt'">
64      <xsl:value-of select="$arg.choice.opt.open.str"/>
65    </xsl:when>
66    <xsl:otherwise>
67      <xsl:value-of select="$arg.choice.def.open.str"/>
68    </xsl:otherwise>
69  </xsl:choose>
70  <xsl:apply-templates/>
71  <xsl:choose>
72    <xsl:when test="$rep='repeat'">
73      <xsl:value-of select="$arg.rep.repeat.str"/>
74    </xsl:when>
75    <xsl:when test="$rep='norepeat'">
76      <xsl:value-of select="$arg.rep.norepeat.str"/>
77    </xsl:when>
78    <xsl:otherwise>
79      <xsl:value-of select="$arg.rep.def.str"/>
80    </xsl:otherwise>
81  </xsl:choose>
82  <xsl:choose>
83    <xsl:when test="$choice='plain'">
84      <xsl:value-of select="$arg.choice.plain.close.str"/>
85    </xsl:when>
86    <xsl:when test="$choice='req'">
87      <xsl:value-of select="$arg.choice.req.close.str"/>
88    </xsl:when>
89    <xsl:when test="$choice='opt'">
90      <xsl:value-of select="$arg.choice.opt.close.str"/>
91    </xsl:when>
92    <xsl:otherwise>
93      <xsl:value-of select="$arg.choice.def.close.str"/>
94    </xsl:otherwise>
95  </xsl:choose>
96</xsl:template>
97
98<xsl:template match="group/arg">
99  <xsl:variable name="choice" select="@choice"/>
100  <xsl:variable name="rep" select="@rep"/>
101  <xsl:if test="position()>1"><xsl:value-of select="$arg.or.sep"/></xsl:if>
102  <xsl:apply-templates/>
103</xsl:template>
104
105<xsl:template match="sbr">
106</xsl:template>
107
108<!-- ==================================================================== -->
109
110<xsl:template match="synopfragmentref">
111  <xsl:variable name="target" select="id(@linkend)"/>
112  <xsl:variable name="snum">
113    <xsl:apply-templates select="$target" mode="synopfragment.number"/>
114  </xsl:variable>
115  <fo:inline font-style="italic">
116    <xsl:text>(</xsl:text>
117    <xsl:value-of select="$snum"/>
118    <xsl:text>)</xsl:text>
119  </fo:inline>
120</xsl:template>
121
122<xsl:template match="synopfragment" mode="synopfragment.number">
123  <xsl:number format="1"/>
124</xsl:template>
125
126<xsl:template match="synopfragment">
127  <xsl:variable name="snum">
128    <xsl:apply-templates select="." mode="synopfragment.number"/>
129  </xsl:variable>
130  <fo:block>
131    <xsl:text>(</xsl:text>
132    <xsl:value-of select="$snum"/>
133    <xsl:text>)</xsl:text>
134    <xsl:text> </xsl:text>
135    <xsl:apply-templates/>
136  </fo:block>
137</xsl:template>   
138
139<xsl:template match="funcsynopsis">
140  <xsl:call-template name="informal.object"/>
141</xsl:template>
142
143<xsl:template match="funcsynopsisinfo">
144  <fo:block><xsl:apply-templates/></fo:block>
145</xsl:template>
146
147<xsl:template match="funcprototype">
148  <fo:block font-family="{$monospace.font.family}">
149    <xsl:apply-templates/>
150    <xsl:if test="$funcsynopsis.style='kr'">
151      <xsl:apply-templates select="/paramdef" mode="kr-funcsynopsis-mode"/>
152    </xsl:if>
153  </fo:block>
154</xsl:template>
155
156<xsl:template match="funcdef">
157  <fo:inline font-family="{$monospace.font.family}">
158    <xsl:apply-templates/>
159  </fo:inline>
160</xsl:template>
161
162<xsl:template match="funcdef/function">
163  <xsl:choose>
164    <xsl:when test="$funcsynopsis.decoration != 0">
165      <fo:inline font-weight="bold">
166        <xsl:apply-templates/>
167      </fo:inline>
168    </xsl:when>
169    <xsl:otherwise>
170      <xsl:apply-templates/>
171    </xsl:otherwise>
172  </xsl:choose>
173</xsl:template>
174
175<xsl:template match="void">
176  <xsl:choose>
177    <xsl:when test="$funcsynopsis.style='ansi'">
178      <xsl:text>(void);</xsl:text>
179    </xsl:when>
180    <xsl:otherwise>
181      <xsl:text>();</xsl:text>
182    </xsl:otherwise>
183  </xsl:choose>
184</xsl:template>
185
186<xsl:template match="varargs">
187  <xsl:text>(...);</xsl:text>
188</xsl:template>
189
190<xsl:template match="paramdef">
191  <xsl:variable name="paramnum">
192    <xsl:number count="paramdef" format="1"/>
193  </xsl:variable>
194  <xsl:if test="$paramnum=1">(</xsl:if>
195  <xsl:choose>
196    <xsl:when test="$funcsynopsis.style='ansi'">
197      <xsl:apply-templates/>
198    </xsl:when>
199    <xsl:otherwise>
200      <xsl:apply-templates select="/parameter"/>
201    </xsl:otherwise>
202  </xsl:choose>
203  <xsl:choose>
204    <xsl:when test="following-sibling::paramdef">
205      <xsl:text>, </xsl:text>
206    </xsl:when>
207    <xsl:otherwise>
208      <xsl:text>);</xsl:text>
209    </xsl:otherwise>
210  </xsl:choose>
211</xsl:template>
212
213<xsl:template match="paramdef/parameter">
214  <xsl:choose>
215    <xsl:when test="$funcsynopsis.decoration != 0">
216      <xsl:apply-templates/>
217    </xsl:when>
218    <xsl:otherwise>
219      <xsl:apply-templates/>
220    </xsl:otherwise>
221  </xsl:choose>
222  <xsl:if test="following-sibling::parameter">
223    <xsl:text>, </xsl:text>
224  </xsl:if>
225</xsl:template>  
226
227<xsl:template match="paramdef" mode="kr-funcsynopsis-mode">
228  <xsl:apply-templates/>
229  <xsl:text>;</xsl:text>
230</xsl:template>
231
232<xsl:template match="funcparams">
233  <xsl:text>(</xsl:text>
234  <xsl:apply-templates/>
235  <xsl:text>)</xsl:text>
236</xsl:template>
237
238<!-- ==================================================================== -->
239
240</xsl:stylesheet>
241