diff --git a/doc/examples/examples.xsl b/doc/examples/examples.xsl
index 103023dbe40bfadf62e4a3c153dc1511ca27dd0d_ZG9jL2V4YW1wbGVzL2V4YW1wbGVzLnhzbA==..26176bd5bb025822fd72b764b8364203e15d04cc_ZG9jL2V4YW1wbGVzL2V4YW1wbGVzLnhzbA== 100644
--- a/doc/examples/examples.xsl
+++ b/doc/examples/examples.xsl
@@ -37,6 +37,7 @@
     <p>Includes:</p>
     <ul>
     <xsl:for-each select="includes/include">
+      <xsl:sort select="@line" data-type="number"/>
       <xsl:apply-templates select='.'/>
     </xsl:for-each>
     </ul>
diff --git a/doc/examples/index.py b/doc/examples/index.py
index 103023dbe40bfadf62e4a3c153dc1511ca27dd0d_ZG9jL2V4YW1wbGVzL2luZGV4LnB5..26176bd5bb025822fd72b764b8364203e15d04cc_ZG9jL2V4YW1wbGVzL2luZGV4LnB5 100755
--- a/doc/examples/index.py
+++ b/doc/examples/index.py
@@ -2,9 +2,8 @@
 #
 # Indexes the examples and build an XML description
 #
-import string
 import glob
 import sys
 try:
     import libxml2
 except:
@@ -6,8 +5,9 @@
 import glob
 import sys
 try:
     import libxml2
 except:
+    print("libxml2 python bindings not available")
     sys.exit(1)
 sys.path.insert(0, "..")
 from apibuild import CParser, escape
@@ -28,6 +28,6 @@
         return
     api_dict = {}
     try:
-        print "loading ../libxml2-api.xml"
+        print("loading ../libxml2-api.xml")
         api_doc = libxml2.parseFile("../libxml2-api.xml")
     except:
@@ -32,7 +32,7 @@
         api_doc = libxml2.parseFile("../libxml2-api.xml")
     except:
-        print "failed to parse ../libxml2-api.xml"
-	sys.exit(1)
+        print("failed to parse ../libxml2-api.xml")
+        sys.exit(1)
 
 def find_symbol(name):
     global api_dict
@@ -43,9 +43,9 @@
 
     if name == None:
         return
-    if api_dict.has_key(name):
+    if name in api_dict:
         return api_dict[name]
     ctxt = api_doc.xpathNewContext()
     res = ctxt.xpathEval("/api/symbols/*[@name = '%s']" % (name))
     if type(res) == type([]) and len(res) >= 1:
         if len(res) > 1:
@@ -47,11 +47,11 @@
         return api_dict[name]
     ctxt = api_doc.xpathNewContext()
     res = ctxt.xpathEval("/api/symbols/*[@name = '%s']" % (name))
     if type(res) == type([]) and len(res) >= 1:
         if len(res) > 1:
-	    print "Found %d references to %s in the API" % (len(res), name)
-	node = res[0]
-	typ = node.name
-	file = node.xpathEval("string(@file)")
-	info = node.xpathEval("string(info)")
+            print("Found %d references to %s in the API" % (len(res), name))
+        node = res[0]
+        typ = node.name
+        file = node.xpathEval("string(@file)")
+        info = node.xpathEval("string(info)")
     else:
@@ -57,9 +57,9 @@
     else:
-        print "Reference %s not found in the API" % (name)
-	return None
+        print("Reference %s not found in the API" % (name))
+        return None
     ret = (typ, file, info)
     api_dict[name] = ret
     return ret
 
 def parse_top_comment(filename, comment):
     res = {}
@@ -60,10 +60,10 @@
     ret = (typ, file, info)
     api_dict[name] = ret
     return ret
 
 def parse_top_comment(filename, comment):
     res = {}
-    lines = string.split(comment, "\n")
+    lines = comment.split("\n")
     item = None
     for line in lines:
         while line != "" and (line[0] == ' ' or line[0] == '\t'):
@@ -67,5 +67,5 @@
     item = None
     for line in lines:
         while line != "" and (line[0] == ' ' or line[0] == '\t'):
