blob: d17efc663ba6dc82abf3c63511656d0203c18695 [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"
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000011 xmlns:str="http://exslt.org/strings"
12 extension-element-prefixes="exsl str"
13 exclude-result-prefixes="exsl str">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000014
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000015 <!-- Import the main part of the site stylesheets -->
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000016 <xsl:import href="site.xsl"/>
17
18 <!-- Generate XHTML-1.0 transitional -->
19 <xsl:output method="xml" encoding="ISO-8859-1" indent="yes"
20 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
21 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
22
23 <!-- Build keys for all symbols -->
24 <xsl:key name="symbols" match="/api/symbols/*" use="@name"/>
25
26 <!-- the target directory -->
27 <xsl:variable name="htmldir">newhtml</xsl:variable>
28
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000029 <!-- This is convoluted but needed to force the current document to
30 be the API one and not the result tree from the tokenize() result,
31 because the keys are only defined on the main document -->
32 <xsl:template mode="dumptoken" match='*'>
33 <xsl:param name="token"/>
34 <xsl:variable name="ref" select="key('symbols', $token)"/>
35 <xsl:choose>
36 <xsl:when test="$ref">
37 <a href="libxml-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:value-of select="$token"/>
41 </xsl:otherwise>
42 </xsl:choose>
43 </xsl:template>
44
45 <!-- dumps a string, making cross-reference links -->
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000046 <xsl:template name="dumptext">
47 <xsl:param name="text"/>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000048 <xsl:variable name="ctxt" select='.'/>
49 <!-- <xsl:value-of select="$text"/> -->
50 <xsl:for-each select="str:tokenize($text, ' &#9;')">
51 <xsl:apply-templates select="$ctxt" mode='dumptoken'>
52 <xsl:with-param name="token" select="string(.)"/>
53 </xsl:apply-templates>
54 <xsl:if test="position() != last()">
55 <xsl:text> </xsl:text>
56 </xsl:if>
57 </xsl:for-each>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000058 </xsl:template>
59
60 <xsl:template match="macro" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000061 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000062 <xsl:text>#define </xsl:text><a href="#{@name}"><xsl:value-of select="@name"/></a><xsl:text>
63
64</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000065 </pre>
66 </xsl:template>
67
68 <xsl:template match="typedef" mode="toc">
69 <xsl:variable name="name" select="string(@name)"/>
70 <pre class="programlisting">
71 <xsl:choose>
72 <xsl:when test="@type = 'enum'">
73 <xsl:text>Enum </xsl:text>
74 <a name="{$name}"><xsl:value-of select="$name"/></a>
75 <xsl:text> {
76</xsl:text>
77 <xsl:for-each select="/api/symbols/enum[@type = $name]">
78 <xsl:sort select="@value" data-type="number" order="ascending"/>
79 <xsl:text> </xsl:text>
80 <a name="{@name}"><xsl:value-of select="@name"/></a>
81 <xsl:text> = </xsl:text>
82 <xsl:value-of select="@value"/>
83 <xsl:if test="@info != ''">
84 <xsl:text> : </xsl:text>
85 <xsl:call-template name="dumptext">
86 <xsl:with-param name="text" select="@info"/>
87 </xsl:call-template>
88 </xsl:if>
89 <xsl:text>
90</xsl:text>
91 </xsl:for-each>
92 <xsl:text>}
93
94</xsl:text>
95 </xsl:when>
96 <xsl:otherwise>
97 <xsl:text>Typedef </xsl:text>
98 <xsl:call-template name="dumptext">
99 <xsl:with-param name="text" select="@type"/>
100 </xsl:call-template>
101 <xsl:text> </xsl:text>
102 <a name="{$name}"><xsl:value-of select="$name"/></a>
103 <xsl:text>
104
105</xsl:text>
106 </xsl:otherwise>
107 </xsl:choose>
108 </pre>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000109 </xsl:template>
110
111 <xsl:template match="struct" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000112 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000113 <xsl:text>Structure </xsl:text><a name="{@name}"><xsl:value-of select="@name"/></a><br/>
114 <xsl:value-of select="@type"/><xsl:text> {
115</xsl:text>
116 <xsl:for-each select="field">
117 <xsl:text> </xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000118 <xsl:call-template name="dumptext">
119 <xsl:with-param name="text" select="@type"/>
120 </xsl:call-template>
121 <xsl:text>&#9;</xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000122 <xsl:value-of select="@name"/><xsl:text>&#9;: </xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000123 <xsl:call-template name="dumptext">
124 <xsl:with-param name="text" select="substring(@info, 1, 50)"/>
125 </xsl:call-template>
126 <xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000127</xsl:text>
128 </xsl:for-each>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000129 </pre>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000130 <xsl:text>}
131
132</xsl:text>
133 </xsl:template>
134
135 <xsl:template match="macro">
136 <xsl:variable name="name" select="string(@name)"/>
137 <h3><a name="{$name}"></a>Macro: <xsl:value-of select="$name"/></h3>
138 <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
139 <p>
140 <xsl:call-template name="dumptext">
141 <xsl:with-param name="text" select="info"/>
142 </xsl:call-template>
143 </p><xsl:text>
144</xsl:text>
145 </xsl:template>
146
147 <xsl:template match="function" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000148 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000149 <xsl:call-template name="dumptext">
150 <xsl:with-param name="text" select="return/@type"/>
151 </xsl:call-template>
152 <xsl:text>&#9;</xsl:text>
153 <a href="#{@name}"><xsl:value-of select="@name"/></a>
154 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000155 <xsl:if test="not(arg)">
156 <xsl:text>void</xsl:text>
157 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000158 <xsl:for-each select="arg">
159 <xsl:call-template name="dumptext">
160 <xsl:with-param name="text" select="@type"/>
161 </xsl:call-template>
162 <xsl:text> </xsl:text>
163 <xsl:value-of select="@name"/>
164 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000165 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000166 </xsl:if>
167 </xsl:for-each>
168 <xsl:text>)</xsl:text><br/>
169 <xsl:text>
170</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000171 </pre>
172 </xsl:template>
173
174 <xsl:template match="functype" mode="toc">
175 <pre class="programlisting">
176 <xsl:variable name="name" select="string(@name)"/>
177 <a name="{$name}"></a>
178 <xsl:text>Function type: </xsl:text>
179 <xsl:value-of select="$name"/>
180 <xsl:text>
181</xsl:text>
182 <xsl:call-template name="dumptext">
183 <xsl:with-param name="text" select="return/@type"/>
184 </xsl:call-template>
185 <xsl:text>&#9;</xsl:text>
186 <xsl:value-of select="@name"/>
187 <xsl:text>&#9;(</xsl:text>
188 <xsl:if test="not(arg)">
189 <xsl:text>void</xsl:text>
190 </xsl:if>
191 <xsl:for-each select="arg">
192 <xsl:call-template name="dumptext">
193 <xsl:with-param name="text" select="@type"/>
194 </xsl:call-template>
195 <xsl:text> </xsl:text>
196 <xsl:value-of select="@name"/>
197 <xsl:if test="position() != last()">
198 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
199 </xsl:if>
200 </xsl:for-each>
201 <xsl:text>)
202</xsl:text>
203 </pre>
204 <p>
205 <xsl:call-template name="dumptext">
206 <xsl:with-param name="text" select="info"/>
207 </xsl:call-template>
208 </p><xsl:text>
209</xsl:text>
210 <xsl:if test="arg | return">
211 <div class="variablelist"><table border="0"><col align="left"/><tbody>
212 <xsl:for-each select="arg">
213 <tr>
214 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
215 <td><xsl:value-of select="@info"/></td>
216 </tr>
217 </xsl:for-each>
218 <xsl:if test="return/@info">
219 <tr>
220 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
221 <td><xsl:value-of select="return/@info"/></td>
222 </tr>
223 </xsl:if>
224 </tbody></table></div>
225 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000226 </xsl:template>
227
228 <xsl:template match="function">
229 <xsl:variable name="name" select="string(@name)"/>
230 <h3><a name="{$name}"></a>Function: <xsl:value-of select="$name"/></h3>
231 <pre class="programlisting">
232 <xsl:call-template name="dumptext">
233 <xsl:with-param name="text" select="return/@type"/>
234 </xsl:call-template>
235 <xsl:text>&#9;</xsl:text>
236 <xsl:value-of select="@name"/>
237 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000238 <xsl:if test="not(arg)">
239 <xsl:text>void</xsl:text>
240 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000241 <xsl:for-each select="arg">
242 <xsl:call-template name="dumptext">
243 <xsl:with-param name="text" select="@type"/>
244 </xsl:call-template>
245 <xsl:text> </xsl:text>
246 <xsl:value-of select="@name"/>
247 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000248 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000249 </xsl:if>
250 </xsl:for-each>
251 <xsl:text>)</xsl:text><br/>
252 <xsl:text>
253</xsl:text>
254 </pre>
255 <p>
256 <xsl:call-template name="dumptext">
257 <xsl:with-param name="text" select="info"/>
258 </xsl:call-template>
259 </p><xsl:text>
260</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000261 <xsl:if test="arg | return/@info">
262 <div class="variablelist"><table border="0"><col align="left"/><tbody>
263 <xsl:for-each select="arg">
264 <tr>
265 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
266 <td><xsl:value-of select="@info"/></td>
267 </tr>
268 </xsl:for-each>
269 <xsl:if test="return/@info">
270 <tr>
271 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
272 <td><xsl:value-of select="return/@info"/></td>
273 </tr>
274 </xsl:if>
275 </tbody></table></div>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000276 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000277 </xsl:template>
278
279 <xsl:template match="exports" mode="toc">
280 <xsl:apply-templates select="key('symbols', string(@symbol))" mode="toc"/>
281 </xsl:template>
282
283 <xsl:template match="exports">
284 <xsl:apply-templates select="key('symbols', string(@symbol))"/>
285 </xsl:template>
286
287 <xsl:template match="file">
288 <xsl:variable name="name" select="@name"/>
289 <xsl:variable name="title">Module <xsl:value-of select="$name"/> from <xsl:value-of select="/api/@name"/></xsl:variable>
290 <xsl:document href="{$htmldir}/libxml-{$name}.html" method="xml" encoding="ISO-8859-1"
291 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
292 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
293 <html>
294 <head>
295 <xsl:call-template name="style"/>
296 <title><xsl:value-of select="$title"/></title>
297 </head>
298 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
299 <xsl:call-template name="titlebox">
300 <xsl:with-param name="title" select="$title"/>
301 </xsl:call-template>
302 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
303 <tr>
304 <td bgcolor="#8b7765">
305 <table border="0" cellspacing="0" cellpadding="2" width="100%">
306 <tr>
307 <td valign="top" width="200" bgcolor="#8b7765">
308 <xsl:call-template name="toc"/>
309 </td>
310 <td valign="top" bgcolor="#8b7765">
311 <table border="0" cellspacing="0" cellpadding="1" width="100%">
312 <tr>
313 <td>
314 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
315 <tr>
316 <td>
317 <table border="0" cellpadding="3" cellspacing="1" width="100%">
318 <tr>
319 <td bgcolor="#fffacd">
320 <h2>Table of Contents</h2>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000321 <xsl:apply-templates select="exports" mode="toc"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000322 <h2>Description</h2>
323 <xsl:text>
324</xsl:text>
325 <xsl:apply-templates select="exports"/>
326 <p><a href="bugs.html">Daniel Veillard</a></p>
327 </td>
328 </tr>
329 </table>
330 </td>
331 </tr>
332 </table>
333 </td>
334 </tr>
335 </table>
336 </td>
337 </tr>
338 </table>
339 </td>
340 </tr>
341 </table>
342 </body>
343 </html>
344 </xsl:document>
345 </xsl:template>
346
347 <xsl:template match="file" mode="toc">
348 <xsl:variable name="name" select="@name"/>
349 <li> <a href="libxml-{$name}.html"><xsl:value-of select="$name"/></a></li>
350 </xsl:template>
351
352 <xsl:template match="/">
353 <xsl:variable name="title">Reference Manual for <xsl:value-of select="/api/@name"/></xsl:variable>
354 <xsl:document href="{$htmldir}/index.html" method="xml" encoding="ISO-8859-1"
355 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
356 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
357 <html>
358 <head>
359 <xsl:call-template name="style"/>
360 <title><xsl:value-of select="$title"/></title>
361 </head>
362 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
363 <xsl:call-template name="titlebox">
364 <xsl:with-param name="title" select="$title"/>
365 </xsl:call-template>
366 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
367 <tr>
368 <td bgcolor="#8b7765">
369 <table border="0" cellspacing="0" cellpadding="2" width="100%">
370 <tr>
371 <td valign="top" width="200" bgcolor="#8b7765">
372 <xsl:call-template name="toc"/>
373 </td>
374 <td valign="top" bgcolor="#8b7765">
375 <table border="0" cellspacing="0" cellpadding="1" width="100%">
376 <tr>
377 <td>
378 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
379 <tr>
380 <td>
381 <table border="0" cellpadding="3" cellspacing="1" width="100%">
382 <tr>
383 <td bgcolor="#fffacd">
384 <h2>Table of Contents</h2>
385 <ul>
386 <xsl:apply-templates select="/api/files/file" mode="toc"/>
387 </ul>
388 <p><a href="bugs.html">Daniel Veillard</a></p>
389 </td>
390 </tr>
391 </table>
392 </td>
393 </tr>
394 </table>
395 </td>
396 </tr>
397 </table>
398 </td>
399 </tr>
400 </table>
401 </td>
402 </tr>
403 </table>
404 </body>
405 </html>
406 </xsl:document>
407 <!-- now build the file for each of the modules -->
408 <xsl:apply-templates select="/api/files/file"/>
409 </xsl:template>
410
411</xsl:stylesheet>