blob: 6ad33ba479242bf8708e65580e0fef36aee5ffd3 [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
Daniel Veillard2925c0a2003-11-17 13:58:17 +000026 <!-- the target directory for the HTML output -->
27 <xsl:variable name="htmldir">html</xsl:variable>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000028
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
Daniel Veillard2925c0a2003-11-17 13:58:17 +000068 <xsl:template match="variable" mode="toc">
69 <pre class="programlisting">
70 <xsl:text>Variable </xsl:text>
71 <xsl:call-template name="dumptext">
72 <xsl:with-param name="text" select="string(@type)"/>
73 </xsl:call-template>
74 <xsl:text> </xsl:text>
75 <a name="{@name}"></a>
76 <xsl:value-of select="@name"/>
77 <xsl:text>
78
79</xsl:text>
80 </pre>
81 </xsl:template>
82
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000083 <xsl:template match="typedef" mode="toc">
84 <xsl:variable name="name" select="string(@name)"/>
85 <pre class="programlisting">
86 <xsl:choose>
87 <xsl:when test="@type = 'enum'">
88 <xsl:text>Enum </xsl:text>
89 <a name="{$name}"><xsl:value-of select="$name"/></a>
90 <xsl:text> {
91</xsl:text>
92 <xsl:for-each select="/api/symbols/enum[@type = $name]">
93 <xsl:sort select="@value" data-type="number" order="ascending"/>
94 <xsl:text> </xsl:text>
95 <a name="{@name}"><xsl:value-of select="@name"/></a>
96 <xsl:text> = </xsl:text>
97 <xsl:value-of select="@value"/>
98 <xsl:if test="@info != ''">
99 <xsl:text> : </xsl:text>
100 <xsl:call-template name="dumptext">
101 <xsl:with-param name="text" select="@info"/>
102 </xsl:call-template>
103 </xsl:if>
104 <xsl:text>
105</xsl:text>
106 </xsl:for-each>
107 <xsl:text>}
108
109</xsl:text>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:text>Typedef </xsl:text>
113 <xsl:call-template name="dumptext">
114 <xsl:with-param name="text" select="@type"/>
115 </xsl:call-template>
116 <xsl:text> </xsl:text>
117 <a name="{$name}"><xsl:value-of select="$name"/></a>
118 <xsl:text>
119
120</xsl:text>
121 </xsl:otherwise>
122 </xsl:choose>
123 </pre>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000124 </xsl:template>
125
126 <xsl:template match="struct" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000127 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000128 <xsl:text>Structure </xsl:text><a name="{@name}"><xsl:value-of select="@name"/></a><br/>
129 <xsl:value-of select="@type"/><xsl:text> {
130</xsl:text>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000131 <xsl:if test="not(field)">
132 <xsl:text>The content of this structure is not made public by the API.
133</xsl:text>
134 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000135 <xsl:for-each select="field">
136 <xsl:text> </xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000137 <xsl:call-template name="dumptext">
138 <xsl:with-param name="text" select="@type"/>
139 </xsl:call-template>
140 <xsl:text>&#9;</xsl:text>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000141 <xsl:value-of select="@name"/>
142 <xsl:if test="@info != ''">
143 <xsl:text>&#9;: </xsl:text>
144 <xsl:call-template name="dumptext">
145 <xsl:with-param name="text" select="substring(@info, 1, 50)"/>
146 </xsl:call-template>
147 </xsl:if>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000148 <xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000149</xsl:text>
150 </xsl:for-each>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000151 <xsl:text>}</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000152 </pre>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000153 <br/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000154 </xsl:template>
155
156 <xsl:template match="macro">
157 <xsl:variable name="name" select="string(@name)"/>
158 <h3><a name="{$name}"></a>Macro: <xsl:value-of select="$name"/></h3>
159 <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
160 <p>
161 <xsl:call-template name="dumptext">
162 <xsl:with-param name="text" select="info"/>
163 </xsl:call-template>
164 </p><xsl:text>
165</xsl:text>
166 </xsl:template>
167
168 <xsl:template match="function" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000169 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000170 <xsl:call-template name="dumptext">
171 <xsl:with-param name="text" select="return/@type"/>
172 </xsl:call-template>
173 <xsl:text>&#9;</xsl:text>
174 <a href="#{@name}"><xsl:value-of select="@name"/></a>
175 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000176 <xsl:if test="not(arg)">
177 <xsl:text>void</xsl:text>
178 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000179 <xsl:for-each select="arg">
180 <xsl:call-template name="dumptext">
181 <xsl:with-param name="text" select="@type"/>
182 </xsl:call-template>
183 <xsl:text> </xsl:text>
184 <xsl:value-of select="@name"/>
185 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000186 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000187 </xsl:if>
188 </xsl:for-each>
189 <xsl:text>)</xsl:text><br/>
190 <xsl:text>
191</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000192 </pre>
193 </xsl:template>
194
195 <xsl:template match="functype" mode="toc">
196 <pre class="programlisting">
197 <xsl:variable name="name" select="string(@name)"/>
198 <a name="{$name}"></a>
199 <xsl:text>Function type: </xsl:text>
200 <xsl:value-of select="$name"/>
201 <xsl:text>
202</xsl:text>
203 <xsl:call-template name="dumptext">
204 <xsl:with-param name="text" select="return/@type"/>
205 </xsl:call-template>
206 <xsl:text>&#9;</xsl:text>
207 <xsl:value-of select="@name"/>
208 <xsl:text>&#9;(</xsl:text>
209 <xsl:if test="not(arg)">
210 <xsl:text>void</xsl:text>
211 </xsl:if>
212 <xsl:for-each select="arg">
213 <xsl:call-template name="dumptext">
214 <xsl:with-param name="text" select="@type"/>
215 </xsl:call-template>
216 <xsl:text> </xsl:text>
217 <xsl:value-of select="@name"/>
218 <xsl:if test="position() != last()">
219 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
220 </xsl:if>
221 </xsl:for-each>
222 <xsl:text>)
223</xsl:text>
224 </pre>
225 <p>
226 <xsl:call-template name="dumptext">
227 <xsl:with-param name="text" select="info"/>
228 </xsl:call-template>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000229 </p>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000230 <xsl:if test="arg | return">
231 <div class="variablelist"><table border="0"><col align="left"/><tbody>
232 <xsl:for-each select="arg">
233 <tr>
234 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000235 <td>
236 <xsl:call-template name="dumptext">
237 <xsl:with-param name="text" select="@info"/>
238 </xsl:call-template>
239 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000240 </tr>
241 </xsl:for-each>
242 <xsl:if test="return/@info">
243 <tr>
244 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000245 <td>
246 <xsl:call-template name="dumptext">
247 <xsl:with-param name="text" select="return/@info"/>
248 </xsl:call-template>
249 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000250 </tr>
251 </xsl:if>
252 </tbody></table></div>
253 </xsl:if>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000254 <br/>
255 <xsl:text>
256</xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000257 </xsl:template>
258
259 <xsl:template match="function">
260 <xsl:variable name="name" select="string(@name)"/>
261 <h3><a name="{$name}"></a>Function: <xsl:value-of select="$name"/></h3>
262 <pre class="programlisting">
263 <xsl:call-template name="dumptext">
264 <xsl:with-param name="text" select="return/@type"/>
265 </xsl:call-template>
266 <xsl:text>&#9;</xsl:text>
267 <xsl:value-of select="@name"/>
268 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000269 <xsl:if test="not(arg)">
270 <xsl:text>void</xsl:text>
271 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000272 <xsl:for-each select="arg">
273 <xsl:call-template name="dumptext">
274 <xsl:with-param name="text" select="@type"/>
275 </xsl:call-template>
276 <xsl:text> </xsl:text>
277 <xsl:value-of select="@name"/>
278 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000279 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000280 </xsl:if>
281 </xsl:for-each>
282 <xsl:text>)</xsl:text><br/>
283 <xsl:text>
284</xsl:text>
285 </pre>
286 <p>
287 <xsl:call-template name="dumptext">
288 <xsl:with-param name="text" select="info"/>
289 </xsl:call-template>
290 </p><xsl:text>
291</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000292 <xsl:if test="arg | return/@info">
293 <div class="variablelist"><table border="0"><col align="left"/><tbody>
294 <xsl:for-each select="arg">
295 <tr>
296 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000297 <td>
298 <xsl:call-template name="dumptext">
299 <xsl:with-param name="text" select="@info"/>
300 </xsl:call-template>
301 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000302 </tr>
303 </xsl:for-each>
304 <xsl:if test="return/@info">
305 <tr>
306 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000307 <td>
308 <xsl:call-template name="dumptext">
309 <xsl:with-param name="text" select="return/@info"/>
310 </xsl:call-template>
311 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000312 </tr>
313 </xsl:if>
314 </tbody></table></div>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000315 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000316 </xsl:template>
317
318 <xsl:template match="exports" mode="toc">
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000319 <xsl:apply-templates select="key('symbols', string(@symbol))[1]" mode="toc"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000320 </xsl:template>
321
322 <xsl:template match="exports">
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000323 <xsl:apply-templates select="key('symbols', string(@symbol))[1]"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000324 </xsl:template>
325
326 <xsl:template match="file">
327 <xsl:variable name="name" select="@name"/>
328 <xsl:variable name="title">Module <xsl:value-of select="$name"/> from <xsl:value-of select="/api/@name"/></xsl:variable>
329 <xsl:document href="{$htmldir}/libxml-{$name}.html" method="xml" encoding="ISO-8859-1"
330 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
331 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
332 <html>
333 <head>
334 <xsl:call-template name="style"/>
335 <title><xsl:value-of select="$title"/></title>
336 </head>
337 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
338 <xsl:call-template name="titlebox">
339 <xsl:with-param name="title" select="$title"/>
340 </xsl:call-template>
341 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
342 <tr>
343 <td bgcolor="#8b7765">
344 <table border="0" cellspacing="0" cellpadding="2" width="100%">
345 <tr>
346 <td valign="top" width="200" bgcolor="#8b7765">
347 <xsl:call-template name="toc"/>
348 </td>
349 <td valign="top" bgcolor="#8b7765">
350 <table border="0" cellspacing="0" cellpadding="1" width="100%">
351 <tr>
352 <td>
353 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
354 <tr>
355 <td>
356 <table border="0" cellpadding="3" cellspacing="1" width="100%">
357 <tr>
358 <td bgcolor="#fffacd">
359 <h2>Table of Contents</h2>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000360 <xsl:apply-templates select="exports" mode="toc"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000361 <h2>Description</h2>
362 <xsl:text>
363</xsl:text>
364 <xsl:apply-templates select="exports"/>
365 <p><a href="bugs.html">Daniel Veillard</a></p>
366 </td>
367 </tr>
368 </table>
369 </td>
370 </tr>
371 </table>
372 </td>
373 </tr>
374 </table>
375 </td>
376 </tr>
377 </table>
378 </td>
379 </tr>
380 </table>
381 </body>
382 </html>
383 </xsl:document>
384 </xsl:template>
385
386 <xsl:template match="file" mode="toc">
387 <xsl:variable name="name" select="@name"/>
388 <li> <a href="libxml-{$name}.html"><xsl:value-of select="$name"/></a></li>
389 </xsl:template>
390
391 <xsl:template match="/">
392 <xsl:variable name="title">Reference Manual for <xsl:value-of select="/api/@name"/></xsl:variable>
393 <xsl:document href="{$htmldir}/index.html" method="xml" encoding="ISO-8859-1"
394 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
395 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
396 <html>
397 <head>
398 <xsl:call-template name="style"/>
399 <title><xsl:value-of select="$title"/></title>
400 </head>
401 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
402 <xsl:call-template name="titlebox">
403 <xsl:with-param name="title" select="$title"/>
404 </xsl:call-template>
405 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
406 <tr>
407 <td bgcolor="#8b7765">
408 <table border="0" cellspacing="0" cellpadding="2" width="100%">
409 <tr>
410 <td valign="top" width="200" bgcolor="#8b7765">
411 <xsl:call-template name="toc"/>
412 </td>
413 <td valign="top" bgcolor="#8b7765">
414 <table border="0" cellspacing="0" cellpadding="1" width="100%">
415 <tr>
416 <td>
417 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
418 <tr>
419 <td>
420 <table border="0" cellpadding="3" cellspacing="1" width="100%">
421 <tr>
422 <td bgcolor="#fffacd">
423 <h2>Table of Contents</h2>
424 <ul>
425 <xsl:apply-templates select="/api/files/file" mode="toc"/>
426 </ul>
427 <p><a href="bugs.html">Daniel Veillard</a></p>
428 </td>
429 </tr>
430 </table>
431 </td>
432 </tr>
433 </table>
434 </td>
435 </tr>
436 </table>
437 </td>
438 </tr>
439 </table>
440 </td>
441 </tr>
442 </table>
443 </body>
444 </html>
445 </xsl:document>
446 <!-- now build the file for each of the modules -->
447 <xsl:apply-templates select="/api/files/file"/>
448 </xsl:template>
449
450</xsl:stylesheet>