-	    line = line[1:]
+            line = line[1:]
         while line != "" and line[0] == '*':
@@ -71,3 +71,3 @@
         while line != "" and line[0] == '*':
-	    line = line[1:]
+            line = line[1:]
         while line != "" and (line[0] == ' ' or line[0] == '\t'):
@@ -73,20 +73,20 @@
         while line != "" and (line[0] == ' ' or line[0] == '\t'):
-	    line = line[1:]
-	try:
-	    (it, line) = string.split(line, ":", 1)
-	    item = it
-	    while line != "" and (line[0] == ' ' or line[0] == '\t'):
-		line = line[1:]
-	    if res.has_key(item):
-	        res[item] = res[item] + " " + line
-	    else:
-		res[item] = line
-	except:
-	    if item != None:
-	        if res.has_key(item):
-		    res[item] = res[item] + " " + line
-		else:
-		    res[item] = line
+            line = line[1:]
+        try:
+            (it, line) = line.split(":", 1)
+            item = it
+            while line != "" and (line[0] == ' ' or line[0] == '\t'):
+                line = line[1:]
+            if item in res:
+                res[item] = res[item] + " " + line
+            else:
+                res[item] = line
+        except:
+            if item != None:
+                if item in res:
+                    res[item] = res[item] + " " + line
+                else:
+                    res[item] = line
     return res
 
 def parse(filename, output):
@@ -100,5 +100,5 @@
     output.write("  <example filename='%s'>\n" % filename)
     try:
         synopsis = info['synopsis']
-	output.write("    <synopsis>%s</synopsis>\n" % escape(synopsis));
+        output.write("    <synopsis>%s</synopsis>\n" % escape(synopsis));
     except:
@@ -104,4 +104,4 @@
     except:
-        print "Example %s lacks a synopsis description" % (filename)
+        print("Example %s lacks a synopsis description" % (filename))
     try:
         purpose = info['purpose']
@@ -106,4 +106,4 @@
     try:
         purpose = info['purpose']
-	output.write("    <purpose>%s</purpose>\n" % escape(purpose));
+        output.write("    <purpose>%s</purpose>\n" % escape(purpose));
     except:
@@ -109,4 +109,4 @@
     except:
-        print "Example %s lacks a purpose description" % (filename)
+        print("Example %s lacks a purpose description" % (filename))
     try:
         usage = info['usage']
@@ -111,4 +111,4 @@
     try:
         usage = info['usage']
-	output.write("    <usage>%s</usage>\n" % escape(usage));
+        output.write("    <usage>%s</usage>\n" % escape(usage));
     except:
@@ -114,4 +114,4 @@
     except:
-        print "Example %s lacks an usage description" % (filename)
+        print("Example %s lacks an usage description" % (filename))
     try:
         test = info['test']
@@ -116,10 +116,10 @@
     try:
         test = info['test']
-	output.write("    <test>%s</test>\n" % escape(test));
-	progname=filename[0:-2]
-	command=string.replace(test, progname, './' + progname, 1)
-	tests.append(command)
+        output.write("    <test>%s</test>\n" % escape(test));
+        progname=filename[0:-2]
+        command=test.replace(progname, './' + progname, 1)
+        tests.append(command)
     except:
         pass
     try:
         author = info['author']
@@ -122,6 +122,6 @@
     except:
         pass
     try:
         author = info['author']
-	output.write("    <author>%s</author>\n" % escape(author));
+        output.write("    <author>%s</author>\n" % escape(author));
     except:
@@ -127,4 +127,4 @@
     except:
-        print "Example %s lacks an author description" % (filename)
+        print("Example %s lacks an author description" % (filename))
     try:
         copy = info['copy']
@@ -129,4 +129,4 @@
     try:
         copy = info['copy']
-	output.write("    <copy>%s</copy>\n" % escape(copy));
+        output.write("    <copy>%s</copy>\n" % escape(copy));
     except:
@@ -132,4 +132,4 @@
     except:
-        print "Example %s lacks a copyright description" % (filename)
+        print("Example %s lacks a copyright description" % (filename))
     try:
         section = info['section']
