Debian Codegraph @

xslt/docbook/html/db2html-funcsynopsis.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
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
6 later version.
7
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
11 details.
12
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, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:str="http://exslt.org/strings"
20 xmlns="http://www.w3.org/1999/xhtml"
21 exclude-result-prefixes="db str"
22 version="1.0">
23
24 <!--!!==========================================================================
25 DocBook to HTML - Function Synopses
26
27 REMARK: Describe this module
28 -->
29
30
31 <!--@@==========================================================================
32 db2html.funcsynopsis.style
33 How to render `funcsynopsis` elements
34
35 This parameter controls the indentation style used to render `funcsynopsis`
36 elements. Supported values are `'KR'` and `'ANSI'`. This value can also
37 be set with the `db2html.funcsynopsis.style` processing instruction at the
38 top of the XML document. The same processing instruction or inside a
39 `funcsynopsis` element will override this setting for that synopsis.
40 -->
41 <xsl:param name="db2html.funcsynopsis.style">
42 <xsl:choose>
43 <xsl:when test="/processing-instruction('db2html.funcsynopsis.style')">
44 <xsl:value-of select="/processing-instruction('db2html.funcsynopsis.style')"/>
45 </xsl:when>
46 <xsl:otherwise>
47 <xsl:value-of select="'ANSI'"/>
48 </xsl:otherwise>
49 </xsl:choose>
50 </xsl:param>
51
52
53 <!-- == Matched Templates == -->
54
55 <!-- = funcdef = -->
56 <xsl:template match="funcdef | db:funcdef">
57 <xsl:call-template name="db2html.inline"/>
58 </xsl:template>
59
60 <!-- = funcparams = -->
61 <xsl:template match="funcparams | db:funcparams">
62 <xsl:text>(</xsl:text>
63 <xsl:call-template name="db2html.inline"/>
64 <xsl:text>)</xsl:text>
65 </xsl:template>
66
67 <!-- = funcprototype = -->
68 <xsl:template match="funcprototype | db:funcprototype">
69 <xsl:variable name="style">
70 <xsl:choose>
71 <xsl:when test="../processing-instruction('db2html.funcsynopsis.style')">
72 <xsl:value-of select="../processing-instruction('db2html.funcsynopsis.style')"/>
73 </xsl:when>
74 <xsl:otherwise>
75 <xsl:value-of select="$db2html.funcsynopsis.style"/>
76 </xsl:otherwise>
77 </xsl:choose>
78 </xsl:variable>
79 <xsl:for-each select="funcdef/preceding-sibling::modifier |
80 db:funcdef/preceding-sibling::db:modifier">
81 <xsl:apply-templates select="."/>
82 <xsl:text> </xsl:text>
83 </xsl:for-each>
84 <xsl:apply-templates select="funcdef | db:funcdef"/>
85 <xsl:text> (</xsl:text>
86 <xsl:choose>
87 <xsl:when test="$style = 'KR'">
88 <xsl:for-each select="void | varargs | paramdef |
89 db:void | db:varargs | db:paramdef">
90 <xsl:if test="position() != 1">
91 <xsl:text>, </xsl:text>
92 </xsl:if>
93 <xsl:choose>
94 <xsl:when test="self::paramdef or self::db:paramdef">
95 <xsl:call-template name="db2html.inline">
96 <xsl:with-param name="node" select="."/>
97 <xsl:with-param name="children" select="parameter | db:parameter"/>
98 </xsl:call-template>
99 </xsl:when>
100 <xsl:otherwise>
101 <xsl:apply-templates select="."/>
102 </xsl:otherwise>
103 </xsl:choose>
104 </xsl:for-each>
105 <xsl:text>)</xsl:text>
106 <xsl:for-each select="funcdef/following-sibling::modifier |
107 db:funcdef/following-sibling::db:modifier">
108 <xsl:text> </xsl:text>
109 <xsl:apply-templates select="."/>
110 </xsl:for-each>
111 <xsl:text>;</xsl:text>
112 <xsl:for-each select="paramdef | db:paramdef">
113 <xsl:text>&#x000A; </xsl:text>
114 <xsl:apply-templates select="."/>
115 <xsl:text>;</xsl:text>
116 </xsl:for-each>
117 </xsl:when>
118 <!-- ANSI is the default -->
119 <xsl:otherwise>
120 <xsl:variable name="indent">
121 <xsl:call-template name="_db2html.funcsynopsis.pad">
122 <xsl:with-param name="nodes"
123 select="funcdef | funcdef/preceding-sibling::modifier|
124 db:funcdef |
125 db:fundef/preceding-sibling::db:modifier"/>
126 </xsl:call-template>
127 <xsl:value-of select="str:padding(count(funcdef/preceding-sibling::modifier) +
128 count(db:funcdef/preceding-sibling::db:modifier) + 2)"/>
129 </xsl:variable>
130 <xsl:for-each select="void | varargs | paramdef |
131 db:void | db:varargs | db:paramdef">
132 <xsl:if test="position() != 1">
133 <xsl:text>,&#x000A;</xsl:text>
134 <xsl:value-of select="$indent"/>
135 </xsl:if>
136 <xsl:apply-templates select="."/>
137 </xsl:for-each>
138 <xsl:text>)</xsl:text>
139 <xsl:for-each select="funcdef/following-sibling::modifier |
140 db:funcdef/following-sibling::db:modifier">
141 <xsl:text> </xsl:text>
142 <xsl:apply-templates select="."/>
143 </xsl:for-each>
144 <xsl:text>;</xsl:text>
145 </xsl:otherwise>
146 </xsl:choose>
147 </xsl:template>
148
149 <!-- = funcsynopsis = -->
150 <xsl:template match="funcsynopsis | db:funcsynopsis">
151 <xsl:call-template name="db2html.pre">
152 <xsl:with-param name="node" select="."/>
153 <xsl:with-param name="children" select="*"/>
154 <xsl:with-param name="class" select="'synopsis'"/>
155 </xsl:call-template>
156 </xsl:template>
157
158 <!-- = funcsynopsisinfo = -->
159 <xsl:template match="funcsynopsisinfo | db:funcsynopsisinfo">
160 <xsl:call-template name="db2html.pre"/>
161 </xsl:template>
162
163 <!-- = initializer = -->
164 <xsl:template match="initializer | db:initializer">
165 <xsl:call-template name="db2html.inline"/>
166 </xsl:template>
167
168 <!-- = modifier = -->
169 <xsl:template match="modifier | db:modifier">
170 <xsl:call-template name="db2html.inline"/>
171 </xsl:template>
172
173 <!-- = paramdef = -->
174 <xsl:template match="paramdef | db:paramdef">
175 <xsl:call-template name="db2html.inline"/>
176 </xsl:template>
177
178 <!-- = varargs = -->
179 <xsl:template match="varargs | db:varargs">
180 <xsl:text>...</xsl:text>
181 </xsl:template>
182
183 <!-- = void = -->
184 <xsl:template match="void | db:void">
185 <xsl:text>void</xsl:text>
186 </xsl:template>
187
188
189 <!-- == Utility Templates == -->
190
191 <!--#* _db2html.funcsynopsis.pad -->
192 <xsl:template name="_db2html.funcsynopsis.pad">
193 <xsl:param name="nodes"/>
194 <xsl:value-of select="str:padding(string-length($nodes[1]))"/>
195 <xsl:if test="$nodes[position() != 1]">
196 <xsl:call-template name="_db2html.funcsynopsis.pad">
197 <xsl:with-param name="nodes" select="$nodes[position() != 1]"/>
198 </xsl:call-template>
199 </xsl:if>
200 </xsl:template>
201
202 </xsl:stylesheet>