rebuilt the generated HTML pages updated the stylesheets, added a

* doc/*.html: rebuilt the generated HTML pages
* doc/examples/*: updated the stylesheets, added a synopsis,
  Makefile.am is now generated by index.py
Daniel
diff --git a/doc/examples/.cvsignore b/doc/examples/.cvsignore
index 4c50877..0d6032c 100644
--- a/doc/examples/.cvsignore
+++ b/doc/examples/.cvsignore
@@ -1,4 +1,4 @@
 .memdump
 Makefile.in
 Makefile
-example1
+parse1
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 6615fe8..fdda972 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -1,16 +1,8 @@
-noinst_PROGRAMS=example1
-
+# Beware this is autogenerated by config.py
 INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
 DEPS = $(top_builddir)/libxml2.la
 LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
 
-EXTRA_DIST=examples.xml test1.xml
-
-example1_SOURCES=example1.c
-example1_LDFLAGS =
-example1_DEPENDENCIES = $(DEPS)
-example1_LDADD=  @RDL_LIBS@ $(LDADDS)
-
 all: examples.xml index.html
 
 examples.xml: index.py *.c
@@ -18,3 +10,13 @@
 
 index.html: examples.xml examples.xsl
 	-@(xsltproc examples.xsl examples.xml && echo "Rebuilt web page" && xmllint --valid --noout index.html)
+
+EXTRA_DIST=examples.xsl index.py test1.xml examples.xml 
+
+noinst_PROGRAMS=parse1 
+
+parse1_SOURCES=parse1.c
+parse1_LDFLAGS=
+parse1_DEPENDENCIES= $(DEPS)
+parse1_LDADD= @RDL_LIBS@ $(LDADDS)
+
diff --git a/doc/examples/examples.xml b/doc/examples/examples.xml
index d81f93c..e2df8b2 100644
--- a/doc/examples/examples.xml
+++ b/doc/examples/examples.xml
@@ -1,5 +1,6 @@
 <examples>
-  <example filename='example1.c'>
+  <example filename='parse1.c'>
+    <synopsis>Parse an XML file to a tree and free it</synopsis>
     <purpose>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
     <usage>example1 test1.xml</usage>
     <author>Daniel veillard</author>
@@ -10,33 +11,33 @@
       <include>&lt;libxml/parser.h&gt;</include>
     </includes>
     <uses>
-      <function line='48' file='parser' name='xmlCleanupParser'/>
-      <macro line='43' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='29' file='tree' name='xmlFreeDoc'/>
-      <function line='24' file='parser' name='xmlReadFile'/>
-      <typedef line='22' file='tree' name='xmlDocPtr'/>
+      <function line='49' file='parser' name='xmlCleanupParser'/>
+      <macro line='44' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='30' file='tree' name='xmlFreeDoc'/>
+      <function line='25' file='parser' name='xmlReadFile'/>
+      <typedef line='23' file='tree' name='xmlDocPtr'/>
     </uses>
   </example>
   <symbols>
     <symbol name='LIBXML_TEST_VERSION'>
-      <ref filename='example1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
     <symbol name='xmlCleanupParser'>
-      <ref filename='example1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
     <symbol name='xmlDocPtr'>
-      <ref filename='example1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
     <symbol name='xmlFreeDoc'>
-      <ref filename='example1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
     <symbol name='xmlReadFile'>
-      <ref filename='example1.c'/>
+      <ref filename='parse1.c'/>
     </symbol>
   </symbols>
   <sections>
     <section name='Parsing'>
-      <example filename='example1.c'/>
+      <example filename='parse1.c'/>
     </section>
   </sections>
 </examples>
diff --git a/doc/examples/examples.xsl b/doc/examples/examples.xsl
index 8b2453d..8b6b501 100644
--- a/doc/examples/examples.xsl
+++ b/doc/examples/examples.xsl
@@ -24,8 +24,9 @@
   </xsl:variable>
 
   <xsl:template match="include">
-    <!-- TODO improve with a link -->
-    <li><xsl:value-of select="."/></li>
+    <xsl:variable name="header" select="substring-before(substring-after(., '/'), '&gt;')"/>
+    <xsl:variable name="doc" select="concat('../html/libxml-', $header, 'tml')"/>
+    <li><a href="{$doc}"><xsl:value-of select="."/></a></li>
   </xsl:template>
 
   <xsl:template match="typedef">
@@ -51,7 +52,7 @@
 
   <xsl:template match="example">
     <xsl:variable name="filename" select="string(@filename)"/>
-    <h3><a name="{$filename}" href="{$filename}"><xsl:value-of select="$filename"/></a></h3>
+    <h3><a name="{$filename}" href="{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="synopsis"/></h3>
     <p><xsl:value-of select="purpose"/></p>
     <p>Includes:</p>
     <ul>
@@ -72,11 +73,12 @@
   </xsl:template>
 
   <xsl:template match="section">
-    <li><p> <xsl:value-of select="@name"/> :</p>
+    <li><p> <a href="#{@name}"><xsl:value-of select="@name"/></a> :</p>
     <ul>
     <xsl:for-each select="example">
       <xsl:sort select='.'/>
-      <li> <a href="#{@filename}"><xsl:value-of select="@filename"/></a></li>
+      <xsl:variable name="filename" select="@filename"/>
+      <li> <a href="#{$filename}"><xsl:value-of select="$filename"/></a>: <xsl:value-of select="/examples/example[@filename = $filename]/synopsis"/></li>
     </xsl:for-each>
     </ul>
     </li>
@@ -93,6 +95,14 @@
     </ul>
   </xsl:template>
 
+  <xsl:template name="sections-list">
+    <xsl:for-each select="sections/section">
+      <xsl:variable name="section" select="@name"/>
+      <h2> <a name="{$section}"></a><xsl:value-of select="$section"/> Examples</h2>
+      <xsl:apply-templates select='/examples/example[section = $section]'/>
+    </xsl:for-each>
+  </xsl:template>
+
   <xsl:template match="examples">
     <xsl:variable name="title">Libxml2 set of examples</xsl:variable>
      <xsl:document href="index.html" method="xml" encoding="ISO-8859-1"
@@ -128,7 +138,7 @@
                                     <tr>
                                       <td bgcolor="#fffacd">
 				        <xsl:apply-templates select="sections"/>
-				        <xsl:apply-templates select="example"/>
+					<xsl:call-template name="sections-list"/>
 					<p><a href="../bugs.html">Daniel Veillard</a></p>
                                       </td>
                                     </tr>
diff --git a/doc/examples/index.html b/doc/examples/index.html
index 0673611..14262cd 100644
--- a/doc/examples/index.html
+++ b/doc/examples/index.html
@@ -8,4 +8,4 @@
 H3 {font-family: Verdana,Arial,Helvetica}
 A:link, A:visited, A:active { text-decoration: underline }
 </style><title>Libxml2 set of examples</title></head><body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Libxml2 set of examples</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Main Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a href="../index.html">Home</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a href="../guidelines.html">XML Guidelines</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><p> The examples are stored per section depending on the main focus
-    of the example:</p><ul><li><p>Parsing :</p><ul><li><a href="#example1.c">example1.c</a></li></ul></li></ul><h3><a name="example1.c" href="example1.c" id="example1.c">example1.c</a></h3><p>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</p><p>Includes:</p><ul><li>&lt;libxml/tree.h&gt;</li><li>&lt;libxml/parser.h&gt;</li></ul><p>Uses:</p><ul><li> line 22: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 24: Function <a href="../html/libxml-parser.html#xmlReadFile">xmlReadFile</a> from parser.h</li><li> line 29: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 43: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 48: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>example1 test1.xml</p><p>Author: Daniel veillard</p><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
+    of the example:</p><ul><li><p><a href="#Parsing">Parsing</a> :</p><ul><li><a href="#parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</li></ul></li></ul><h2><a name="Parsing" id="Parsing"></a>Parsing Examples</h2><h3><a name="parse1.c" href="parse1.c" id="parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</h3><p>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html">&lt;libxml/tree.h&gt;</a></li><li><a href="../html/libxml-parser.html">&lt;libxml/parser.h&gt;</a></li></ul><p>Uses:</p><ul><li> line 23: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 25: Function <a href="../html/libxml-parser.html#xmlReadFile">xmlReadFile</a> from parser.h</li><li> line 30: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 44: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 49: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>example1 test1.xml</p><p>Author: Daniel veillard</p><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/examples/index.py b/doc/examples/index.py
index ad88276..cbf66a0 100755
--- a/doc/examples/index.py
+++ b/doc/examples/index.py
@@ -12,6 +12,8 @@
 sys.path.append("..")
 from apibuild import CParser, escape
 
+examples = []
+extras = ['examples.xsl', 'index.py']
 sections = {}
 symbols = {}
 api_dict = None
@@ -96,6 +98,11 @@
     info = parse_top_comment(filename, parser.top_comment)
     output.write("  <example filename='%s'>\n" % filename)
     try:
+        synopsis = info['synopsis']
+	output.write("    <synopsis>%s</synopsis>\n" % synopsis);
+    except:
+        print "Example %s lacks a synopsis description" % (filename)
+    try:
         purpose = info['purpose']
 	output.write("    <purpose>%s</purpose>\n" % purpose);
     except:
@@ -126,7 +133,8 @@
         print "Example %s lacks a section description" % (filename)
     for topic in info.keys():
         if topic != "purpose" and topic != "usage" and \
-	   topic != "author" and topic != "copy" and topic != "section":
+	   topic != "author" and topic != "copy" and \
+	   topic != "section" and topic != "synopsis":
 	    str = info[topic]
 	    output.write("    <extra topic='%s'>%s</extra>\n" % str)
     output.write("    <includes>\n")
@@ -197,6 +205,42 @@
         output.write("    </section>\n")
     output.write("  </sections>\n")
 
+def dump_Makefile():
+    for file in glob.glob('*.xml'):
+        extras.append(file)
+    Makefile="""# Beware this is autogenerated by config.py
+INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
+DEPS = $(top_builddir)/libxml2.la
+LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
+
+all: examples.xml index.html
+
+examples.xml: index.py *.c
+	-@($(srcdir)/index.py)
+
+index.html: examples.xml examples.xsl
+	-@(xsltproc examples.xsl examples.xml && echo "Rebuilt web page" && xmllint --valid --noout index.html)
+
+"""
+    EXTRA_DIST=""
+    for extra in extras:
+        EXTRA_DIST = EXTRA_DIST + extra + " "
+    Makefile = Makefile + "EXTRA_DIST=%s\n\n" % (EXTRA_DIST)
+    noinst_PROGRAMS=""
+    for example in examples:
+        noinst_PROGRAMS = noinst_PROGRAMS + example + " "
+    Makefile = Makefile + "noinst_PROGRAMS=%s\n\n" % (noinst_PROGRAMS)
+    for example in examples:
+        Makefile = Makefile + "%s_SOURCES=%s.c\n%s_LDFLAGS=\n%s_DEPENDENCIES= $(DEPS)\n%s_LDADD= @RDL_LIBS@ $(LDADDS)\n\n" % (example, example, example,
+	       example, example)
+    try:
+	old = open("Makefile.am", "r").read()
+	if old != Makefile:
+	    n = open("Makefile.am", "w").write(Makefile)
+	    print "Updated Makefile.am"
+    except:
+        print "Failed to read or save Makefile.am"
+    
 if __name__ == "__main__":
     load_api()
     output = open("examples.xml", "w")
@@ -204,9 +248,11 @@
 
     for file in glob.glob('*.c'):
 	parse(file, output)
+	examples.append(file[:-2])
 
     dump_symbols(output)
     dump_sections(output)
     output.write("</examples>\n")
     output.close()
+    dump_Makefile()
 
diff --git a/doc/examples/example1.c b/doc/examples/parse1.c
similarity index 95%
rename from doc/examples/example1.c
rename to doc/examples/parse1.c
index 42b2b4a..622d252 100644
--- a/doc/examples/example1.c
+++ b/doc/examples/parse1.c
@@ -1,5 +1,6 @@
 /**
  * section: Parsing
+ * synopsis: Parse an XML file to a tree and free it
  * purpose: Demonstrate the use of xmlReadFile() to read an XML file
  *          into a tree and and xmlFreeDoc() to free the resulting tree
  * usage: example1 test1.xml