@@ -134,8 +134,8 @@
     try:
         section = info['section']
-	output.write("    <section>%s</section>\n" % escape(section));
-	if sections.has_key(section):
-	    sections[section].append(filename)
-	else:
-	    sections[section] = [filename]
+        output.write("    <section>%s</section>\n" % escape(section));
+        if section in sections:
+            sections[section].append(filename)
+        else:
+            sections[section] = [filename]
     except:
@@ -141,4 +141,4 @@
     except:
-        print "Example %s lacks a section description" % (filename)
-    for topic in info.keys():
+        print("Example %s lacks a section description" % (filename))
+    for topic in sorted(info.keys()):
         if topic != "purpose" and topic != "usage" and \
@@ -144,7 +144,7 @@
         if topic != "purpose" and topic != "usage" and \
-	   topic != "author" and topic != "copy" and \
-	   topic != "section" and topic != "synopsis" and topic != "test":
-	    str = info[topic]
-	    output.write("    <extra topic='%s'>%s</extra>\n" % (
-	                 escape(topic), escape(str)))
+           topic != "author" and topic != "copy" and \
+           topic != "section" and topic != "synopsis" and topic != "test":
+            str = info[topic]
+            output.write("    <extra topic='%s'>%s</extra>\n" % (
+                         escape(topic), escape(str)))
     output.write("    <includes>\n")
@@ -150,3 +150,3 @@
     output.write("    <includes>\n")
-    for include in idx.includes.keys():
+    for include in sorted(idx.includes.keys()):
         if include.find("libxml") != -1:
@@ -152,4 +152,7 @@
         if include.find("libxml") != -1:
-	    output.write("      <include>%s</include>\n" % (escape(include)))
+            id = idx.includes[include]
+            line = id.get_lineno()
+            output.write("      <include line='%d'>%s</include>\n" %
+                         (line, escape(include)))
     output.write("    </includes>\n")
     output.write("    <uses>\n")
@@ -154,4 +157,4 @@
     output.write("    </includes>\n")
     output.write("    <uses>\n")
-    for ref in idx.references.keys():
+    for ref in sorted(idx.references.keys()):
         id = idx.references[ref]
@@ -157,26 +160,26 @@
         id = idx.references[ref]
-	name = id.get_name()
-	line = id.get_lineno()
-	if symbols.has_key(name):
-	    sinfo = symbols[name]
-	    refs = sinfo[0]
-	    # gather at most 5 references per symbols
-	    if refs > 5:
-	        continue
-	    sinfo.append(filename)
-	    sinfo[0] = refs + 1
-	else:
-	    symbols[name] = [1, filename]
-	info = find_symbol(name)
-	if info != None:
-	    type = info[0]
-	    file = info[1]
-	    output.write("      <%s line='%d' file='%s' name='%s'/>\n" % (type,
-	                 line, file, name))
-	else:
-	    type = id.get_type()
-	    output.write("      <%s line='%d' name='%s'/>\n" % (type,
-	                 line, name))
+        name = id.get_name()
+        line = id.get_lineno()
+        if name in symbols:
+            sinfo = symbols[name]
+            refs = sinfo[0]
+            # gather at most 5 references per symbols
+            if refs > 5:
+                continue
+            sinfo.append(filename)
+            sinfo[0] = refs + 1
+        else:
+            symbols[name] = [1, filename]
+        info = find_symbol(name)
+        if info != None:
+            type = info[0]
+            file = info[1]
+            output.write("      <%s line='%d' file='%s' name='%s'/>\n" % (type,
+                         line, file, name))
+        else:
+            type = id.get_type()
+            output.write("      <%s line='%d' name='%s'/>\n" % (type,
+                         line, name))
 
     output.write("    </uses>\n")
     output.write("  </example>\n")
@@ -187,7 +190,5 @@
     global symbols
 
     output.write("  <symbols>\n")
-    keys = symbols.keys()
-    keys.sort()
-    for symbol in keys:
+    for symbol in sorted(symbols.keys()):
         output.write("    <symbol name='%s'>\n" % (symbol))
