1<?xml version="1.0"?> 2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 3 4 <xsl:variable name="apidoc-prefix">https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-</xsl:variable> 5 6 <xsl:template match="include"> 7 <xsl:variable name="header" select="substring-before(substring-after(., '/'), '>')"/> 8 <xsl:variable name="doc" select="concat($apidoc-prefix, $header, 'tml')"/> 9 <li><a href="{$doc}"><xsl:value-of select="."/></a></li> 10 </xsl:template> 11 12 <xsl:template match="typedef"> 13 <xsl:variable name="name" select="@name"/> 14 <xsl:variable name="header" select="concat(@file, '.h')"/> 15 <xsl:variable name="doc" select="concat($apidoc-prefix, @file, '.html#', $name)"/> 16 <li> line <xsl:value-of select="@line"/>: Type <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li> 17 </xsl:template> 18 19 <xsl:template match="function"> 20 <xsl:variable name="name" select="@name"/> 21 <xsl:variable name="header" select="concat(@file, '.h')"/> 22 <xsl:variable name="doc" select="concat($apidoc-prefix, @file, '.html#', $name)"/> 23 <li> line <xsl:value-of select="@line"/>: Function <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li> 24 </xsl:template> 25 26 <xsl:template match="macro"> 27 <xsl:variable name="name" select="@name"/> 28 <xsl:variable name="header" select="concat(@file, '.h')"/> 29 <xsl:variable name="doc" select="concat($apidoc-prefix, @file, '.html#', $name)"/> 30 <li> line <xsl:value-of select="@line"/>: Macro <a href="{$doc}"><xsl:value-of select="$name"/></a> from <xsl:value-of select="$header"/></li> 31 </xsl:template> 32 33 <xsl:template match="example"> 34 <xsl:variable name="filename" select="string(@filename)"/> 35 <h3><a name="{$filename}" href="{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="synopsis"/></h3> 36 <p><xsl:value-of select="purpose"/></p> 37 <p>Includes:</p> 38 <ul> 39 <xsl:for-each select="includes/include"> 40 <xsl:sort select="@line" data-type="number"/> 41 <xsl:apply-templates select='.'/> 42 </xsl:for-each> 43 </ul> 44 <p>Uses:</p> 45 <ul> 46 <xsl:for-each select="uses/*"> 47 <xsl:sort select="@line" data-type="number"/> 48 <xsl:apply-templates select='.'/> 49 </xsl:for-each> 50 </ul> 51 <p>Usage:</p> 52 <p><xsl:value-of select="usage"/></p> 53 <p>Author: <xsl:value-of select="author"/></p> 54 </xsl:template> 55 56 <xsl:template match="section"> 57 <li><p> <a href="#{@name}"><xsl:value-of select="@name"/></a> :</p> 58 <ul> 59 <xsl:for-each select="example"> 60 <xsl:sort select='.'/> 61 <xsl:variable name="filename" select="@filename"/> 62 <li> <a href="#{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="/examples/example[@filename = $filename]/synopsis"/></li> 63 </xsl:for-each> 64 </ul> 65 </li> 66 </xsl:template> 67 68 <xsl:template match="sections"> 69 <p> The examples are stored per section depending on the main focus 70 of the example:</p> 71 <ul> 72 <xsl:for-each select="section"> 73 <xsl:sort select='.'/> 74 <xsl:apply-templates select='.'/> 75 </xsl:for-each> 76 </ul> 77 <p> Getting the compilation options and libraries dependencies needed 78to generate binaries from the examples is best done on Linux/Unix by using 79the xml2-config script which should have been installed as part of <i>make 80install</i> step or when installing the libxml2 development package:</p> 81<pre>gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`</pre> 82 </xsl:template> 83 84 <xsl:template name="sections-list"> 85 <xsl:for-each select="sections/section"> 86 <xsl:variable name="section" select="@name"/> 87 <h2> <a name="{$section}"></a><xsl:value-of select="$section"/> Examples</h2> 88 <xsl:apply-templates select='/examples/example[section = $section]'/> 89 </xsl:for-each> 90 </xsl:template> 91 92 <xsl:template match="examples"> 93 <xsl:variable name="title">Libxml2 set of examples</xsl:variable> 94 <xsl:document href="index.html" method="xml" indent="yes" omit-xml-declaration="yes" 95 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 96 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 97 <html> 98 <head> 99 <title> 100 <xsl:value-of select="$title"/> 101 </title> 102 </head> 103 <body> 104 <h1><xsl:value-of select="$title"/></h1> 105 <xsl:apply-templates select="sections"/> 106 <xsl:call-template name="sections-list"/> 107 </body> 108 </html> 109 </xsl:document> 110 </xsl:template> 111 112</xsl:stylesheet> 113