examples.xsl revision e8ba84ef7e8ce95a9e12517402f2b8c99792e407
1<?xml version="1.0"?>
2<xsl:stylesheet version="1.0"
3  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4  xmlns:exsl="http://exslt.org/common"
5  extension-element-prefixes="exsl"
6  exclude-result-prefixes="exsl">
7
8  <xsl:import href="/site.xsl"/>
9
10  <xsl:variable name="href_base">../</xsl:variable>
11  <xsl:variable name="menu_name">Examples Menu</xsl:variable>
12
13  <xsl:variable name="toc">
14    <form action="/search.php"
15          enctype="application/x-www-form-urlencoded" method="get">
16      <input name="query" type="text" size="20" value=""/>
17      <input name="submit" type="submit" value="Search ..."/>
18    </form>
19    <ul><!-- style="margin-left: -1em" -->
20      <li><a href="{$href_base}index.html">Home</a></li>
21      <li><a style="font-weight:bold" 
22             href="{$href_base}docs.html">Developer Menu</a></li>
23      <li><a style="font-weight:bold" 
24             href="{$href_base}html/index.html">API Menu</a></li>
25      <xsl:for-each select="/examples/sections/section">
26        <li><a href="#{@name}"><xsl:value-of select="@name"/> Examples</a></li>
27      </xsl:for-each>
28      <li><a href="{$href_base}guidelines.html">XML Guidelines</a></li>
29    </ul>
30  </xsl:variable>
31
32  <xsl:template match="include">
33    <xsl:variable name="header" select="substring-before(substring-after(., '/'), '&gt;')"/>
34    <xsl:variable name="doc" select="concat('/html/libxml-', $header, 'tml')"/>
35    <li><a href="{$doc}"><xsl:value-of select="."/></a></li>
36  </xsl:template>
37
38  <xsl:template match="typedef">
39    <xsl:variable name="name" select="@name"/>
40    <xsl:variable name="header" select="concat(@file, '.h')"/>
41    <xsl:variable name="doc" select="concat('/html/libxml-', @file, '.html#', $name)"/>
42    <li> line <xsl:value-of select="@line"/>: Type <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li>
43  </xsl:template>
44
45  <xsl:template match="function">
46    <xsl:variable name="name" select="@name"/>
47    <xsl:variable name="header" select="concat(@file, '.h')"/>
48    <xsl:variable name="doc" select="concat('/html/libxml-', @file, '.html#', $name)"/>
49    <li> line <xsl:value-of select="@line"/>: Function <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li>
50  </xsl:template>
51
52  <xsl:template match="macro">
53    <xsl:variable name="name" select="@name"/>
54    <xsl:variable name="header" select="concat(@file, '.h')"/>
55    <xsl:variable name="doc" select="concat('/html/libxml-', @file, '.html#', $name)"/>
56    <li> line <xsl:value-of select="@line"/>: Macro <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li>
57  </xsl:template>
58
59  <xsl:template match="example">
60    <xsl:variable name="filename" select="string(@filename)"/>
61    <h3><a name="{$filename}" href="{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="synopsis"/></h3>
62    <p><xsl:value-of select="purpose"/></p>
63    <p>Includes:</p>
64    <ul>
65    <xsl:for-each select="includes/include">
66      <xsl:apply-templates select='.'/>
67    </xsl:for-each>
68    </ul>
69    <p>Uses:</p>
70    <ul>
71    <xsl:for-each select="uses/*">
72      <xsl:sort select="@line" data-type="number"/>
73      <xsl:apply-templates select='.'/>
74    </xsl:for-each>
75    </ul>
76    <p>Usage:</p>
77    <p><xsl:value-of select="usage"/></p>
78    <p>Author: <xsl:value-of select="author"/></p>
79  </xsl:template>
80
81  <xsl:template match="section">
82    <li><p> <a href="#{@name}"><xsl:value-of select="@name"/></a> :</p>
83    <ul>
84    <xsl:for-each select="example">
85      <xsl:sort select='.'/>
86      <xsl:variable name="filename" select="@filename"/>
87      <li> <a href="#{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="/examples/example[@filename = $filename]/synopsis"/></li>
88    </xsl:for-each>
89    </ul>
90    </li>
91  </xsl:template>
92
93  <xsl:template match="sections">
94    <p> The examples are stored per section depending on the main focus
95    of the example:</p>
96    <ul>
97    <xsl:for-each select="section">
98      <xsl:sort select='.'/>
99      <xsl:apply-templates select='.'/>
100    </xsl:for-each>
101    </ul>
102  </xsl:template>
103
104  <xsl:template name="sections-list">
105    <xsl:for-each select="sections/section">
106      <xsl:variable name="section" select="@name"/>
107      <h2> <a name="{$section}"></a><xsl:value-of select="$section"/> Examples</h2>
108      <xsl:apply-templates select='/examples/example[section = $section]'/>
109    </xsl:for-each>
110  </xsl:template>
111
112  <xsl:template match="examples">
113    <xsl:variable name="title">Libxml2 set of examples</xsl:variable>
114     <xsl:document href="index.html" method="xml" encoding="ISO-8859-1"
115         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
116     doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
117      <html>
118        <head>
119        <xsl:call-template name="style"/>
120	<xsl:element name="title">
121	  <xsl:value-of select="$title"/>
122	</xsl:element>
123        </head>
124        <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
125          <xsl:call-template name="titlebox">
126	    <xsl:with-param name="title" select="$title"/>
127	  </xsl:call-template>
128          <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
129            <tr>
130              <td bgcolor="#8b7765">
131                <table border="0" cellspacing="0" cellpadding="2" width="100%">
132                  <tr>
133                    <td valign="top" width="200" bgcolor="#8b7765">
134                      <xsl:call-template name="toc"/>
135                    </td>
136                    <td valign="top" bgcolor="#8b7765">
137                      <table border="0" cellspacing="0" cellpadding="1" width="100%">
138                        <tr>
139                          <td>
140                            <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
141                              <tr>
142                                <td>
143                                  <table border="0" cellpadding="3" cellspacing="1" width="100%">
144                                    <tr>
145                                      <td bgcolor="#fffacd">
146				        <xsl:apply-templates select="sections"/>
147					<xsl:call-template name="sections-list"/>
148					<p><a href="/bugs.html">Daniel Veillard</a></p>
149                                      </td>
150                                    </tr>
151                                  </table>
152                                </td>
153                              </tr>
154                            </table>
155                          </td>
156                        </tr>
157                      </table>
158                    </td>
159                  </tr>
160                </table>
161              </td>
162            </tr>
163          </table>
164        </body>
165      </html>
166    </xsl:document>
167  </xsl:template>
168
169</xsl:stylesheet>
170