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(., '/'), '>')"/> 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 <p> Getting the compilation options and libraries dependencies needed 103to generate binaries from the examples is best done on Linux/Unix by using 104the xml2-config script which should have been installed as part of <i>make 105install</i> step or when installing the libxml2 development package:</p> 106<pre>gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`</pre> 107 </xsl:template> 108 109 <xsl:template name="sections-list"> 110 <xsl:for-each select="sections/section"> 111 <xsl:variable name="section" select="@name"/> 112 <h2> <a name="{$section}"></a><xsl:value-of select="$section"/> Examples</h2> 113 <xsl:apply-templates select='/examples/example[section = $section]'/> 114 </xsl:for-each> 115 </xsl:template> 116 117 <xsl:template match="examples"> 118 <xsl:variable name="title">Libxml2 set of examples</xsl:variable> 119 <xsl:document href="index.html" method="xml" encoding="ISO-8859-1" 120 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 121 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 122 <html> 123 <head> 124 <xsl:call-template name="style"/> 125 <xsl:element name="title"> 126 <xsl:value-of select="$title"/> 127 </xsl:element> 128 </head> 129 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"> 130 <xsl:call-template name="titlebox"> 131 <xsl:with-param name="title" select="$title"/> 132 </xsl:call-template> 133 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"> 134 <tr> 135 <td bgcolor="#8b7765"> 136 <table border="0" cellspacing="0" cellpadding="2" width="100%"> 137 <tr> 138 <td valign="top" width="200" bgcolor="#8b7765"> 139 <xsl:call-template name="toc"/> 140 </td> 141 <td valign="top" bgcolor="#8b7765"> 142 <table border="0" cellspacing="0" cellpadding="1" width="100%"> 143 <tr> 144 <td> 145 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"> 146 <tr> 147 <td> 148 <table border="0" cellpadding="3" cellspacing="1" width="100%"> 149 <tr> 150 <td bgcolor="#fffacd"> 151 <xsl:apply-templates select="sections"/> 152 <xsl:call-template name="sections-list"/> 153 <p><a href="../bugs.html">Daniel Veillard</a></p> 154 </td> 155 </tr> 156 </table> 157 </td> 158 </tr> 159 </table> 160 </td> 161 </tr> 162 </table> 163 </td> 164 </tr> 165 </table> 166 </td> 167 </tr> 168 </table> 169 </body> 170 </html> 171 </xsl:document> 172 </xsl:template> 173 174</xsl:stylesheet> 175