@@ -193,9 +194,9 @@
         output.write("    <symbol name='%s'>\n" % (symbol))
-	info = symbols[symbol]
-	i = 1
-	while i < len(info):
-	    output.write("      <ref filename='%s'/>\n" % (info[i]))
-	    i = i + 1
+        info = symbols[symbol]
+        i = 1
+        while i < len(info):
+            output.write("      <ref filename='%s'/>\n" % (info[i]))
+            i = i + 1
         output.write("    </symbol>\n")
     output.write("  </symbols>\n")
 
@@ -203,7 +204,5 @@
     global sections
 
     output.write("  <sections>\n")
-    keys = sections.keys()
-    keys.sort()
-    for section in keys:
+    for section in sorted(sections.keys()):
         output.write("    <section name='%s'>\n" % (section))
@@ -209,9 +208,9 @@
         output.write("    <section name='%s'>\n" % (section))
-	info = sections[section]
-	i = 0
-	while i < len(info):
-	    output.write("      <example filename='%s'/>\n" % (info[i]))
-	    i = i + 1
+        info = sections[section]
+        i = 0
+        while i < len(info):
+            output.write("      <example filename='%s'/>\n" % (info[i]))
+            i = i + 1
         output.write("    </section>\n")
     output.write("  </sections>\n")
 
@@ -231,11 +230,11 @@
 CLEANFILES = *.tmp
 
 rebuild:
-	cd $(srcdir) && $(PYTHON) index.py
-	$(MAKE) Makefile
-	cd $(srcdir) && xsltproc examples.xsl examples.xml
-	-cd $(srcdir) && xmllint --valid --noout index.html
+\tcd $(srcdir) && $(PYTHON) index.py
+\t$(MAKE) Makefile
+\tcd $(srcdir) && xsltproc examples.xsl examples.xml
+\t-cd $(srcdir) && xmllint --valid --noout index.html
 
 .PHONY: rebuild
 
 install-data-local: 
@@ -238,8 +237,8 @@
 
 .PHONY: rebuild
 
 install-data-local: 
-	$(MKDIR_P) $(DESTDIR)$(docdir)/examples
-	-$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(DESTDIR)$(docdir)/examples/
+\t$(MKDIR_P) $(DESTDIR)$(docdir)/examples
+\t-$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(DESTDIR)$(docdir)/examples/
 
 clean-local:
@@ -244,6 +243,6 @@
 
 clean-local:
-	test -f Makefile.am || rm -f test?.xml
+\ttest -f Makefile.am || rm -f test?.xml
 
 """
     examples.sort()
@@ -269,8 +268,8 @@
         Makefile = Makefile + '\t@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0\n'
     Makefile = Makefile + "\t@rm *.tmp\n"
     try:
-	old = open("Makefile.am", "r").read()
-	if old != Makefile:
-	    n = open("Makefile.am", "w").write(Makefile)
-	    print "Updated Makefile.am"
+        old = open("Makefile.am", "r").read()
+        if old != Makefile:
+            n = open("Makefile.am", "w").write(Makefile)
+            print("Updated Makefile.am")
     except:
@@ -276,21 +275,5 @@
     except:
-        print "Failed to read or save Makefile.am"
-#    #
-#    # Autogenerate the .cvsignore too ... DEPRECATED
-#    #
-#    ignore = """.memdump
-#Makefile.in
-#Makefile
-#"""
-#    for example in examples:
-#        ignore = ignore + "%s\n" % (example)
-#    try:
-#	old = open(".cvsignore", "r").read()
-#	if old != ignore:
-#	    n = open(".cvsignore", "w").write(ignore)
-#	    print "Updated .cvsignore"
-#    except:
-#        print "Failed to read or save .cvsignore"
+        print("Failed to read or save Makefile.am")
 
 if __name__ == "__main__":
     load_api()
@@ -298,8 +281,8 @@
     output.write("<examples>\n")
 
     for file in sorted(glob.glob('*.c')):
-	parse(file, output)
-	examples.append(file[:-2])
+        parse(file, output)
+        examples.append(file[:-2])
 
     dump_symbols(output)
     dump_sections(output)