blob: 7f848f76440b8a64720251bc5f9b29cc079c0603 [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 Veillardbff06bf2003-11-17 16:58:05 +000029 <xsl:template name="navbar">
30 <xsl:variable name="previous" select="preceding-sibling::file[1]"/>
31 <xsl:variable name="next" select="following-sibling::file[1]"/>
32 <table class="navigation" width="100%" summary="Navigation header"
33 cellpadding="2" cellspacing="2">
34 <tr valign="middle">
35 <xsl:if test="$previous">
36 <td><a accesskey="p" href="libxml-{$previous/@name}.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></img></a></td>
37 <th align="left"><a href="libxml-{$previous/@name}.html"><xsl:value-of select="$previous/@name"/></a></th>
38 </xsl:if>
39 <td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></img></a></td>
40 <th align="left"><a href="index.html">API documentation</a></th>
41 <td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></img></a></td>
42 <th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th>
43 <xsl:if test="$next">
44 <th align="right"><a href="libxml-{$next/@name}.html"><xsl:value-of select="$next/@name"/></a></th>
45 <td><a accesskey="n" href="libxml-{$next/@name}.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></img></a></td>
46 </xsl:if>
47 </tr>
48 </table>
49 </xsl:template>
50
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000051 <!-- This is convoluted but needed to force the current document to
52 be the API one and not the result tree from the tokenize() result,
53 because the keys are only defined on the main document -->
54 <xsl:template mode="dumptoken" match='*'>
55 <xsl:param name="token"/>
56 <xsl:variable name="ref" select="key('symbols', $token)"/>
57 <xsl:choose>
58 <xsl:when test="$ref">
59 <a href="libxml-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
60 </xsl:when>
61 <xsl:otherwise>
62 <xsl:value-of select="$token"/>
63 </xsl:otherwise>
64 </xsl:choose>
65 </xsl:template>
66
67 <!-- dumps a string, making cross-reference links -->
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000068 <xsl:template name="dumptext">
69 <xsl:param name="text"/>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000070 <xsl:variable name="ctxt" select='.'/>
71 <!-- <xsl:value-of select="$text"/> -->
72 <xsl:for-each select="str:tokenize($text, ' &#9;')">
73 <xsl:apply-templates select="$ctxt" mode='dumptoken'>
74 <xsl:with-param name="token" select="string(.)"/>
75 </xsl:apply-templates>
76 <xsl:if test="position() != last()">
77 <xsl:text> </xsl:text>
78 </xsl:if>
79 </xsl:for-each>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000080 </xsl:template>
81
82 <xsl:template match="macro" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000083 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +000084 <xsl:text>#define </xsl:text><a href="#{@name}"><xsl:value-of select="@name"/></a><xsl:text>
85
86</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +000087 </pre>
88 </xsl:template>
89
Daniel Veillard2925c0a2003-11-17 13:58:17 +000090 <xsl:template match="variable" mode="toc">
91 <pre class="programlisting">
92 <xsl:text>Variable </xsl:text>
93 <xsl:call-template name="dumptext">
94 <xsl:with-param name="text" select="string(@type)"/>
95 </xsl:call-template>
96 <xsl:text> </xsl:text>
97 <a name="{@name}"></a>
98 <xsl:value-of select="@name"/>
99 <xsl:text>
100
101</xsl:text>
102 </pre>
103 </xsl:template>
104
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000105 <xsl:template match="typedef" mode="toc">
106 <xsl:variable name="name" select="string(@name)"/>
107 <pre class="programlisting">
108 <xsl:choose>
109 <xsl:when test="@type = 'enum'">
110 <xsl:text>Enum </xsl:text>
111 <a name="{$name}"><xsl:value-of select="$name"/></a>
112 <xsl:text> {
113</xsl:text>
114 <xsl:for-each select="/api/symbols/enum[@type = $name]">
115 <xsl:sort select="@value" data-type="number" order="ascending"/>
116 <xsl:text> </xsl:text>
117 <a name="{@name}"><xsl:value-of select="@name"/></a>
118 <xsl:text> = </xsl:text>
119 <xsl:value-of select="@value"/>
120 <xsl:if test="@info != ''">
121 <xsl:text> : </xsl:text>
122 <xsl:call-template name="dumptext">
123 <xsl:with-param name="text" select="@info"/>
124 </xsl:call-template>
125 </xsl:if>
126 <xsl:text>
127</xsl:text>
128 </xsl:for-each>
129 <xsl:text>}
130
131</xsl:text>
132 </xsl:when>
133 <xsl:otherwise>
134 <xsl:text>Typedef </xsl:text>
135 <xsl:call-template name="dumptext">
136 <xsl:with-param name="text" select="@type"/>
137 </xsl:call-template>
138 <xsl:text> </xsl:text>
139 <a name="{$name}"><xsl:value-of select="$name"/></a>
140 <xsl:text>
141
142</xsl:text>
143 </xsl:otherwise>
144 </xsl:choose>
145 </pre>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000146 </xsl:template>
147
148 <xsl:template match="struct" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000149 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000150 <xsl:text>Structure </xsl:text><a name="{@name}"><xsl:value-of select="@name"/></a><br/>
151 <xsl:value-of select="@type"/><xsl:text> {
152</xsl:text>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000153 <xsl:if test="not(field)">
154 <xsl:text>The content of this structure is not made public by the API.
155</xsl:text>
156 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000157 <xsl:for-each select="field">
158 <xsl:text> </xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000159 <xsl:call-template name="dumptext">
160 <xsl:with-param name="text" select="@type"/>
161 </xsl:call-template>
162 <xsl:text>&#9;</xsl:text>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000163 <xsl:value-of select="@name"/>
164 <xsl:if test="@info != ''">
165 <xsl:text>&#9;: </xsl:text>
166 <xsl:call-template name="dumptext">
167 <xsl:with-param name="text" select="substring(@info, 1, 50)"/>
168 </xsl:call-template>
169 </xsl:if>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000170 <xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000171</xsl:text>
172 </xsl:for-each>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000173 <xsl:text>}</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000174 </pre>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000175 <br/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000176 </xsl:template>
177
178 <xsl:template match="macro">
179 <xsl:variable name="name" select="string(@name)"/>
180 <h3><a name="{$name}"></a>Macro: <xsl:value-of select="$name"/></h3>
181 <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
182 <p>
183 <xsl:call-template name="dumptext">
184 <xsl:with-param name="text" select="info"/>
185 </xsl:call-template>
186 </p><xsl:text>
187</xsl:text>
188 </xsl:template>
189
190 <xsl:template match="function" mode="toc">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000191 <pre class="programlisting">
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000192 <xsl:call-template name="dumptext">
193 <xsl:with-param name="text" select="return/@type"/>
194 </xsl:call-template>
195 <xsl:text>&#9;</xsl:text>
196 <a href="#{@name}"><xsl:value-of select="@name"/></a>
197 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000198 <xsl:if test="not(arg)">
199 <xsl:text>void</xsl:text>
200 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000201 <xsl:for-each select="arg">
202 <xsl:call-template name="dumptext">
203 <xsl:with-param name="text" select="@type"/>
204 </xsl:call-template>
205 <xsl:text> </xsl:text>
206 <xsl:value-of select="@name"/>
207 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000208 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000209 </xsl:if>
210 </xsl:for-each>
211 <xsl:text>)</xsl:text><br/>
212 <xsl:text>
213</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000214 </pre>
215 </xsl:template>
216
217 <xsl:template match="functype" mode="toc">
218 <pre class="programlisting">
219 <xsl:variable name="name" select="string(@name)"/>
220 <a name="{$name}"></a>
221 <xsl:text>Function type: </xsl:text>
222 <xsl:value-of select="$name"/>
223 <xsl:text>
224</xsl:text>
225 <xsl:call-template name="dumptext">
226 <xsl:with-param name="text" select="return/@type"/>
227 </xsl:call-template>
228 <xsl:text>&#9;</xsl:text>
229 <xsl:value-of select="@name"/>
230 <xsl:text>&#9;(</xsl:text>
231 <xsl:if test="not(arg)">
232 <xsl:text>void</xsl:text>
233 </xsl:if>
234 <xsl:for-each select="arg">
235 <xsl:call-template name="dumptext">
236 <xsl:with-param name="text" select="@type"/>
237 </xsl:call-template>
238 <xsl:text> </xsl:text>
239 <xsl:value-of select="@name"/>
240 <xsl:if test="position() != last()">
241 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
242 </xsl:if>
243 </xsl:for-each>
244 <xsl:text>)
245</xsl:text>
246 </pre>
247 <p>
248 <xsl:call-template name="dumptext">
249 <xsl:with-param name="text" select="info"/>
250 </xsl:call-template>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000251 </p>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000252 <xsl:if test="arg | return">
253 <div class="variablelist"><table border="0"><col align="left"/><tbody>
254 <xsl:for-each select="arg">
255 <tr>
256 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000257 <td>
258 <xsl:call-template name="dumptext">
259 <xsl:with-param name="text" select="@info"/>
260 </xsl:call-template>
261 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000262 </tr>
263 </xsl:for-each>
264 <xsl:if test="return/@info">
265 <tr>
266 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000267 <td>
268 <xsl:call-template name="dumptext">
269 <xsl:with-param name="text" select="return/@info"/>
270 </xsl:call-template>
271 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000272 </tr>
273 </xsl:if>
274 </tbody></table></div>
275 </xsl:if>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000276 <br/>
277 <xsl:text>
278</xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000279 </xsl:template>
280
281 <xsl:template match="function">
282 <xsl:variable name="name" select="string(@name)"/>
283 <h3><a name="{$name}"></a>Function: <xsl:value-of select="$name"/></h3>
284 <pre class="programlisting">
285 <xsl:call-template name="dumptext">
286 <xsl:with-param name="text" select="return/@type"/>
287 </xsl:call-template>
288 <xsl:text>&#9;</xsl:text>
289 <xsl:value-of select="@name"/>
290 <xsl:text>&#9;(</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000291 <xsl:if test="not(arg)">
292 <xsl:text>void</xsl:text>
293 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000294 <xsl:for-each select="arg">
295 <xsl:call-template name="dumptext">
296 <xsl:with-param name="text" select="@type"/>
297 </xsl:call-template>
298 <xsl:text> </xsl:text>
299 <xsl:value-of select="@name"/>
300 <xsl:if test="position() != last()">
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000301 <xsl:text>, </xsl:text><br/><xsl:text>&#9;&#9;&#9;&#9; </xsl:text>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000302 </xsl:if>
303 </xsl:for-each>
304 <xsl:text>)</xsl:text><br/>
305 <xsl:text>
306</xsl:text>
307 </pre>
308 <p>
309 <xsl:call-template name="dumptext">
310 <xsl:with-param name="text" select="info"/>
311 </xsl:call-template>
312 </p><xsl:text>
313</xsl:text>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000314 <xsl:if test="arg | return/@info">
315 <div class="variablelist"><table border="0"><col align="left"/><tbody>
316 <xsl:for-each select="arg">
317 <tr>
318 <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000319 <td>
320 <xsl:call-template name="dumptext">
321 <xsl:with-param name="text" select="@info"/>
322 </xsl:call-template>
323 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000324 </tr>
325 </xsl:for-each>
326 <xsl:if test="return/@info">
327 <tr>
328 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000329 <td>
330 <xsl:call-template name="dumptext">
331 <xsl:with-param name="text" select="return/@info"/>
332 </xsl:call-template>
333 </td>
Daniel Veillard0b3d9b82003-11-17 11:51:30 +0000334 </tr>
335 </xsl:if>
336 </tbody></table></div>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000337 </xsl:if>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000338 </xsl:template>
339
340 <xsl:template match="exports" mode="toc">
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000341 <xsl:apply-templates select="key('symbols', string(@symbol))[1]" mode="toc"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000342 </xsl:template>
343
344 <xsl:template match="exports">
Daniel Veillard2925c0a2003-11-17 13:58:17 +0000345 <xsl:apply-templates select="key('symbols', string(@symbol))[1]"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000346 </xsl:template>
347
348 <xsl:template match="file">
349 <xsl:variable name="name" select="@name"/>
350 <xsl:variable name="title">Module <xsl:value-of select="$name"/> from <xsl:value-of select="/api/@name"/></xsl:variable>
351 <xsl:document href="{$htmldir}/libxml-{$name}.html" method="xml" encoding="ISO-8859-1"
352 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
353 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
354 <html>
355 <head>
356 <xsl:call-template name="style"/>
357 <title><xsl:value-of select="$title"/></title>
358 </head>
359 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
360 <xsl:call-template name="titlebox">
361 <xsl:with-param name="title" select="$title"/>
362 </xsl:call-template>
363 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
364 <tr>
365 <td bgcolor="#8b7765">
366 <table border="0" cellspacing="0" cellpadding="2" width="100%">
367 <tr>
368 <td valign="top" width="200" bgcolor="#8b7765">
369 <xsl:call-template name="toc"/>
370 </td>
371 <td valign="top" bgcolor="#8b7765">
372 <table border="0" cellspacing="0" cellpadding="1" width="100%">
373 <tr>
374 <td>
375 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
376 <tr>
377 <td>
378 <table border="0" cellpadding="3" cellspacing="1" width="100%">
379 <tr>
380 <td bgcolor="#fffacd">
Daniel Veillardbff06bf2003-11-17 16:58:05 +0000381 <xsl:call-template name="navbar"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000382 <h2>Table of Contents</h2>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000383 <xsl:apply-templates select="exports" mode="toc"/>
Daniel Veillardc72f9fd2003-11-16 23:59:52 +0000384 <h2>Description</h2>
385 <xsl:text>
386</xsl:text>
387 <xsl:apply-templates select="exports"/>
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 </xsl:template>
408
409 <xsl:template match="file" mode="toc">
410 <xsl:variable name="name" select="@name"/>
411 <li> <a href="libxml-{$name}.html"><xsl:value-of select="$name"/></a></li>
412 </xsl:template>
413
414 <xsl:template match="/">
415 <xsl:variable name="title">Reference Manual for <xsl:value-of select="/api/@name"/></xsl:variable>
416 <xsl:document href="{$htmldir}/index.html" method="xml" encoding="ISO-8859-1"
417 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
418 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
419 <html>
420 <head>
421 <xsl:call-template name="style"/>
422 <title><xsl:value-of select="$title"/></title>
423 </head>
424 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
425 <xsl:call-template name="titlebox">
426 <xsl:with-param name="title" select="$title"/>
427 </xsl:call-template>
428 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
429 <tr>
430 <td bgcolor="#8b7765">
431 <table border="0" cellspacing="0" cellpadding="2" width="100%">
432 <tr>
433 <td valign="top" width="200" bgcolor="#8b7765">
434 <xsl:call-template name="toc"/>
435 </td>
436 <td valign="top" bgcolor="#8b7765">
437 <table border="0" cellspacing="0" cellpadding="1" width="100%">
438 <tr>
439 <td>
440 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
441 <tr>
442 <td>
443 <table border="0" cellpadding="3" cellspacing="1" width="100%">
444 <tr>
445 <td bgcolor="#fffacd">
446 <h2>Table of Contents</h2>
447 <ul>
448 <xsl:apply-templates select="/api/files/file" mode="toc"/>
449 </ul>
450 <p><a href="bugs.html">Daniel Veillard</a></p>
451 </td>
452 </tr>
453 </table>
454 </td>
455 </tr>
456 </table>
457 </td>
458 </tr>
459 </table>
460 </td>
461 </tr>
462 </table>
463 </td>
464 </tr>
465 </table>
466 </body>
467 </html>
468 </xsl:document>
469 <!-- now build the file for each of the modules -->
470 <xsl:apply-templates select="/api/files/file"/>
471 </xsl:template>
472
473</xsl:stylesheet>