Annotation of embedaddon/libxml2/doc/wiki.xsl, revision 1.1.1.1
1.1 misho 1: <?xml version="1.0"?>
2: <!--
3: Stylesheet to generate the HTML documentation from an XML API descriptions:
4: xsltproc wiki.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: xmlns:str="http://exslt.org/strings"
12: extension-element-prefixes="exsl str"
13: exclude-result-prefixes="exsl str">
14:
15: <!-- Generate XHTML-1.0 transitional -->
16: <xsl:output method="xml" encoding="UTF-8" indent="yes"
17: doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
18: doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
19:
20: <!-- Build keys for all symbols -->
21: <xsl:key name="symbols" match="/api/symbols/*" use="@name"/>
22:
23: <!-- the target directory for the HTML output -->
24: <xsl:variable name="htmldir">wiki</xsl:variable>
25: <xsl:variable name="href_base">../</xsl:variable>
26:
27: <xsl:template name="style">
28: <link rel="SHORTCUT ICON" href="/favicon.ico"/>
29: <style type="text/css">
30: TD {font-family: Verdana,Arial,Helvetica}
31: BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
32: H1 {font-family: Verdana,Arial,Helvetica}
33: H2 {font-family: Verdana,Arial,Helvetica}
34: H3 {font-family: Verdana,Arial,Helvetica}
35: A:link, A:visited, A:active { text-decoration: underline }
36: </style>
37: </xsl:template>
38:
39: <xsl:template name="docstyle">
40: <style type="text/css">
41: div.deprecated pre.programlisting {border-style: double;border-color:red}
42: pre.programlisting {border-style: double;}
43: </style>
44: </xsl:template>
45:
46: <!-- This is convoluted but needed to force the current document to
47: be the API one and not the result tree from the tokenize() result,
48: because the keys are only defined on the main document -->
49: <xsl:template mode="dumptoken" match='*'>
50: <xsl:param name="token"/>
51: <xsl:variable name="ref" select="key('symbols', $token)"/>
52: <xsl:choose>
53: <xsl:when test="$ref">
54: <a href="libxml-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
55: </xsl:when>
56: <xsl:otherwise>
57: <xsl:value-of select="$token"/>
58: </xsl:otherwise>
59: </xsl:choose>
60: </xsl:template>
61:
62: <!-- dumps a string, making cross-reference links -->
63: <xsl:template name="dumptext">
64: <xsl:param name="text"/>
65: <xsl:variable name="ctxt" select='.'/>
66: <!-- <xsl:value-of select="$text"/> -->
67: <xsl:for-each select="str:tokenize($text, ' 	')">
68: <xsl:apply-templates select="$ctxt" mode='dumptoken'>
69: <xsl:with-param name="token" select="string(.)"/>
70: </xsl:apply-templates>
71: <xsl:if test="position() != last()">
72: <xsl:text> </xsl:text>
73: </xsl:if>
74: </xsl:for-each>
75: </xsl:template>
76:
77: <xsl:template match="macro" mode="toc">
78: <pre class="programlisting">
79: <xsl:text>#define </xsl:text><a href="#{@name}"><xsl:value-of select="@name"/></a>
80: </pre>
81: </xsl:template>
82:
83: <xsl:template match="variable" mode="toc">
84: <pre class="programlisting">
85: <xsl:text>Variable </xsl:text>
86: <xsl:call-template name="dumptext">
87: <xsl:with-param name="text" select="string(@type)"/>
88: </xsl:call-template>
89: <xsl:text> </xsl:text>
90: <a name="{@name}"></a>
91: <xsl:value-of select="@name"/>
92: <xsl:text>
93:
94: </xsl:text>
95: </pre>
96: </xsl:template>
97:
98: <xsl:template match="typedef" mode="toc">
99: <xsl:variable name="name" select="string(@name)"/>
100: <pre class="programlisting">
101: <xsl:choose>
102: <xsl:when test="@type = 'enum'">
103: <xsl:text>Enum </xsl:text>
104: <a href="#{$name}"><xsl:value-of select="$name"/></a>
105: <xsl:text>
106: </xsl:text>
107: </xsl:when>
108: <xsl:otherwise>
109: <xsl:text>Typedef </xsl:text>
110: <xsl:call-template name="dumptext">
111: <xsl:with-param name="text" select="@type"/>
112: </xsl:call-template>
113: <xsl:text> </xsl:text>
114: <a name="{$name}"><xsl:value-of select="$name"/></a>
115: <xsl:text>
116: </xsl:text>
117: </xsl:otherwise>
118: </xsl:choose>
119: </pre>
120: </xsl:template>
121:
122: <xsl:template match="typedef[@type = 'enum']">
123: <xsl:variable name="name" select="string(@name)"/>
124: <h3>Enum <a name="{$name}"><xsl:value-of select="$name"/></a></h3>
125: <pre class="programlisting">
126: <xsl:text>Enum </xsl:text>
127: <xsl:value-of select="$name"/>
128: <xsl:text> {
129: </xsl:text>
130: <xsl:for-each select="/api/symbols/enum[@type = $name]">
131: <xsl:sort select="@value" data-type="number" order="ascending"/>
132: <xsl:text> </xsl:text>
133: <a name="{@name}"><xsl:value-of select="@name"/></a>
134: <xsl:text> = </xsl:text>
135: <xsl:value-of select="@value"/>
136: <xsl:if test="@info != ''">
137: <xsl:text> : </xsl:text>
138: <xsl:call-template name="dumptext">
139: <xsl:with-param name="text" select="@info"/>
140: </xsl:call-template>
141: </xsl:if>
142: <xsl:text>
143: </xsl:text>
144: </xsl:for-each>
145: <xsl:text>}
146: </xsl:text>
147: </pre>
148: </xsl:template>
149:
150: <xsl:template match="struct" mode="toc">
151: <pre class="programlisting">
152: <xsl:text>Structure </xsl:text><a href="#{@name}"><xsl:value-of select="@name"/></a><br/>
153: <xsl:value-of select="@type"/><xsl:text>
154: </xsl:text>
155: <xsl:if test="not(field)">
156: <xsl:text>The content of this structure is not made public by the API.
157: </xsl:text>
158: </xsl:if>
159: </pre>
160: </xsl:template>
161:
162: <xsl:template match="struct">
163: <h3><a name="{@name}">Structure <xsl:value-of select="@name"/></a></h3>
164: <pre class="programlisting">
165: <xsl:text>Structure </xsl:text><xsl:value-of select="@name"/><br/>
166: <xsl:value-of select="@type"/><xsl:text> {
167: </xsl:text>
168: <xsl:if test="not(field)">
169: <xsl:text>The content of this structure is not made public by the API.
170: </xsl:text>
171: </xsl:if>
172: <xsl:for-each select="field">
173: <xsl:text> </xsl:text>
174: <xsl:call-template name="dumptext">
175: <xsl:with-param name="text" select="@type"/>
176: </xsl:call-template>
177: <xsl:text>	</xsl:text>
178: <xsl:value-of select="@name"/>
179: <xsl:if test="@info != ''">
180: <xsl:text>	: </xsl:text>
181: <xsl:call-template name="dumptext">
182: <xsl:with-param name="text" select="substring(@info, 1, 40)"/>
183: </xsl:call-template>
184: </xsl:if>
185: <xsl:text>
186: </xsl:text>
187: </xsl:for-each>
188: <xsl:text>}</xsl:text>
189: </pre>
190: </xsl:template>
191:
192: <xsl:template match="macro">
193: <xsl:variable name="name" select="string(@name)"/>
194: <h3><a name="{$name}"></a>Macro: <xsl:value-of select="$name"/></h3>
195: <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
196: <p>
197: <xsl:call-template name="dumptext">
198: <xsl:with-param name="text" select="info"/>
199: </xsl:call-template>
200: </p><xsl:text>
201: </xsl:text>
202: </xsl:template>
203:
204: <xsl:template match="function" mode="toc">
205: <xsl:variable name="name" select="string(@name)"/>
206: <xsl:variable name="nlen" select="string-length($name)"/>
207: <xsl:variable name="tlen" select="string-length(return/@type)"/>
208: <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
209: <pre class="programlisting">
210: <xsl:call-template name="dumptext">
211: <xsl:with-param name="text" select="return/@type"/>
212: </xsl:call-template>
213: <xsl:text>	</xsl:text>
214: <a href="#{@name}"><xsl:value-of select="@name"/></a>
215: <xsl:if test="$blen - 40 < -8">
216: <xsl:text>	</xsl:text>
217: </xsl:if>
218: <xsl:if test="$blen - 40 < 0">
219: <xsl:text>	</xsl:text>
220: </xsl:if>
221: <xsl:text>	(</xsl:text>
222: <xsl:if test="not(arg)">
223: <xsl:text>void</xsl:text>
224: </xsl:if>
225: <xsl:for-each select="arg">
226: <xsl:call-template name="dumptext">
227: <xsl:with-param name="text" select="@type"/>
228: </xsl:call-template>
229: <xsl:text> </xsl:text>
230: <xsl:value-of select="@name"/>
231: <xsl:if test="position() != last()">
232: <xsl:text>, </xsl:text><br/>
233: <xsl:if test="$blen - 40 > 8">
234: <xsl:text>	</xsl:text>
235: </xsl:if>
236: <xsl:if test="$blen - 40 > 0">
237: <xsl:text>	</xsl:text>
238: </xsl:if>
239: <xsl:text>					 </xsl:text>
240: </xsl:if>
241: </xsl:for-each>
242: <xsl:text>)</xsl:text>
243: </pre><xsl:text>
244: </xsl:text>
245: </xsl:template>
246:
247: <xsl:template match="functype" mode="toc">
248: <xsl:variable name="name" select="string(@name)"/>
249: <xsl:variable name="nlen" select="string-length($name)"/>
250: <xsl:variable name="tlen" select="string-length(return/@type)"/>
251: <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
252: <pre class="programlisting">
253: <xsl:text>Function type: </xsl:text>
254: <a href="#{$name}"><xsl:value-of select="$name"/></a>
255: <xsl:text>
256: </xsl:text>
257: <xsl:call-template name="dumptext">
258: <xsl:with-param name="text" select="return/@type"/>
259: </xsl:call-template>
260: <xsl:text>	</xsl:text>
261: <a href="#{$name}"><xsl:value-of select="$name"/></a>
262: <xsl:if test="$blen - 40 < -8">
263: <xsl:text>	</xsl:text>
264: </xsl:if>
265: <xsl:if test="$blen - 40 < 0">
266: <xsl:text>	</xsl:text>
267: </xsl:if>
268: <xsl:text>	(</xsl:text>
269: <xsl:if test="not(arg)">
270: <xsl:text>void</xsl:text>
271: </xsl:if>
272: <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()">
279: <xsl:text>, </xsl:text><br/>
280: <xsl:if test="$blen - 40 > 8">
281: <xsl:text>	</xsl:text>
282: </xsl:if>
283: <xsl:if test="$blen - 40 > 0">
284: <xsl:text>	</xsl:text>
285: </xsl:if>
286: <xsl:text>					 </xsl:text>
287: </xsl:if>
288: </xsl:for-each>
289: <xsl:text>)
290: </xsl:text>
291: </pre>
292: <xsl:text>
293: </xsl:text>
294: </xsl:template>
295:
296: <xsl:template match="functype">
297: <xsl:variable name="name" select="string(@name)"/>
298: <xsl:variable name="nlen" select="string-length($name)"/>
299: <xsl:variable name="tlen" select="string-length(return/@type)"/>
300: <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
301: <h3>
302: <a name="{$name}"></a>
303: <xsl:text>Function type: </xsl:text>
304: <xsl:value-of select="$name"/>
305: </h3>
306: <pre class="programlisting">
307: <xsl:text>Function type: </xsl:text>
308: <xsl:value-of select="$name"/>
309: <xsl:text>
310: </xsl:text>
311: <xsl:call-template name="dumptext">
312: <xsl:with-param name="text" select="return/@type"/>
313: </xsl:call-template>
314: <xsl:text>	</xsl:text>
315: <xsl:value-of select="@name"/>
316: <xsl:if test="$blen - 40 < -8">
317: <xsl:text>	</xsl:text>
318: </xsl:if>
319: <xsl:if test="$blen - 40 < 0">
320: <xsl:text>	</xsl:text>
321: </xsl:if>
322: <xsl:text>	(</xsl:text>
323: <xsl:if test="not(arg)">
324: <xsl:text>void</xsl:text>
325: </xsl:if>
326: <xsl:for-each select="arg">
327: <xsl:call-template name="dumptext">
328: <xsl:with-param name="text" select="@type"/>
329: </xsl:call-template>
330: <xsl:text> </xsl:text>
331: <xsl:value-of select="@name"/>
332: <xsl:if test="position() != last()">
333: <xsl:text>, </xsl:text><br/>
334: <xsl:if test="$blen - 40 > 8">
335: <xsl:text>	</xsl:text>
336: </xsl:if>
337: <xsl:if test="$blen - 40 > 0">
338: <xsl:text>	</xsl:text>
339: </xsl:if>
340: <xsl:text>					 </xsl:text>
341: </xsl:if>
342: </xsl:for-each>
343: <xsl:text>)
344: </xsl:text>
345: </pre>
346: <p>
347: <xsl:call-template name="dumptext">
348: <xsl:with-param name="text" select="info"/>
349: </xsl:call-template>
350: </p>
351: <xsl:if test="arg | return">
352: <div class="variablelist"><table border="0"><col align="left"/><tbody>
353: <xsl:for-each select="arg">
354: <tr>
355: <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
356: <td>
357: <xsl:call-template name="dumptext">
358: <xsl:with-param name="text" select="@info"/>
359: </xsl:call-template>
360: </td>
361: </tr>
362: </xsl:for-each>
363: <xsl:if test="return/@info">
364: <tr>
365: <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
366: <td>
367: <xsl:call-template name="dumptext">
368: <xsl:with-param name="text" select="return/@info"/>
369: </xsl:call-template>
370: </td>
371: </tr>
372: </xsl:if>
373: </tbody></table></div>
374: </xsl:if>
375: <br/>
376: <xsl:text>
377: </xsl:text>
378: </xsl:template>
379:
380: <xsl:template match="function">
381: <xsl:variable name="name" select="string(@name)"/>
382: <xsl:variable name="nlen" select="string-length($name)"/>
383: <xsl:variable name="tlen" select="string-length(return/@type)"/>
384: <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
385: <h3><a name="{$name}"></a>Function: <xsl:value-of select="$name"/></h3>
386: <pre class="programlisting">
387: <xsl:call-template name="dumptext">
388: <xsl:with-param name="text" select="return/@type"/>
389: </xsl:call-template>
390: <xsl:text>	</xsl:text>
391: <xsl:value-of select="@name"/>
392: <xsl:if test="$blen - 40 < -8">
393: <xsl:text>	</xsl:text>
394: </xsl:if>
395: <xsl:if test="$blen - 40 < 0">
396: <xsl:text>	</xsl:text>
397: </xsl:if>
398: <xsl:text>	(</xsl:text>
399: <xsl:if test="not(arg)">
400: <xsl:text>void</xsl:text>
401: </xsl:if>
402: <xsl:for-each select="arg">
403: <xsl:call-template name="dumptext">
404: <xsl:with-param name="text" select="@type"/>
405: </xsl:call-template>
406: <xsl:text> </xsl:text>
407: <xsl:value-of select="@name"/>
408: <xsl:if test="position() != last()">
409: <xsl:text>, </xsl:text><br/>
410: <xsl:if test="$blen - 40 > 8">
411: <xsl:text>	</xsl:text>
412: </xsl:if>
413: <xsl:if test="$blen - 40 > 0">
414: <xsl:text>	</xsl:text>
415: </xsl:if>
416: <xsl:text>					 </xsl:text>
417: </xsl:if>
418: </xsl:for-each>
419: <xsl:text>)</xsl:text><br/>
420: <xsl:text>
421: </xsl:text>
422: </pre>
423: <p>
424: <xsl:call-template name="dumptext">
425: <xsl:with-param name="text" select="info"/>
426: </xsl:call-template>
427: </p><xsl:text>
428: </xsl:text>
429: <xsl:if test="arg | return/@info">
430: <div class="variablelist"><table border="0"><col align="left"/><tbody>
431: <xsl:for-each select="arg">
432: <tr>
433: <td><span class="term"><i><tt><xsl:value-of select="@name"/></tt></i>:</span></td>
434: <td>
435: <xsl:call-template name="dumptext">
436: <xsl:with-param name="text" select="@info"/>
437: </xsl:call-template>
438: </td>
439: </tr>
440: </xsl:for-each>
441: <xsl:if test="return/@info">
442: <tr>
443: <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
444: <td>
445: <xsl:call-template name="dumptext">
446: <xsl:with-param name="text" select="return/@info"/>
447: </xsl:call-template>
448: </td>
449: </tr>
450: </xsl:if>
451: </tbody></table></div>
452: </xsl:if>
453: </xsl:template>
454:
455: <xsl:template match="exports" mode="toc">
456: <xsl:apply-templates select="key('symbols', string(@symbol))[1]" mode="toc"/>
457: </xsl:template>
458:
459: <xsl:template match="exports">
460: <xsl:apply-templates select="key('symbols', string(@symbol))[1]"/>
461: </xsl:template>
462:
463: <xsl:template name="description">
464: <xsl:if test="deprecated">
465: <h2 style="font-weight:bold;color:red;text-align:center">This module is deprecated</h2>
466: </xsl:if>
467: <xsl:if test="description">
468: <p><xsl:value-of select="description"/></p>
469: </xsl:if>
470: </xsl:template>
471:
472: <xsl:template name="docomponents">
473: <xsl:param name="mode"/>
474: <xsl:apply-templates select="exports[@type='macro']" mode="$mode">
475: <xsl:sort select='@symbol'/>
476: </xsl:apply-templates>
477: <xsl:apply-templates select="exports[@type='enum']" mode="$mode">
478: <xsl:sort select='@symbol'/>
479: </xsl:apply-templates>
480: <xsl:apply-templates select="exports[@type='typedef']" mode="$mode">
481: <xsl:sort select='@symbol'/>
482: </xsl:apply-templates>
483: <xsl:apply-templates select="exports[@type='struct']" mode="$mode">
484: <xsl:sort select='@symbol'/>
485: </xsl:apply-templates>
486: <xsl:apply-templates select="exports[@type='function']" mode="$mode">
487: <xsl:sort select='@symbol'/>
488: </xsl:apply-templates>
489: </xsl:template>
490:
491: <xsl:template match="file">
492: <xsl:variable name="name" select="@name"/>
493: <xsl:variable name="title">Module <xsl:value-of select="$name"/> from <xsl:value-of select="/api/@name"/></xsl:variable>
494: <xsl:document href="{$htmldir}/libxml-{$name}.html" method="xml" encoding="UTF-8"
495: doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
496: doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
497: <xsl:call-template name="style"/>
498: <xsl:call-template name="docstyle"/>
499: <table border="0" cellpadding="3" cellspacing="1" width="100%">
500: <tr>
501: <td>
502: <xsl:call-template name="description"/>
503: <xsl:choose>
504: <xsl:when test="deprecated">
505: <div class="deprecated">
506: <h2>Table of Contents</h2>
507: <xsl:apply-templates select="exports" mode="toc"/>
508: <h2>Description</h2>
509: <xsl:text>
510: </xsl:text>
511: <xsl:apply-templates select="exports"/>
512: </div>
513: </xsl:when>
514: <xsl:otherwise>
515: <h2>Table of Contents</h2>
516: <xsl:apply-templates select="exports[@type='macro']" mode="toc">
517: <xsl:sort select='@symbol'/>
518: </xsl:apply-templates>
519: <xsl:apply-templates select="exports[@type='enum']" mode="toc">
520: <xsl:sort select='@symbol'/>
521: </xsl:apply-templates>
522: <xsl:apply-templates select="exports[@type='typedef']" mode="toc">
523: <xsl:sort select='@symbol'/>
524: </xsl:apply-templates>
525: <xsl:apply-templates select="exports[@type='struct']" mode="toc">
526: <xsl:sort select='@symbol'/>
527: </xsl:apply-templates>
528: <xsl:apply-templates select="exports[@type='function']" mode="toc">
529: <xsl:sort select='@symbol'/>
530: </xsl:apply-templates>
531: <h2>Description</h2>
532: <xsl:text>
533: </xsl:text>
534: <xsl:apply-templates select="exports[@type='macro']">
535: <xsl:sort select='@symbol'/>
536: </xsl:apply-templates>
537: <xsl:apply-templates select="exports[@type='enum']">
538: <xsl:sort select='@symbol'/>
539: </xsl:apply-templates>
540: <xsl:apply-templates select="exports[@type='typedef']">
541: <xsl:sort select='@symbol'/>
542: </xsl:apply-templates>
543: <xsl:apply-templates select="exports[@type='struct']">
544: <xsl:sort select='@symbol'/>
545: </xsl:apply-templates>
546: <xsl:apply-templates select="exports[@type='function']">
547: <xsl:sort select='@symbol'/>
548: </xsl:apply-templates>
549: </xsl:otherwise>
550: </xsl:choose>
551: </td>
552: </tr>
553: </table>
554: </xsl:document>
555: </xsl:template>
556:
557: <xsl:template match="file" mode="toc">
558: <xsl:variable name="name" select="@name"/>
559: <b><a href="http://xmlsoft.org/wiki/index.php?title=Libxml2:Api:{$name}"><xsl:value-of select="$name"/></a></b><br/>
560: <xsl:value-of select="summary"/>
561: <br/><br/>
562: </xsl:template>
563:
564: <xsl:template name="mainpage">
565: <xsl:param name="file" select="concat($htmldir, '/libxml-index.html')"/>
566: <xsl:variable name="title">Reference Manual for <xsl:value-of select="/api/@name"/></xsl:variable>
567: <xsl:document href="{$file}" method="xml" encoding="UTF-8"
568: doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
569: doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
570: <xsl:call-template name="style"/>
571: <xsl:call-template name="docstyle"/>
572: <table border="0" cellpadding="3" cellspacing="1" width="100%">
573: <tr>
574: <td>
575: <xsl:apply-templates select="/api/files/file" mode="toc"/>
576: </td>
577: </tr>
578: </table>
579: </xsl:document>
580: </xsl:template>
581:
582: <xsl:template match="/">
583: <!-- Save the main libxml-index.html as well as a couple of copies -->
584: <xsl:call-template name="mainpage"/>
585: <!-- now build the file for each of the modules -->
586: <xsl:apply-templates select="/api/files/file"/>
587: </xsl:template>
588:
589: </xsl:stylesheet>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>