examples.xsl 7.1 KB

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