~ubuntu-branches/ubuntu/vivid/yelp-xsl/vivid-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-11-29 10:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20101129100013-1fxze8fm1fegxl8w
Tags: upstream-2.31.6
ImportĀ upstreamĀ versionĀ 2.31.6

Show diffs side-by-side

added added

removed removed

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