blob: b4dc65ea0465424eac997b44f8ee04d99efdd6a0 [file] [log] [blame]
Daniel Veillardc72f9fd2003-11-16 23:59:52 +00001<?xml version="1.0"?>
2<!--
3 Stylesheet to generate the HTML documentation from an XML API descriptions:
4 xsltproc newapi.xsl libxml2-api.xml
5
6 Daniel Veillard
7-->
8<xsl:stylesheet version="1.0"
9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:exsl="http://exslt.org/common"
11 extension-element-prefixes="exsl"
12 exclude-result-prefixes="exsl">
13
14 <!-- Import the resto of the site stylesheets -->
15 <xsl:import href="site.xsl"/>
16
17 <!-- Generate XHTML-1.0 transitional -->
18 <xsl:output method="xml" encoding="ISO-8859-1" indent="yes"
19 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
20 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
21
22 <!-- Build keys for all symbols -->
23 <xsl:key name="symbols" match="/api/symbols/*" use="@name"/>
24
25 <!-- the target directory -->
26 <xsl:variable name="htmldir">newhtml</xsl:variable>
27
28 <xsl:template name="dumptext">
29 <xsl:param name="text"/>
30 <xsl:value-of select="$text"/>
31 </xsl:template>
32
33 <xsl:template match="macro" mode="toc">
34 <xsl:text>#define </xsl:text><a href="#{@name}"><xsl:value-of select="@name"/></a><xsl:text>
35
36</xsl:text>
37 </xsl:template>
38
39 <xsl:template match="struct" mode="toc">
40 <xsl:text>Structure </xsl:text><a name="{@name}"><xsl:value-of select="@name"/></a><br/>
41 <xsl:value-of select="@type"/><xsl:text> {
42</xsl:text>
43 <xsl:for-each select="field">
44 <xsl:text> </xsl:text>
45 <xsl:value-of select="@type"/><xsl:text>&#9;</xsl:text>
46 <xsl:value-of select="@name"/><xsl:text>&#9;: </xsl:text>
47 <xsl:value-of select="substring(@info, 1, 50)"/><xsl:text>
48</xsl:text>
49 </xsl:for-each>
50 <xsl:text>}
51
52</xsl:text>
53 </xsl:template>
54
55 <xsl:template match="macro">
56 <xsl:variable name="name" select="string(@name)"/>
57 <h3><a name="{$name}"></a>Macro: <xsl:value-of select="$name"/></h3>
58 <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
59 <p>
60 <xsl:call-template name="dumptext">
61 <xsl:with-param name="text" select="info"/>
62 </xsl:call-template>
63 </p><xsl:text>
64</xsl:text>
65 </xsl:template>
66
67 <xsl:template match="function" mode="toc">
68 <xsl:call-template name="dumptext">
69 <xsl:with-param name="text" select="return/@type"/>
70 </xsl:call-template>
71 <xsl:text>&#9;</xsl:text>
72 <a href="#{@name}"><xsl:value-of select="@name"/></a>
73 <xsl:text>&#9;(</xsl:text>
74 <xsl:for-each select="arg">
75 <xsl:call-template name="dumptext">
76 <xsl:with-param name="text" select="@type"/>
77 </xsl:call-template>
78 <xsl:text> </xsl:text>
79 <xsl:value-of select="@name"/>
80 <xsl:if test="position() != last()">
81 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9;</xsl:text>
82 </xsl:if>
83 </xsl:for-each>
84 <xsl:text>)</xsl:text><br/>
85 <xsl:text>
86</xsl:text>
87 </xsl:template>
88
89 <xsl:template match="function">
90 <xsl:variable name="name" select="string(@name)"/>
91 <h3><a name="{$name}"></a>Function: <xsl:value-of select="$name"/></h3>
92 <pre class="programlisting">
93 <xsl:call-template name="dumptext">
94 <xsl:with-param name="text" select="return/@type"/>
95 </xsl:call-template>
96 <xsl:text>&#9;</xsl:text>
97 <xsl:value-of select="@name"/>
98 <xsl:text>&#9;(</xsl:text>
99 <xsl:for-each select="arg">
100 <xsl:call-template name="dumptext">
101 <xsl:with-param name="text" select="@type"/>
102 </xsl:call-template>
103 <xsl:text> </xsl:text>
104 <xsl:value-of select="@name"/>
105 <xsl:if test="position() != last()">
106 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9;</xsl:text>
107 </xsl:if>
108 </xsl:for-each>
109 <xsl:text>)</xsl:text><br/>
110 <xsl:text>
111</xsl:text>
112 </pre>
113 <p>
114 <xsl:call-template name="dumptext">
115 <xsl:with-param name="text" select="info"/>
116 </xsl:call-template>
117 </p><xsl:text>
118</xsl:text>
119 <div class="variablelist"><table border="0"><col align="left"/><tbody>
120 <xsl:for-each select="arg">
121 <tr>
122 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
123 <td><xsl:value-of select="@info"/></td>
124 </tr>
125 </xsl:for-each>
126 <xsl:if test="return/@info">
127 <tr>
128 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
129 <td><xsl:value-of select="return/@info"/></td>
130 </tr>
131 </xsl:if>
132 </tbody></table></div>
133 </xsl:template>
134
135 <xsl:template match="exports" mode="toc">
136 <xsl:apply-templates select="key('symbols', string(@symbol))" mode="toc"/>
137 </xsl:template>
138
139 <xsl:template match="exports">
140 <xsl:apply-templates select="key('symbols', string(@symbol))"/>
141 </xsl:template>
142
143 <xsl:template match="file">
144 <xsl:variable name="name" select="@name"/>
145 <xsl:variable name="title">Module <xsl:value-of select="$name"/> from <xsl:value-of select="/api/@name"/></xsl:variable>
146 <xsl:document href="{$htmldir}/libxml-{$name}.html" method="xml" encoding="ISO-8859-1"
147 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
148 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
149 <html>
150 <head>
151 <xsl:call-template name="style"/>
152 <title><xsl:value-of select="$title"/></title>
153 </head>
154 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
155 <xsl:call-template name="titlebox">
156 <xsl:with-param name="title" select="$title"/>
157 </xsl:call-template>
158 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
159 <tr>
160 <td bgcolor="#8b7765">
161 <table border="0" cellspacing="0" cellpadding="2" width="100%">
162 <tr>
163 <td valign="top" width="200" bgcolor="#8b7765">
164 <xsl:call-template name="toc"/>
165 </td>
166 <td valign="top" bgcolor="#8b7765">
167 <table border="0" cellspacing="0" cellpadding="1" width="100%">
168 <tr>
169 <td>
170 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
171 <tr>
172 <td>
173 <table border="0" cellpadding="3" cellspacing="1" width="100%">
174 <tr>
175 <td bgcolor="#fffacd">
176 <h2>Table of Contents</h2>
177 <pre>
178 <xsl:apply-templates select="exports" mode="toc"/>
179 </pre>
180 <h2>Description</h2>
181 <xsl:text>
182</xsl:text>
183 <xsl:apply-templates select="exports"/>
184 <p><a href="bugs.html">Daniel Veillard</a></p>
185 </td>
186 </tr>
187 </table>
188 </td>
189 </tr>
190 </table>
191 </td>
192 </tr>
193 </table>
194 </td>
195 </tr>
196 </table>
197 </td>
198 </tr>
199 </table>
200 </body>
201 </html>
202 </xsl:document>
203 </xsl:template>
204
205 <xsl:template match="file" mode="toc">
206 <xsl:variable name="name" select="@name"/>
207 <li> <a href="libxml-{$name}.html"><xsl:value-of select="$name"/></a></li>
208 </xsl:template>
209
210 <xsl:template match="/">
211 <xsl:variable name="title">Reference Manual for <xsl:value-of select="/api/@name"/></xsl:variable>
212 <xsl:document href="{$htmldir}/index.html" method="xml" encoding="ISO-8859-1"
213 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
214 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
215 <html>
216 <head>
217 <xsl:call-template name="style"/>
218 <title><xsl:value-of select="$title"/></title>
219 </head>
220 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
221 <xsl:call-template name="titlebox">
222 <xsl:with-param name="title" select="$title"/>
223 </xsl:call-template>
224 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
225 <tr>
226 <td bgcolor="#8b7765">
227 <table border="0" cellspacing="0" cellpadding="2" width="100%">
228 <tr>
229 <td valign="top" width="200" bgcolor="#8b7765">
230 <xsl:call-template name="toc"/>
231 </td>
232 <td valign="top" bgcolor="#8b7765">
233 <table border="0" cellspacing="0" cellpadding="1" width="100%">
234 <tr>
235 <td>
236 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
237 <tr>
238 <td>
239 <table border="0" cellpadding="3" cellspacing="1" width="100%">
240 <tr>
241 <td bgcolor="#fffacd">
242 <h2>Table of Contents</h2>
243 <ul>
244 <xsl:apply-templates select="/api/files/file" mode="toc"/>
245 </ul>
246 <p><a href="bugs.html">Daniel Veillard</a></p>
247 </td>
248 </tr>
249 </table>
250 </td>
251 </tr>
252 </table>
253 </td>
254 </tr>
255 </table>
256 </td>
257 </tr>
258 </table>
259 </td>
260 </tr>
261 </table>
262 </body>
263 </html>
264 </xsl:document>
265 <!-- now build the file for each of the modules -->
266 <xsl:apply-templates select="/api/files/file"/>
267 </xsl:template>
268
269</xsl:stylesheet>