Roll libxml from 37ebf8a8 to f2987a29

This patch also removes the docbook configure option which was removed
upstream and changes the filename of the generated archive file from
"gz" to "xz" due to upstream changes.

2022-04-03 daniel.engberg.lists@pyret.net cmake: Remove non needed files in docs dir
2022-04-04 wellnhofer@aevum.de Move doc/examples tests to new test suite
2022-04-04 wellnhofer@aevum.de Simplify 'make check' targets
2022-04-03 ccom@randomderp.com configure: move XML_PRIVATE_LIBS after WIN32_EXTRA_LIBADD is set
2022-04-04 wellnhofer@aevum.de Fix schemas and relaxng tests
2022-04-04 wellnhofer@aevum.de Remove unused result files
2020-07-09 wellnhofer@aevum.de Move regexp tests to runtest
2020-07-09 wellnhofer@aevum.de Allow missing result files in runtest
2022-04-03 wellnhofer@aevum.de Move SVG tests to runtest.c
2022-04-03 wellnhofer@aevum.de Move testModule to new test suite
2022-04-03 wellnhofer@aevum.de Move testThreads to new test suite
2022-04-03 wellnhofer@aevum.de Remove major parts of old test suite
2022-04-03 wellnhofer@aevum.de Move local Autoconf macros into m4 directory
2022-04-03 wellnhofer@aevum.de Remove outdated xml2Conf.sh
2022-04-03 wellnhofer@aevum.de Update xml2-config man page
2022-04-03 wellnhofer@aevum.de Consolidate man pages
2022-04-03 tony.tascioglu@windriver.com Make testchar return an error on failure
2022-04-03 wellnhofer@aevum.de Initialize XPath floating-point globals
2022-04-03 wellnhofer@aevum.de Add CI job for static build
2022-04-03 wellnhofer@aevum.de Use XML_PRIVATE_LIBS in libxml2_la_LIBADD
2022-04-03 wellnhofer@aevum.de Update libxml-2.0-uninstalled.pc.in
2022-04-03 wellnhofer@aevum.de Remove LIBS from XML_PRIVATE_LIBS
2022-04-03 wellnhofer@aevum.de Add WIN32_EXTRA_LIBADD to XML_PRIVATE_LIBS
2022-04-03 wellnhofer@aevum.de Don't overlink executables
2022-04-02 daniel.engberg.lists@pyret.net cmake: Adjust paths for UNIX or UNIX-like target systems
2022-04-02 daniel.engberg.lists@pyret.net build: Make use of variables in libxml's pkg-config file
2022-04-02 soap@gentoo.org Avoid obsolescent `test -a` constructs
2022-02-06 wellnhofer@aevum.de Make xmlStaticCopyNode non-recursive
2022-03-06 wellnhofer@aevum.de Clean up encoding switching code
2022-04-02 wellnhofer@aevum.de Move AM_MAINTAINER_MODE to AM section
2022-01-18 james.hilliard1@gmail.com configure: check for icu DEFS
2022-04-02 soap@gentoo.org configure.ac: produce tar.xz only (GNOME policy)
2022-04-02 soap@gentoo.org configure.ac: make AM_SILENT_RULES([yes]) unconditional
2022-04-02 wellnhofer@aevum.de Fix GitLab pages job
2022-04-02 wellnhofer@aevum.de Rename xmlcatalog_man.xml
2022-04-02 wellnhofer@aevum.de Streamline documentation installation
2022-04-02 wellnhofer@aevum.de Don't try to recreate COPYING symlink
2022-03-29 jarhar@chromium.org Add windows includes to xmlIO.c
2022-03-30 soap@gentoo.org python/tests: open() relative to test scripts
2022-03-30 soap@gentoo.org Detect libm using libtool's macros
2022-03-30 soap@gentoo.org configure.ac: disable static libraries by default
2022-03-30 soap@gentoo.org python/Makefile.am: nest python docs in $(docdir)
2022-03-30 soap@gentoo.org python/Makefile.am: rely on global AM_INIT_AUTOMAKE
2022-03-30 soap@gentoo.org Makefile.am: install examples more idiomatically
2022-03-30 soap@gentoo.org configure.ac: remove useless AC_SUBST
2022-03-30 soap@gentoo.org Respect `--sysconfdir` in source files
2022-03-30 jinniahn@gmail.com fix: xmlXPathParserContext could be double-delete in  OOM case.
2022-03-18 vadim@zeitlins.org Ignore configure backup file created by recent autoreconf too
2022-03-02 wellnhofer@aevum.de Only install *.html and *.c example files
2022-03-02 wellnhofer@aevum.de Remove --with-html-dir option
2022-03-02 wellnhofer@aevum.de Rework documentation build system
2022-03-02 wellnhofer@aevum.de Remove old website
2022-03-29 wellnhofer@aevum.de Mark docbook symbols as removed
2022-03-29 wellnhofer@aevum.de Port some test scripts to Python 3
2022-03-29 wellnhofer@aevum.de Fix calls to deprecated init/cleanup functions
2022-03-29 soap@gentoo.org Use AM_PATH_PYTHON/PKG_CHECK_MODULES for python bindings
2022-03-22 wellnhofer@aevum.de Revert "Continue to parse entity refs in recovery mode"
2022-03-18 wellnhofer@aevum.de Revert "Simplify recursive pthread mutex"
2022-03-06 wellnhofer@aevum.de Undeprecate schema init functions
2022-03-09 wellnhofer@aevum.de Fix --without-debug build
2022-03-06 wellnhofer@aevum.de Fix weak pthread symbols after commit 4adb7677
2022-03-06 wellnhofer@aevum.de Use critical sections as mutex on Windows
2022-03-06 wellnhofer@aevum.de Simplify recursive pthread mutex
2022-03-06 wellnhofer@aevum.de Use non-recursive mutex in dict.c
2022-03-06 wellnhofer@aevum.de Deprecate module init and cleanup functions
2022-03-06 wellnhofer@aevum.de Fix parser progress checks
2022-03-06 wellnhofer@aevum.de Avoid arithmetic on freed pointers
2022-03-05 wellnhofer@aevum.de Continue to parse entity refs in recovery mode
2022-03-05 wellnhofer@aevum.de Improve buffer allocation scheme
2022-03-05 wellnhofer@aevum.de Don't set HAVE_WIN32_THREADS in win32config.h
2022-03-05 wellnhofer@aevum.de Fix potential double-free in xmlXPtrStringRangeFunction
2022-03-05 wellnhofer@aevum.de Fix memory leak in xmlFindCharEncodingHandler
2022-03-05 wellnhofer@aevum.de Normalize XPath strings in-place
2022-03-02 wellnhofer@aevum.de Make examples a standalone HTML page
2022-03-02 wellnhofer@aevum.de Remove obsolete XML Software Autoupdate (XSA) file
2022-03-02 wellnhofer@aevum.de Add XML_DEPRECATED to ignored keywords
2022-03-04 wellnhofer@aevum.de Remove DOCBparser
2022-03-04 wellnhofer@aevum.de Remove unneeded #includes
2022-03-04 wellnhofer@aevum.de Use stdint.h with newer MSVC
2022-03-04 wellnhofer@aevum.de Remove cruft from win32config.h
2022-03-04 wellnhofer@aevum.de Remove ICONV_CONST test
2022-03-04 jarhar@chromium.org Remove regressions.py from Makefile.am
2022-03-03 wellnhofer@aevum.de Remove isinf/isnan emulation in win32config.h
2022-03-02 wellnhofer@aevum.de Fix recursion check in xinclude.c
2022-03-02 wellnhofer@aevum.de Update genChRanges.py
2022-03-02 wellnhofer@aevum.de Update build_glob.py
2022-03-02 wellnhofer@aevum.de Move xmlCleanupGlobals to non-generated section
2022-03-02 wellnhofer@aevum.de Remove obsolete Python test framework

Bug: 934413
Change-Id: Ia02605cd3a3061e612521001618993962f39abd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3556688
Auto-Submit: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988757}
NOKEYCHECK=True
GitOrigin-RevId: 035c7920440f028a3770416e4ffecd2abe791f0b
diff --git a/BUILD.gn b/BUILD.gn
index 9f6403f..24688c1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -156,7 +156,6 @@
   # Commented out sources are libxml2 files we do not want to include. They are
   # here to make it easy to identify files which are new.
   sources = [
-    #"src/DOCBparser.c",
     "src/HTMLparser.c",
     "src/HTMLtree.c",
 
@@ -177,7 +176,6 @@
     "src/error.c",
     "src/globals.c",
     "src/hash.c",
-    "src/include/libxml/DOCBparser.h",
     "src/include/libxml/HTMLparser.h",
     "src/include/libxml/HTMLtree.h",
     "src/include/libxml/SAX.h",
diff --git a/README.chromium b/README.chromium
index 982eb77..43e1b54 100644
--- a/README.chromium
+++ b/README.chromium
@@ -1,7 +1,7 @@
 Name: libxml
 URL: http://xmlsoft.org
-Version: 37ebf8a8b2789037792cfc0264b814d742cda2d9
-CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.12
+Version: f2987a295ff847ecb2a6a3eae1a271c9a64255b6
+CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.13
 License: MIT
 License File: src/Copyright
 Security Critical: yes
diff --git a/chromium/roll.py b/chromium/roll.py
index e91d8c0..32a62a7 100755
--- a/chromium/roll.py
+++ b/chromium/roll.py
@@ -96,7 +96,6 @@
     ('--without-c14n', 'c14n=no'),
     ('--without-catalog', 'catalog=no'),
     ('--without-debug', 'xml_debug=no'),
-    ('--without-docbook', 'docb=no'),
     ('--without-ftp', 'ftp=no'),
     ('--without-http', 'http=no'),
     ('--without-iconv', 'iconv=no'),
@@ -341,7 +340,7 @@
         # Work out what it is called
         tar_file = subprocess.check_output(
             '''awk '/PACKAGE =/ {p=$3} /VERSION =/ {v=$3} '''
-            '''END {printf("%s-%s.tar.gz", p, v)}' Makefile''',
+            '''END {printf("%s-%s.tar.xz", p, v)}' Makefile''',
             shell=True).decode('ascii')
         return commit, os.path.abspath(tar_file)
 
@@ -363,7 +362,7 @@
             # Update the libxml repo and export it to the Chromium tree
             with WorkingDir(THIRD_PARTY_LIBXML_SRC):
                 subprocess.check_call(
-                    'tar xzf %s --strip-components=1' % tar_file,
+                    'tar xJf %s --strip-components=1' % tar_file,
                     shell=True)
         finally:
             shutil.rmtree(temp_dir)
diff --git a/linux/config.h b/linux/config.h
index c702e79..c95bcf5 100644
--- a/linux/config.h
+++ b/linux/config.h
@@ -147,9 +147,6 @@
 /* Whether __va_copy() is available */
 /* #undef HAVE___VA_COPY */
 
-/* Define as const if the declaration of iconv() needs const. */
-/* #undef ICONV_CONST */
-
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #define LT_OBJDIR ".libs/"
 
diff --git a/linux/include/libxml/xmlversion.h b/linux/include/libxml/xmlversion.h
index fae4bf0..ffd1494 100644
--- a/linux/include/libxml/xmlversion.h
+++ b/linux/include/libxml/xmlversion.h
@@ -230,15 +230,6 @@
 #endif
 
 /**
- * LIBXML_DOCB_ENABLED:
- *
- * Whether the SGML Docbook support is configured in
- */
-#if 0
-#define LIBXML_DOCB_ENABLED
-#endif
-
-/**
  * LIBXML_XPATH_ENABLED:
  *
  * Whether XPath is configured in
diff --git a/linux/xml2-config b/linux/xml2-config
index 28e7f23..10f1313 100755
--- a/linux/xml2-config
+++ b/linux/xml2-config
@@ -86,14 +86,12 @@
             shift
             libs="-lxml2"
         else
-            libs="-lxml2     -licui18n -licuuc -licudata -lm  "
+            libs="-lxml2     -licui18n -licuuc -licudata -lm   "
         fi
 
         if [ "-L${libdir}" != "-L/usr/lib" -a "-L${libdir}" != "-L/usr/lib64" ]; then
             libs="-L${libdir} $libs"
         fi
-
-        libs="$libs "
         ;;
 
     *)
diff --git a/mac/config.h b/mac/config.h
index c702e79..c95bcf5 100644
--- a/mac/config.h
+++ b/mac/config.h
@@ -147,9 +147,6 @@
 /* Whether __va_copy() is available */
 /* #undef HAVE___VA_COPY */
 
-/* Define as const if the declaration of iconv() needs const. */
-/* #undef ICONV_CONST */
-
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #define LT_OBJDIR ".libs/"
 
diff --git a/mac/include/libxml/xmlversion.h b/mac/include/libxml/xmlversion.h
index fae4bf0..ffd1494 100644
--- a/mac/include/libxml/xmlversion.h
+++ b/mac/include/libxml/xmlversion.h
@@ -230,15 +230,6 @@
 #endif
 
 /**
- * LIBXML_DOCB_ENABLED:
- *
- * Whether the SGML Docbook support is configured in
- */
-#if 0
-#define LIBXML_DOCB_ENABLED
-#endif
-
-/**
  * LIBXML_XPATH_ENABLED:
  *
  * Whether XPath is configured in
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d679414..68419a0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -26,7 +26,6 @@
 option(LIBXML2_WITH_C14N "Add the Canonicalization support" ON)
 option(LIBXML2_WITH_CATALOG "Add the Catalog support" ON)
 option(LIBXML2_WITH_DEBUG "Add the debugging module" ON)
-option(LIBXML2_WITH_DOCB "Add Docbook SGML support" ON)
 set(LIBXML2_WITH_EXPR ON)
 option(LIBXML2_WITH_FTP "Add the FTP support" ON)
 option(LIBXML2_WITH_HTML "Add the HTML support" ON)
@@ -97,7 +96,7 @@
 	find_package(ZLIB REQUIRED)
 endif()
 
-foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_DOCB WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
+foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
 	if(LIBXML2_${VARIABLE})
 		set(${VARIABLE} 1)
 	else()
@@ -194,23 +193,6 @@
 	check_include_files(unistd.h HAVE_UNISTD_H)
 	check_function_exists(va_copy HAVE_VA_COPY)
 	check_function_exists(__va_copy HAVE___VA_COPY)
-	check_c_source_compiles("
-		#include <stdlib.h>
-		#include <iconv.h>
-		extern
-		#ifdef __cplusplus
-		\"C\"
-		#endif
-		#if defined(__STDC__) || defined(__cplusplus)
-		size_t iconv(iconv_t cd, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft);
-		#else
-		size_t iconv();
-		#endif
-		int main() { return 0; }
-	" ICONV_CONST_TEST)
-	if(NOT ICONV_CONST_TEST)
-		set(ICONV_CONST "const")
-	endif()
 	set(LT_OBJDIR ".libs/")
 	check_c_source_compiles("
 		#include <sys/socket.h>
@@ -270,7 +252,6 @@
 	include/libxml/chvalid.h
 	include/libxml/debugXML.h
 	include/libxml/dict.h
-	include/libxml/DOCBparser.h
 	include/libxml/encoding.h
 	include/libxml/entities.h
 	include/libxml/globals.h
@@ -373,10 +354,6 @@
 	)
 endif()
 
-if(LIBXML2_WITH_SAX1)
-	list(APPEND LIBXML2_SRCS DOCBparser.c)
-endif()
-
 if(LIBXML2_WITH_TRIO)
 	list(APPEND LIBXML2_SRCS trio.c triostr.c)
 endif()
@@ -384,6 +361,8 @@
 add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS})
 add_library(LibXml2::LibXml2 ALIAS LibXml2)
 
+target_compile_definitions(LibXml2 PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
+
 if(NOT BUILD_SHARED_LIBS)
 	target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC)
 	set(XML_CFLAGS "-DLIBXML_STATIC")
@@ -416,7 +395,7 @@
 
 if(UNIX)
 	target_link_libraries(LibXml2 PRIVATE m)
-	set(M_LIBS "-lm")
+	set(LIBM "-lm")
 endif()
 
 if(WIN32)
@@ -507,6 +486,7 @@
 	foreach(PROGRAM ${PROGRAMS})
 		add_executable(${PROGRAM} ${PROGRAM}.c)
 		add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM})
+		target_compile_definitions(${PROGRAM} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
 		target_link_libraries(${PROGRAM} LibXml2)
 		if(HAVE_LIBHISTORY)
 			target_link_libraries(${PROGRAM} history)
@@ -526,20 +506,11 @@
 		runsuite
 		testapi
 		testAutomata
-		testC14N
 		testchar
 		testdict
-		testHTML
 		testModule
 		testlimits
-		testReader
 		testrecurse
-		testRegexp
-		testRelax
-		testSAX
-		testSchemas
-		testURI
-		testXPath
 	)
 	foreach(TEST ${TESTS})
 		add_executable(${TEST} ${TEST}.c)
@@ -562,6 +533,7 @@
 		)
 		foreach(TEST ${TESTS_THREADS})
 			add_executable(${TEST} ${TEST}.c)
+			target_compile_definitions(${TEST} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
 			if(WIN32)
 				target_compile_definitions(${TEST} PRIVATE HAVE_WIN32_THREADS)
 			endif()
@@ -622,10 +594,16 @@
 	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
 endif()
 
-install(FILES libxml.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 COMPONENT documentation)
+install(FILES doc/xml2-config.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
 install(FILES doc/xmlcatalog.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
 install(FILES doc/xmllint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
-install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2 COMPONENT documentation PATTERN Makefile.* EXCLUDE)
+install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2 COMPONENT documentation
+	PATTERN "Makefile.*" EXCLUDE
+	PATTERN "*.xsl" EXCLUDE
+	PATTERN "*.py" EXCLUDE
+	PATTERN "*.xml" EXCLUDE
+	PATTERN "examples/*" EXCLUDE)
+install(DIRECTORY doc/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2/examples COMPONENT documentation PATTERN "Makefile.*" EXCLUDE)
 
 configure_package_config_file(
 	libxml2-config.cmake.cmake.in libxml2-config.cmake
@@ -669,26 +647,30 @@
 set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
 set(XML_LIBDIR "-L\${libdir}")
 set(XML_LIBS "-lxml2")
-set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${M_LIBS}")
+set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${LIBM} ${WIN32_EXTRA_LIBADD}")
 
 file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
 string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
 
-set(prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}")
+if(WIN32)
+	set(prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}")
+else()
+	set(prefix "${CMAKE_INSTALL_PREFIX}")
+endif()
 set(exec_prefix "\${prefix}")
 set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
 set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
 configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development)
 
-set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..")
+if(WIN32)
+	set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..")
+endif()
 configure_file(xml2-config.in xml2-config @ONLY)
 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xml2-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development)
 
 set(XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2")
 set(XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}")
-configure_file(xml2Conf.sh.in xml2Conf.sh @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml2Conf.sh DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development)
 
 set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime)
 set(CPACK_COMPONENT_PROGRAMS_DEPENDS runtime)
diff --git a/src/HTMLparser.c b/src/HTMLparser.c
index 4b9b4e4..9bd0fb3 100644
--- a/src/HTMLparser.c
+++ b/src/HTMLparser.c
@@ -14,19 +14,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef LIBXML_ZLIB_ENABLED
-#include <zlib.h>
-#endif
-
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
@@ -1407,6 +1394,9 @@
 /**
  * htmlInitAutoClose:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * This is a no-op now.
  */
 void
diff --git a/src/Makefile.am b/src/Makefile.am
index fdbbc40..a230f67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,25 +2,37 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = include . doc example fuzz xstc $(PYTHON_SUBDIR)
+SUBDIRS = include . doc example fuzz xstc
+if WITH_PYTHON
+SUBDIRS += python
+endif
 
 DIST_SUBDIRS = include . doc example fuzz python xstc
 
-AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include -DSYSCONFDIR='"$(sysconfdir)"'
 
-AM_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
+AM_CFLAGS = $(EXTRA_CFLAGS)
 
-check_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \
-               testThreads testC14N testAutomata testRegexp \
-               testReader testapi testModule runtest runsuite testchar \
-	       testdict runxmlconf testrecurse testlimits
+check_PROGRAMS = \
+	runsuite \
+	runtest \
+	runxmlconf \
+	testAutomata \
+	testModule \
+	testThreads \
+	testapi \
+	testchar \
+	testdict \
+	testlimits \
+	testrecurse
 
 bin_PROGRAMS = xmllint xmlcatalog
 
 bin_SCRIPTS=xml2-config
 
 lib_LTLIBRARIES = libxml2.la
-libxml2_la_LIBADD = $(ICU_LIBS) $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
+libxml2_la_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
+libxml2_la_LIBADD = $(XML_PRIVATE_LIBS)
 
 if USE_VERSION_SCRIPT
 LIBXML2_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
@@ -33,12 +45,6 @@
 		     -version-info $(LIBXML_VERSION_INFO) \
 		     $(MODULE_PLATFORM_LIBS)
 
-if WITH_SAX1_SOURCES
-docb_sources = DOCBparser.c
-else
-docb_sources =
-endif
-
 if WITH_TRIO_SOURCES
 trio_sources = triostr.c trio.c
 else
@@ -49,7 +55,6 @@
 		parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c  \
 		valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c  \
 		xpointer.c xinclude.c nanohttp.c nanoftp.c \
-		$(docb_sources) \
 		catalog.c globals.c threads.c c14n.c xmlstring.c buf.c \
 		xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
 		$(trio_sources) \
@@ -58,109 +63,64 @@
 		xmlmodule.c schematron.c xzlib.c
 
 DEPS = $(top_builddir)/libxml2.la
-LDADDS = $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
+LDADDS = $(top_builddir)/libxml2.la
 
 
-man_MANS = xml2-config.1 libxml.3
-
 m4datadir = $(datadir)/aclocal
 m4data_DATA = libxml.m4
 
 runtest_SOURCES=runtest.c
+runtest_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS)
 runtest_LDFLAGS = 
 runtest_DEPENDENCIES = $(DEPS)
-runtest_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
+runtest_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS)
 
 testrecurse_SOURCES=testrecurse.c
 testrecurse_LDFLAGS = 
 testrecurse_DEPENDENCIES = $(DEPS)
-testrecurse_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
+testrecurse_LDADD= $(LDADDS)
 
 testlimits_SOURCES=testlimits.c
 testlimits_LDFLAGS = 
 testlimits_DEPENDENCIES = $(DEPS)
-testlimits_LDADD= $(BASE_THREAD_LIBS) $(RDL_LIBS) $(LDADDS)
+testlimits_LDADD= $(LDADDS)
 
 testchar_SOURCES=testchar.c
 testchar_LDFLAGS = 
 testchar_DEPENDENCIES = $(DEPS)
-testchar_LDADD= $(RDL_LIBS) $(LDADDS)
+testchar_LDADD= $(LDADDS)
 
 testdict_SOURCES=testdict.c
 testdict_LDFLAGS = 
 testdict_DEPENDENCIES = $(DEPS)
-testdict_LDADD= $(RDL_LIBS) $(LDADDS)
+testdict_LDADD= $(LDADDS)
 
 runsuite_SOURCES=runsuite.c
 runsuite_LDFLAGS = 
 runsuite_DEPENDENCIES = $(DEPS)
-runsuite_LDADD= $(RDL_LIBS) $(LDADDS)
+runsuite_LDADD= $(LDADDS)
 
 xmllint_SOURCES=xmllint.c
 xmllint_LDFLAGS = 
 xmllint_DEPENDENCIES = $(DEPS)
 xmllint_LDADD=  $(RDL_LIBS) $(LDADDS)
 
-testSAX_SOURCES=testSAX.c
-testSAX_LDFLAGS = 
-testSAX_DEPENDENCIES = $(DEPS)
-testSAX_LDADD= $(LDADDS)
-
-testHTML_SOURCES=testHTML.c
-testHTML_LDFLAGS = 
-testHTML_DEPENDENCIES = $(DEPS)
-testHTML_LDADD= $(LDADDS)
-
 xmlcatalog_SOURCES=xmlcatalog.c
 xmlcatalog_LDFLAGS = 
 xmlcatalog_DEPENDENCIES = $(DEPS)
 xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS)
 
-testXPath_SOURCES=testXPath.c
-testXPath_LDFLAGS = 
-testXPath_DEPENDENCIES = $(DEPS)
-testXPath_LDADD= $(LDADDS)
-
-testC14N_SOURCES=testC14N.c
-testC14N_LDFLAGS = 
-testC14N_DEPENDENCIES = $(DEPS)
-testC14N_LDADD= $(LDADDS)
-
 testThreads_SOURCES = testThreads.c
+testThreads_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS)
 testThreads_LDFLAGS = 
 testThreads_DEPENDENCIES = $(DEPS)
-testThreads_LDADD= $(BASE_THREAD_LIBS) $(LDADDS)
-
-testURI_SOURCES=testURI.c
-testURI_LDFLAGS = 
-testURI_DEPENDENCIES = $(DEPS)
-testURI_LDADD= $(LDADDS)
-
-testRegexp_SOURCES=testRegexp.c
-testRegexp_LDFLAGS = 
-testRegexp_DEPENDENCIES = $(DEPS)
-testRegexp_LDADD= $(LDADDS)
+testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS)
 
 testAutomata_SOURCES=testAutomata.c
 testAutomata_LDFLAGS = 
 testAutomata_DEPENDENCIES = $(DEPS)
 testAutomata_LDADD= $(LDADDS)
 
-testSchemas_SOURCES=testSchemas.c
-testSchemas_LDFLAGS = 
-testSchemas_DEPENDENCIES = $(DEPS)
-testSchemas_LDADD= $(LDADDS)
-
-testRelax_SOURCES=testRelax.c
-testRelax_LDFLAGS = 
-testRelax_DEPENDENCIES = $(DEPS)
-testRelax_LDADD= $(LDADDS)
-
-testReader_SOURCES=testReader.c
-testReader_LDFLAGS = 
-testReader_DEPENDENCIES = $(DEPS)
-testReader_LDADD= $(LDADDS)
-
 testModule_SOURCES=testModule.c
 testModule_LDFLAGS = 
 testModule_DEPENDENCIES = $(DEPS)
@@ -198,451 +158,32 @@
 #testOOM_DEPENDENCIES = $(DEPS)
 #testOOM_LDADD= $(LDADDS)
 
-runtests: runtest$(EXEEXT) testrecurse$(EXEEXT) testapi$(EXEEXT) \
-          testchar$(EXEEXT) testdict$(EXEEXT) runxmlconf$(EXEEXT)
+check-local:
 	[ -d test   ] || $(LN_S) $(srcdir)/test   .
 	[ -d result ] || $(LN_S) $(srcdir)/result .
-	$(CHECKER) ./runtest$(EXEEXT) && \
-	    $(CHECKER) ./testrecurse$(EXEEXT) && \
-	    ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) ./testapi$(EXEEXT) && \
-	    $(CHECKER) ./testchar$(EXEEXT) && \
-	    $(CHECKER) ./testdict$(EXEEXT) && \
-	    $(CHECKER) ./runxmlconf$(EXEEXT)
-	@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
-	    $(MAKE) tests ; fi)
-	@cd fuzz; $(MAKE) tests
+	$(CHECKER) ./runtest$(EXEEXT)
+	$(CHECKER) ./testrecurse$(EXEEXT)
+	ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) ./testapi$(EXEEXT)
+	$(CHECKER) ./testchar$(EXEEXT)
+	$(CHECKER) ./testdict$(EXEEXT)
+	$(CHECKER) ./testModule$(EXEEXT)
+	$(CHECKER) ./testThreads$(EXEEXT)
+	$(CHECKER) ./runxmlconf$(EXEEXT)
 
-check: all runtests
+# Compatibility name of the check target
+runtests: check
 
-check-valgrind valgrind: all
+check-valgrind valgrind:
 	@echo '## Running the regression tests under Valgrind'
 	@echo '## Go get a cup of coffee it is gonna take a while ...'
-	$(MAKE) CHECKER='valgrind -q' runtests
+	$(MAKE) CHECKER='valgrind -q' check
 
 asan:
 	@echo '## rebuilding for ASAN'
 	./configure CFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" CXXFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" LDFLAGS="-fsanitize=address,undefined" CC="clang" CXX="clang++" --disable-shared ; OptimOff  ; $(MAKE) clean ; $(MAKE)
 
-testall : tests SVGtests SAXtests
-
-tests: XMLtests XMLenttests NStests IDtests Errtests APItests $(READER_TEST) $(TEST_SAX) $(TEST_PUSH) $(TEST_HTML) $(TEST_PHTML) $(TEST_VALID) URItests $(TEST_PATTERN) $(TEST_XPATH) $(TEST_XPTR) $(TEST_XINCLUDE) $(TEST_C14N) $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMAS) $(TEST_SCHEMATRON) $(TEST_THREADS) Timingtests $(TEST_VTIME) $(PYTHON_TESTS) $(TEST_MODULES)
-	@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
-	    $(MAKE) -s tests ; fi)
-	@(cd doc/examples ; $(MAKE) -s tests)
-
-APItests: testapi$(EXEEXT)
-	@echo "## Running the API regression tests this may take a little while"
-	-@(ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) $(top_builddir)/testapi -q)
-
-HTMLtests : testHTML$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## HTML regression tests"
-	-@(for i in $(srcdir)/test/HTML/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testHTML $$i > result.$$name 2> error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/HTML/$$name result.$$name ; \
-	      diff -b $(srcdir)/result/HTML/$$name.err error.$$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML result.$$name > result2.$$name 2>error.$$name ; \
-	      diff result.$$name result2.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name result2.$$name error.$$name ; \
-	  fi ; fi ; done)
-
-HTMLPushtests : testHTML$(EXEEXT)
-	@echo "## Push HTML regression tests"
-	-@(for i in $(srcdir)/test/HTML/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML --push $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testHTML --push $$i > result.$$name 2> error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/HTML/$$name result.$$name ; \
-	      cut -b 1-15 $(srcdir)/result/HTML/$$name.err > errorcut.$$name; \
-	      cut -b 1-15 error.$$name > errorcut2.$$name; \
-	      diff -b errorcut.$$name errorcut2.$$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML --push result.$$name > result2.$$name 2>error.$$name ; \
-	      diff result.$$name result2.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name result2.$$name error.$$name errorcut.$$name errorcut2.$$name ; \
-	  fi ; fi ; done)
-	@echo "## HTML SAX regression tests"
-	-@(for i in $(srcdir)/test/HTML/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/HTML/$$name.sax ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testHTML --sax $$i > result.$$name.sax ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name.sax ; \
-	  fi ; fi ; done)
-	@echo "## Push HTML SAX regression tests"
-	-@(for i in $(srcdir)/test/HTML/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testHTML --push --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testHTML --push --sax $$i 2>&1 > result.$$name.sax ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name.sax ; \
-	  fi ; fi ; done)
-
-XMLtests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XML regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint $$i > $(srcdir)/result/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/$$name result.$$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff result.$$name result2.$$name` ;\
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name result2.$$name ; \
-	  fi ; fi ; done)
-	@echo "## XML regression tests on memory"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --memory $$i > $(srcdir)/result/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --memory $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name result.$$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --memory result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"`; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      diff result.$$name result2.$$name ; \
-	      rm result.$$name result2.$$name ; \
-	  fi ; fi ; done)
-
-XMLPushtests: xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XML push regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --push $$i > $(srcdir)/result/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --push $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/$$name result.$$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --push result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff result.$$name result2.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name result2.$$name ; \
-	  fi ; fi ; done)
-
-NStests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XML Namespaces regression tests"
-	-@(for i in $(srcdir)/test/namespaces/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/namespaces/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint $$i \
-	         2> $(srcdir)/result/namespaces/$$name.err \
-		 > $(srcdir)/result/namespaces/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint $$i 2> error.$$name > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/namespaces/$$name result.$$name ; \
-	      diff $(srcdir)/result/namespaces/$$name.err error.$$name`; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-
-IDtests : xmllint$(EXEEXT) testXPath$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## xml:id regression tests"
-	-@(for i in $(srcdir)/test/xmlid/id_*.xml ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/xmlid/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testXPath -i $$i "id('bar')" \
-	         2> $(srcdir)/result/xmlid/$$name.err \
-		 > $(srcdir)/result/xmlid/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testXPath -i $$i "id('bar')" 2> error.$$name > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/xmlid/$$name result.$$name ; \
-	      diff $(srcdir)/result/xmlid/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-
-Errtests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Error cases regression tests"
-	-@(for i in $(srcdir)/test/errors/*.xml ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/errors/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint $$i \
-	         2> $(srcdir)/result/errors/$$name.err \
-		 > $(srcdir)/result/errors/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint $$i 2> error.$$name > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/errors/$$name result.$$name ; \
-	      diff $(srcdir)/result/errors/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-	@echo "## Error cases regression tests (old 1.0)"
-	-@(for i in $(srcdir)/test/errors10/*.xml ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/errors10/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --oldxml10 $$i \
-	         2> $(srcdir)/result/errors10/$$name.err \
-		 > $(srcdir)/result/errors10/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --oldxml10 $$i 2> error.$$name > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/errors10/$$name result.$$name ; \
-	      diff $(srcdir)/result/errors10/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-	@echo "## Error cases stream regression tests"
-	-@(for i in $(srcdir)/test/errors/*.xml ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/errors/$$name.str ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --stream $$i \
-	         2> $(srcdir)/result/errors/$$name.str \
-		 > /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --stream $$i 2> error.$$name > /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/errors/$$name.str error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm error.$$name ; \
-	  fi ; fi ; done)
-
-Docbtests : xmllint$(EXEEXT)
-
-XMLenttests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XML entity subst regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/noent/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --noent $$i > $(srcdir)/result/noent/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --noent $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff $(srcdir)/result/noent/$$name result.$$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --noent result.$$name 2>&1 > result2.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	      diff result.$$name result2.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name result2.$$name ; \
-	  fi ; fi ; done)
-
-URItests : testURI$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## URI module regression tests"
-	-@(for i in $(srcdir)/test/URI/*.data ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/URI/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i > $(srcdir)/result/URI/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/URI/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	-@(for i in $(srcdir)/test/URI/*.uri ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/URI/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testURI < $$i > $(srcdir)/result/URI/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testURI < $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/URI/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-
-XPathtests : testXPath$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XPath regression tests"
-	-@(if [ "`$(top_builddir)/testXPath | grep 'support not compiled in'`" != "" ] ; \
-	  then echo Skipping debug not compiled in ; exit 0 ; fi ; \
-	  for i in $(srcdir)/test/XPath/expr/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testXPath -f --expr $$i > result.$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XPath/expr/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done ; \
-	  for i in $(srcdir)/test/XPath/docs/* ; do \
-	  if [ ! -d $$i ] ; then \
-	  doc=`basename $$i`; \
-	  for j in $(srcdir)/test/XPath/tests/$$doc* ; do \
-	  if [ ! -f $$j ] ; then continue ; fi ; \
-	  name=`basename $$j`; \
-	  if [ ! -d $$j ] ; then \
-	  if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testXPath -f -i $$i $$j > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XPath/tests/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done ; fi ; done)
-
-XPtrtests : testXPath$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XPointer regression tests"
-	-@(if [ "`$(top_builddir)/testXPath | grep 'support not compiled in'`" != "" ] ; \
-	  then echo Skipping debug not compiled in ; exit 0 ; fi ; \
-	  for i in $(srcdir)/test/XPath/docs/* ; do \
-	  if [ ! -d $$i ] ; then \
-	  doc=`basename $$i`; \
-	  for j in $(srcdir)/test/XPath/xptr/$$doc* ; do \
-	  if [ ! -f $$j ] ; then continue ; fi ; \
-	  name=`basename $$j`; \
-	  if [ ! -d $$j ] ; then \
-	  if [ ! -f $(srcdir)/result/XPath/xptr/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testXPath -xptr -f -i $$i $$j > $(srcdir)/result/XPath/xptr/$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testXPath -xptr -f -i $$i $$j > result.$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XPath/xptr/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done ; fi ; done)
-
-XIncludetests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## XInclude regression tests"
-	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/XInclude/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > result.$$name 2>error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XInclude/$$name result.$$name ; \
-	      diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/XInclude/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > result.$$name 2>error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XInclude/$$name result.$$name ; \
-	      diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-	@(echo > .memdump)
-	@echo "## XInclude xmlReader regression tests"
-	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \
-	      diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \
-	      diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
+# Old test suite. This should be ported to C.
+tests: $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMATRON) Timingtests $(TEST_VTIME) $(PYTHON_TESTS)
 
 Scripttests : xmllint$(EXEEXT)
 	@(echo > .memdump)
@@ -719,224 +260,6 @@
 	grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
 	rm -f $(srcdir)/result/catalogs/mycatalog)
 
-SVGtests : xmllint$(EXEEXT)
-	@echo "## SVG parsing regression tests"
-	-@(for i in $(srcdir)/test/SVG/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/SVG/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint $$i > $(srcdir)/result/SVG/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      echo Testing $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint $$i > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/SVG/$$name result.$$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint result.$$name > result2.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff result.$$name result2.$$name ; \
-	      rm result.$$name result2.$$name ; \
-	  fi ; fi ; done)
-
-Threadtests : testThreads$(EXEEXT)
-	@echo "## Threaded regression tests"
-	-@($(CHECKER) $(top_builddir)/testThreads ; \
-	   grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
-	   exit 0)
-
-Readertests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Reader regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.rdr result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@echo "## Reader on memory regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --memory --nonet --debug --stream $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --memory --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.rdr result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@(echo > .memdump)
-	@echo "## Walker regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > result.$$name 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.rdr result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@echo "## Reader entities substitution regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.rde ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --noent --nonet --debug --stream $$i > $(srcdir)/result/$$name.rde 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --noent --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.rde result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-
-SAXtests : testSAX$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## SAX1 callbacks regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.sax ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testSAX $$i > $(srcdir)/result/$$name.sax 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testSAX $$i > result.$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.sax result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@echo "## SAX2 callbacks regression tests"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/$$name.sax2 ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testSAX --sax2 $$i > $(srcdir)/result/$$name.sax2 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testSAX --sax2 $$i > result.$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/$$name.sax2 result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@echo "## SAX2 callbacks regression tests with entity substitution"
-	-@(for i in $(srcdir)/test/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/noent/$$name.sax2 ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testSAX --sax2 --noent $$i > $(srcdir)/result/noent/$$name.sax2 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testSAX --sax2 --noent $$i > result.$$name 2> /dev/null ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/noent/$$name.sax2 result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-
-Validtests : xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Valid documents regression tests"
-	-@(for i in $(srcdir)/test/VCM/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --valid --noout --nowarning $$i ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"`;\
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	  fi ; done ; exit 0)
-	@echo "## Validity checking regression tests"
-	-@(for i in $(srcdir)/test/VC/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/VC/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --noout --valid $$i 2> result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/VC/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-	@echo "## General documents valid regression tests"
-	-@(for i in $(srcdir)/test/valid/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/valid/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint --valid $$i > result.$$name 2>error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/valid/$$name result.$$name ; \
-	      diff $(srcdir)/result/valid/$$name.err error.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-
-Regexptests: testRegexp$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Regexp regression tests"
-	-@(for i in $(srcdir)/test/regexp/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/regexp/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testRegexp -i $$i > $(srcdir)/result/regexp/$$name 2> $(srcdir)/result/regexp/$$name.err ; \
-	      if [ ! -s "$(srcdir)/result/regexp/$$name.err" ] ; then rm $(srcdir)/result/regexp/$$name.err; fi ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testRegexp -i $$i > result.$$name 2> error.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/regexp/$$name result.$$name ; \
-	      if [ -s "$(srcdir)/result/regexp/$$name.err" -o -s "error.$$name" ] ; then diff $(srcdir)/result/regexp/$$name.err error.$$name ; fi` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
-	      rm result.$$name error.$$name ; \
-	  fi ; fi ; done)
-
-# Disabled for now
-Exptests: testRegexp$(EXEEXT)
-	@echo "## Formal expressions regression tests"
-	-@(for i in $(srcdir)/test/expr/* ; do \
-	  name=`basename $$i`; \
-	  if [ ! -d $$i ] ; then \
-	  if [ ! -f $(srcdir)/result/expr/$$name ] ; then \
-	      echo New test file $$name ; \
-	      $(CHECKER) $(top_builddir)/testRegexp --expr -i $$i > $(srcdir)/result/expr/$$name; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/testRegexp --expr -i $$i 2>&1 > result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/expr/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done)
-
 Automatatests: testAutomata$(EXEEXT)
 	@(echo > .memdump)
 	@echo "## Automata regression tests"
@@ -989,138 +312,6 @@
 	   grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	   exit 0)
 
-C14Ntests : testC14N$(EXEEXT)
-	@echo "## C14N and XPath regression tests"
-	-@(for m in with-comments without-comments 1-1-without-comments exc-without-comments ; do \
-	    for i in $(srcdir)/test/c14n/$$m/*.xml ; do  \
-		if [ ! -d $$i ] ; then \
-		    name=`basename $$i .xml`; \
-		    cmdline="$(CHECKER) $(top_builddir)/testC14N --$$m $$i"; \
-		    if [ -f $(srcdir)/test/c14n/$$m/$$name.xpath ] ; then \
-			cmdline="$$cmdline $(srcdir)/test/c14n/$$m/$$name.xpath"; \
-			if [ -f $(srcdir)/test/c14n/$$m/$$name.ns ] ; then \
-			    cmdline="$$cmdline '`cat $(srcdir)/test/c14n/$$m/$$name.ns`'"; \
-			fi; \
-		    fi; \
-		    $$cmdline > $(srcdir)/test/c14n/test.tmp 2> /dev/null; \
-		    if [ $$? -eq 0 ]; then \
-			diff  $(srcdir)/result/c14n/$$m/$$name $(srcdir)/test/c14n/test.tmp; \
-			if [ $$? -ne 0 ]; then \
-			    echo "Test $$m/$$name failed"; \
-			    cat $(srcdir)/test/c14n/test.tmp; \
-			fi; \
-		    else \
-			echo "C14N failed"; \
-		    fi; \
-		    grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-		fi; \
-		rm -f $(srcdir)/test/c14n/test.tmp; \
-	    done; \
-	done)
-
-Schemastests: testSchemas$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Schemas regression tests"
-	-@(for i in $(srcdir)/test/schemas/*_*.xsd ; do \
-	  name=`basename $$i | sed 's+_.*++'`; \
-	  sno=`basename $$i | sed 's+.*_\(.*\).xsd+\1+'`; \
-	  for j in $(srcdir)/test/schemas/"$$name"_*.xml ; do \
-	      if [ -f $$j ] ; then \
-	      xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
-	      if [ ! -f $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" ]; \
-	      then \
-		  echo New test file "$$name"_"$$sno"_"$$xno" ; \
-		  $(CHECKER) $(top_builddir)/testSchemas $$i $$j \
-		    > $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" \
-		    2> $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err; \
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      else \
-	          log=`$(CHECKER) $(top_builddir)/testSchemas $$i $$j \
-		    > res.$$name 2> err.$$name;\
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	          diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" \
-		       res.$$name;\
-	          diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \
-		       err.$$name;\
-		  grep Unimplemented err.$$name`; \
-	          if [ -n "$$log" ] ; then echo "$$name"_"$$sno"_"$$xno" result ; echo "$$log" ; fi ; \
-	          rm res.$$name err.$$name ; \
-	       fi ; fi ;\
-	  done; done)
-
-Relaxtests: xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Relax-NG regression tests"
-	-@(for i in $(srcdir)/test/relaxng/*.rng ; do \
-	  name=`basename $$i | sed 's+\.rng++'`; \
-	  if [ ! -f $(srcdir)/result/relaxng/"$$name"_valid ] ; then \
-	      echo New schemas $$name ; \
-	      $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $(srcdir)/test/relaxng/tutorA.rng $$i \
-		      > $(srcdir)/result/relaxng/"$$name"_valid \
-		      2> $(srcdir)/result/relaxng/"$$name"_err; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	  else \
-	      log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $(srcdir)/test/relaxng/tutorA.rng $$i \
-	      > res.$$name 2> err.$$name;\
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      diff $(srcdir)/result/relaxng/"$$name"_valid \
-		   res.$$name;\
-	      diff $(srcdir)/result/relaxng/"$$name"_err \
-		   err.$$name | grep -v "error detected at";\
-	      grep Unimplemented err.$$name`; \
-	      if [ -n "$$log" ] ; then echo schemas $$name result ; echo "$$log" ; fi ; \
-	      rm res.$$name err.$$name ; \
-	  fi; \
-	  for j in $(srcdir)/test/relaxng/"$$name"_*.xml ; do \
-	      if [ -f $$j ] ; then \
-	      xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
-	      if [ ! -f $(srcdir)/result/relaxng/"$$name"_"$$xno" ]; \
-	      then \
-		  echo New test file "$$name"_"$$xno" ; \
-		  $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \
-		    > $(srcdir)/result/relaxng/"$$name"_"$$xno" \
-		    2> $(srcdir)/result/relaxng/"$$name"_"$$xno".err; \
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      else \
-	          log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \
-		    > res.$$name 2> err.$$name;\
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	          diff $(srcdir)/result/relaxng/"$$name"_"$$xno" \
-		       res.$$name;\
-	          diff $(srcdir)/result/relaxng/"$$name"_"$$xno".err \
-		       err.$$name | grep -v "error detected at";\
-		  grep Unimplemented err.$$name`; \
-		  if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
-	          rm res.$$name err.$$name ; \
-	       fi ; fi ; \
-	  done; done)
-	@echo "## Relax-NG streaming regression tests"
-	-@(for i in $(srcdir)/test/relaxng/*.rng ; do \
-	  name=`basename $$i | sed 's+\.rng++'`; \
-	  for j in $(srcdir)/test/relaxng/"$$name"_*.xml ; do \
-	      if [ -f $$j ] ; then \
-	      xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
-	      if [ ! -f $(srcdir)/result/relaxng/"$$name"_"$$xno" ]; \
-	      then \
-		  echo New test file "$$name"_"$$xno" ; \
-		  $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \
-		    > $(srcdir)/result/relaxng/"$$name"_"$$xno" \
-		    2> $(srcdir)/result/relaxng/"$$name"_"$$xno".err; \
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      else \
-	          log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --stream --relaxng $$i $$j \
-		    > res.$$name 2> err.$$name;\
-	          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	          diff $(srcdir)/result/relaxng/"$$name"_"$$xno" res.$$name;\
-		  if [ "$$name" != "tutor10_1" -a "$$name" != "tutor10_2" -a "$$name" != "tutor3_2" -a "$$name" != "307377" -a "$$name" != "tutor8_2" ] ; then \
-		      diff $(srcdir)/result/relaxng/"$$name"_"$$xno".err \
-			   err.$$name | grep -v "error detected at";\
-		  fi ; grep Unimplemented err.$$name`; \
-	          if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
-	          rm res.$$name err.$$name ; \
-	       fi ; fi ; \
-	  done; done)
-
 Schematrontests: xmllint$(EXEEXT)
 	@(echo > .memdump)
 	@echo "## Schematron regression tests"
@@ -1174,34 +365,6 @@
 	  fi)
 	@(if [ -x $(PYTHON) -a -d xstc ] ; then cd xstc ; $(MAKE) CHECKER="$(CHECKER)" pytests ; fi)
 
-Patterntests: xmllint$(EXEEXT)
-	@(echo > .memdump)
-	@echo "## Pattern regression tests"
-	-@(for i in $(srcdir)/test/pattern/*.pat ; do \
-	  name=`basename $$i .pat`; \
-	  if [ -f $(srcdir)/test/pattern/$$name.xml ] ; then \
-	  if [ ! -f $(srcdir)/result/pattern/$$name ] ; then \
-	      rm -f result.$$name ; \
-	      echo New test file $$name ; \
-	      for pat in `cat $$i` ; do \
-	      $(CHECKER) $(top_builddir)/xmllint --walker --pattern $$pat $(srcdir)/test/pattern/$$name.xml >> $(srcdir)/result/pattern/$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      done ;\
-	  else \
-	      rm -f result.$$name ; \
-	      lst=`cat $$i` ; \
-	      log=`for pat in $$lst ; do $(CHECKER) $(top_builddir)/xmllint --walker --pattern $$pat $(srcdir)/test/pattern/$$name.xml 2>&1 >> result.$$name ; \
-	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-	      done ;\
-	      diff $(srcdir)/result/pattern/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-	      rm result.$$name ; \
-	  fi ; fi ; done ;)
-
-ModuleTests: testModule$(EXEEXT) testdso.la
-	@echo "## Module tests"
-	@(./testModule$(EXEEXT))
-
 cleanup:
 	-@(find . -name .\#\* -exec rm {} \;)
 	-@(find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \;)
@@ -1226,37 +389,20 @@
 rpm: cleanup cleantar
 	@(unset CDPATH ; $(MAKE) dist-source dist && rpmbuild -ta $(distdir).tar.gz)
 
-## We create xml2Conf.sh here and not from configure because we want
-## to get the paths expanded correctly.  Macros like srcdir are given
-## the value NONE in configure if the user doesn't specify them (this
-## is an autoconf feature, not a bug).
-
-xml2Conf.sh: xml2Conf.sh.in Makefile
-## Use sed and then mv to avoid problems if the user interrupts.
-	sed -e 's?\@XML_LIBDIR\@?$(XML_LIBDIR)?g' \
-	    -e 's?\@XML_INCLUDEDIR\@?$(XML_INCLUDEDIR)?g' \
-	    -e 's?\@VERSION\@?$(VERSION)?g' \
-	    -e 's?\@XML_LIBS\@?$(XML_LIBS)?g' \
-	    -e 's?\@XML_PRIVATE_LIBS\@?$(XML_PRIVATE_LIBS)?g' \
-	       < $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \
-	&& mv xml2Conf.tmp xml2Conf.sh
-
-CLEANFILES = runxmlconf.log test.out xml2Conf.sh *.gcda *.gcno *.res
+CLEANFILES = runxmlconf.log test.out *.gcda *.gcno *.res
 DISTCLEANFILES = COPYING missing.lst
 
-confexecdir=$(libdir)
-confexec_DATA = xml2Conf.sh
-EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml2.spec \
+EXTRA_DIST = xml2-config.in libxml.spec.in libxml2.spec \
              libxml.m4 Copyright check-xml-test-suite.py gentest.py \
 	     check-relaxng-test-suite.py check-relaxng-test-suite2.py \
 	     check-xsddata-test-suite.py check-xinclude-test-suite.py \
              example/Makefile.am example/gjobread.c example/gjobs.xml \
-	     $(man_MANS) libxml-2.0.pc.in libxml-2.0-uninstalled.pc.in \
+	     libxml-2.0.pc.in libxml-2.0-uninstalled.pc.in \
 	     libxml2-config.cmake.in autogen.sh \
 	     trionan.c trionan.h triostr.c triostr.h trio.c trio.h \
 	     triop.h triodef.h libxml.h xzlib.h buf.h \
 	     enc.h save.h genUnicode.py TODO_SCHEMAS \
-	     dbgen.pl dbgenattr.pl regressions.py regressions.xml \
+	     dbgen.pl dbgenattr.pl \
 	     README.tests Makefile.tests libxml2.syms timsort.h \
 	     README.zOS README.md \
 	     CMakeLists.txt config.h.cmake.in libxml2-config.cmake.cmake.in
@@ -1271,27 +417,8 @@
 #
 # Install the tests program sources as examples 
 #
-EXAMPLES_DIR=$(docdir)/examples
-
-install-data-local: 
-	$(MKDIR_P) $(DESTDIR)$(docdir)
-	-$(INSTALL) -m 0644 $(srcdir)/Copyright $(DESTDIR)$(docdir)
-	$(MKDIR_P) $(DESTDIR)$(EXAMPLES_DIR)
-	-$(INSTALL) -m 0644 $(srcdir)/xmllint.c $(DESTDIR)$(EXAMPLES_DIR)
-	-$(INSTALL) -m 0644 $(srcdir)/testSAX.c $(DESTDIR)$(EXAMPLES_DIR)
-	-$(INSTALL) -m 0644 $(srcdir)/testHTML.c $(DESTDIR)$(EXAMPLES_DIR)
-	-$(INSTALL) -m 0644 $(srcdir)/testXPath.c $(DESTDIR)$(EXAMPLES_DIR)
-	@echo "If the documentation is installed, please also look at html/examples for more." > $(DESTDIR)$(EXAMPLES_DIR)/README
-
-uninstall-local:
-	rm -f $(DESTDIR)$(EXAMPLES_DIR)/README
-	rm -f $(DESTDIR)$(EXAMPLES_DIR)/testXPath.c
-	rm -f $(DESTDIR)$(EXAMPLES_DIR)/testHTML.c
-	rm -f $(DESTDIR)$(EXAMPLES_DIR)/testSAX.c
-	rm -f $(DESTDIR)$(EXAMPLES_DIR)/xmllint.c
-	rm -rf $(DESTDIR)$(EXAMPLES_DIR)
-	rm -f $(DESTDIR)$(docdir)/Copyright
-	rm -rf $(DESTDIR)$(docdir)
+examplesdir = $(docdir)/examples
+examples_DATA = xmllint.c
 
 tst: tst.c
 	$(CC) $(CFLAGS) -Iinclude -o tst tst.c .libs/libxml2.a -lpthread -lm -lz -llzma
diff --git a/src/SAX2.c b/src/SAX2.c
index 9a093bc..6180f00 100644
--- a/src/SAX2.c
+++ b/src/SAX2.c
@@ -1034,7 +1034,7 @@
     }
 }
 
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 /**
  * xmlNsErrMsg:
  * @ctxt:  an XML parser context
@@ -2159,7 +2159,7 @@
 	     *
 	     * Open issue: normalization of the value.
 	     */
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef LIBXML_VALID_ENABLED
 	    if (xmlValidateNCName(content, 1) != 0) {
 	        xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
@@ -2928,6 +2928,9 @@
 /**
  * xmlDefaultSAXHandlerInit:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Initialize the default SAX2 handler
  */
 void
@@ -2986,6 +2989,9 @@
 /**
  * htmlDefaultSAXHandlerInit:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Initialize the default SAX handler
  */
 void
@@ -2995,61 +3001,3 @@
 }
 
 #endif /* LIBXML_HTML_ENABLED */
-
-#ifdef LIBXML_DOCB_ENABLED
-
-/**
- * xmlSAX2InitDocbDefaultSAXHandler:
- * @hdlr:  the SAX handler
- *
- * Initialize the default DocBook SAX2 handler
- */
-void
-xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr)
-{
-    if ((hdlr == NULL) || (hdlr->initialized != 0))
-	return;
-
-    hdlr->internalSubset = xmlSAX2InternalSubset;
-    hdlr->externalSubset = NULL;
-    hdlr->isStandalone = xmlSAX2IsStandalone;
-    hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
-    hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
-    hdlr->resolveEntity = xmlSAX2ResolveEntity;
-    hdlr->getEntity = xmlSAX2GetEntity;
-    hdlr->getParameterEntity = NULL;
-    hdlr->entityDecl = xmlSAX2EntityDecl;
-    hdlr->attributeDecl = NULL;
-    hdlr->elementDecl = NULL;
-    hdlr->notationDecl = NULL;
-    hdlr->unparsedEntityDecl = NULL;
-    hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
-    hdlr->startDocument = xmlSAX2StartDocument;
-    hdlr->endDocument = xmlSAX2EndDocument;
-    hdlr->startElement = xmlSAX2StartElement;
-    hdlr->endElement = xmlSAX2EndElement;
-    hdlr->reference = xmlSAX2Reference;
-    hdlr->characters = xmlSAX2Characters;
-    hdlr->cdataBlock = NULL;
-    hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
-    hdlr->processingInstruction = NULL;
-    hdlr->comment = xmlSAX2Comment;
-    hdlr->warning = xmlParserWarning;
-    hdlr->error = xmlParserError;
-    hdlr->fatalError = xmlParserError;
-
-    hdlr->initialized = 1;
-}
-
-/**
- * docbDefaultSAXHandlerInit:
- *
- * Initialize the default SAX handler
- */
-void
-docbDefaultSAXHandlerInit(void)
-{
-    xmlSAX2InitDocbDefaultSAXHandler((xmlSAXHandlerPtr) &docbDefaultSAXHandler);
-}
-
-#endif /* LIBXML_DOCB_ENABLED */
diff --git a/src/acinclude.m4 b/src/acinclude.m4
deleted file mode 100644
index 7ad8630..0000000
--- a/src/acinclude.m4
+++ /dev/null
@@ -1,28 +0,0 @@
-dnl Like AC_TRY_EVAL but also errors out if the compiler generates
-dnl _any_ output. Some compilers might issue warnings which we want
-dnl to catch.
-AC_DEFUN([AC_TRY_EVAL2],
-[{ (eval echo configure:__oline__: \"[$]$1\") 1>&AS_MESSAGE_LOG_FD; dnl
-(eval [$]$1) 2>&AS_MESSAGE_LOG_FD; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }])
-
-dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL
-AC_DEFUN([AC_TRY_COMPILE2],
-[cat > conftest.$ac_ext <<EOF
-[#]line __oline__ "configure"
-#include "confdefs.h"
-[$1]
-int main(void) {
-[$2]
-; return 0; }
-EOF
-if AC_TRY_EVAL2(ac_compile); then
-  ifelse([$3], , :, [rm -rf conftest*
-  $3])
-else
-  echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
-  cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
-ifelse([$4], , , [  rm -rf conftest*
-  $4
-])dnl
-fi
-rm -f conftest*])
diff --git a/src/aclocal.m4 b/src/aclocal.m4
index d6ebff5..c4525a6 100644
--- a/src/aclocal.m4
+++ b/src/aclocal.m4
@@ -1122,6 +1122,350 @@
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------
+# Adds support for distributing Python modules and packages.  To
+# install modules, copy them to $(pythondir), using the python_PYTHON
+# automake variable.  To install a package with the same name as the
+# automake package, install to $(pkgpythondir), or use the
+# pkgpython_PYTHON automake variable.
+#
+# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
+# locations to install python extension modules (shared libraries).
+# Another macro is required to find the appropriate flags to compile
+# extension modules.
+#
+# If your package is configured with a different prefix to python,
+# users will have to add the install directory to the PYTHONPATH
+# environment variable, or create a .pth file (see the python
+# documentation for details).
+#
+# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
+# cause an error if the version of python installed on the system
+# doesn't meet the requirement.  MINIMUM-VERSION should consist of
+# numbers and dots only.
+AC_DEFUN([AM_PATH_PYTHON],
+ [
+  dnl Find a Python interpreter.  Python versions prior to 2.0 are not
+  dnl supported. (2.0 was released on October 16, 2000).
+  m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
+[python python2 python3 dnl
+ python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
+ python3.2 python3.1 python3.0 dnl
+ python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
+ python2.0])
+
+  AC_ARG_VAR([PYTHON], [the Python interpreter])
+
+  m4_if([$1],[],[
+    dnl No version check is needed.
+    # Find any Python interpreter.
+    if test -z "$PYTHON"; then
+      AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
+    fi
+    am_display_PYTHON=python
+  ], [
+    dnl A version check is needed.
+    if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      AC_MSG_CHECKING([whether $PYTHON version is >= $1])
+      AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
+			      [AC_MSG_RESULT([yes])],
+			      [AC_MSG_RESULT([no])
+			       AC_MSG_ERROR([Python interpreter is too old])])
+      am_display_PYTHON=$PYTHON
+    else
+      # Otherwise, try each interpreter until we find one that satisfies
+      # VERSION.
+      AC_CACHE_CHECK([for a Python interpreter with version >= $1],
+	[am_cv_pathless_PYTHON],[
+	for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
+	  test "$am_cv_pathless_PYTHON" = none && break
+	  AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
+	done])
+      # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
+      if test "$am_cv_pathless_PYTHON" = none; then
+	PYTHON=:
+      else
+        AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      fi
+      am_display_PYTHON=$am_cv_pathless_PYTHON
+    fi
+  ])
+
+  if test "$PYTHON" = :; then
+    dnl Run any user-specified action, or abort.
+    m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+  else
+
+  dnl Query Python for its version number.  Although site.py simply uses
+  dnl sys.version[:3], printing that failed with Python 3.10, since the
+  dnl trailing zero was eliminated. So now we output just the major
+  dnl and minor version numbers, as numbers. Apparently the tertiary
+  dnl version is not of interest.
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
+    [am_cv_python_version=`$PYTHON -c "import sys; print ('%u.%u' % sys.version_info[[:2]])"`])
+  AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
+
+  dnl At times, e.g., when building shared libraries, you may want
+  dnl to know which OS platform Python thinks this is.
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
+    [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
+  AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
+
+  dnl emacs-page
+  dnl If --with-python-sys-prefix is given, use the values of sys.prefix
+  dnl and sys.exec_prefix for the corresponding values of PYTHON_PREFIX
+  dnl and PYTHON_EXEC_PREFIX. Otherwise, use the GNU ${prefix} and
+  dnl ${exec_prefix} variables.
+  dnl
+  dnl The two are made distinct variables so they can be overridden if
+  dnl need be, although general consensus is that you shouldn't need
+  dnl this separation.
+  dnl
+  dnl Also allow directly setting the prefixes via configure options,
+  dnl overriding any default.
+  dnl
+  if test "x$prefix" = xNONE; then
+    am__usable_prefix=$ac_default_prefix
+  else
+    am__usable_prefix=$prefix
+  fi
+
+  # Allow user to request using sys.* values from Python,
+  # instead of the GNU $prefix values.
+  AC_ARG_WITH([python-sys-prefix],
+  [AS_HELP_STRING([--with-python-sys-prefix],
+                  [use Python's sys.prefix and sys.exec_prefix values])],
+  [am_use_python_sys=:],
+  [am_use_python_sys=false])
+
+  # Allow user to override whatever the default Python prefix is.
+  AC_ARG_WITH([python_prefix],
+  [AS_HELP_STRING([--with-python_prefix],
+                  [override the default PYTHON_PREFIX])],
+  [am_python_prefix_subst=$withval
+   am_cv_python_prefix=$withval
+   AC_MSG_CHECKING([for explicit $am_display_PYTHON prefix])
+   AC_MSG_RESULT([$am_cv_python_prefix])],
+  [
+   if $am_use_python_sys; then
+     # using python sys.prefix value, not GNU
+     AC_CACHE_CHECK([for python default $am_display_PYTHON prefix],
+     [am_cv_python_prefix],
+     [am_cv_python_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`])
+
+     dnl If sys.prefix is a subdir of $prefix, replace the literal value of
+     dnl $prefix with a variable reference so it can be overridden.
+     case $am_cv_python_prefix in
+     $am__usable_prefix*)
+       am__strip_prefix=`echo "$am__usable_prefix" | sed 's|.|.|g'`
+       am_python_prefix_subst=`echo "$am_cv_python_prefix" | sed "s,^$am__strip_prefix,\\${prefix},"`
+       ;;
+     *)
+       am_python_prefix_subst=$am_cv_python_prefix
+       ;;
+     esac
+   else # using GNU prefix value, not python sys.prefix
+     am_python_prefix_subst='${prefix}'
+     am_python_prefix=$am_python_prefix_subst
+     AC_MSG_CHECKING([for GNU default $am_display_PYTHON prefix])
+     AC_MSG_RESULT([$am_python_prefix])
+   fi])
+  # Substituting python_prefix_subst value.
+  AC_SUBST([PYTHON_PREFIX], [$am_python_prefix_subst])
+
+  # emacs-page Now do it all over again for Python exec_prefix, but with yet
+  # another conditional: fall back to regular prefix if that was specified.
+  AC_ARG_WITH([python_exec_prefix],
+  [AS_HELP_STRING([--with-python_exec_prefix],
+                  [override the default PYTHON_EXEC_PREFIX])],
+  [am_python_exec_prefix_subst=$withval
+   am_cv_python_exec_prefix=$withval
+   AC_MSG_CHECKING([for explicit $am_display_PYTHON exec_prefix])
+   AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+  [
+   # no explicit --with-python_exec_prefix, but if
+   # --with-python_prefix was given, use its value for python_exec_prefix too.
+   AS_IF([test -n "$with_python_prefix"],
+   [am_python_exec_prefix_subst=$with_python_prefix
+    am_cv_python_exec_prefix=$with_python_prefix
+    AC_MSG_CHECKING([for python_prefix-given $am_display_PYTHON exec_prefix])
+    AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+   [
+    # Set am__usable_exec_prefix whether using GNU or Python values,
+    # since we use that variable for pyexecdir.
+    if test "x$exec_prefix" = xNONE; then
+      am__usable_exec_prefix=$am__usable_prefix
+    else
+      am__usable_exec_prefix=$exec_prefix
+    fi
+    #
+    if $am_use_python_sys; then # using python sys.exec_prefix, not GNU
+      AC_CACHE_CHECK([for python default $am_display_PYTHON exec_prefix],
+      [am_cv_python_exec_prefix],
+      [am_cv_python_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`])
+      dnl If sys.exec_prefix is a subdir of $exec_prefix, replace the
+      dnl literal value of $exec_prefix with a variable reference so it can
+      dnl be overridden.
+      case $am_cv_python_exec_prefix in
+      $am__usable_exec_prefix*)
+        am__strip_prefix=`echo "$am__usable_exec_prefix" | sed 's|.|.|g'`
+        am_python_exec_prefix_subst=`echo "$am_cv_python_exec_prefix" | sed "s,^$am__strip_prefix,\\${exec_prefix},"`
+        ;;
+      *)
+        am_python_exec_prefix_subst=$am_cv_python_exec_prefix
+        ;;
+     esac
+   else # using GNU $exec_prefix, not python sys.exec_prefix
+     am_python_exec_prefix_subst='${exec_prefix}'
+     am_python_exec_prefix=$am_python_exec_prefix_subst
+     AC_MSG_CHECKING([for GNU default $am_display_PYTHON exec_prefix])
+     AC_MSG_RESULT([$am_python_exec_prefix])
+   fi])])
+  # Substituting python_exec_prefix_subst.
+  AC_SUBST([PYTHON_EXEC_PREFIX], [$am_python_exec_prefix_subst])
+
+  # Factor out some code duplication into this shell variable.
+  am_python_setup_sysconfig="\
+import sys
+# Prefer sysconfig over distutils.sysconfig, for better compatibility
+# with python 3.x.  See automake bug#10227.
+try:
+    import sysconfig
+except ImportError:
+    can_use_sysconfig = 0
+else:
+    can_use_sysconfig = 1
+# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    from platform import python_implementation
+    if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7':
+        can_use_sysconfig = 0
+except ImportError:
+    pass"
+
+  dnl emacs-page Set up 4 directories:
+
+  dnl 1. pythondir: where to install python scripts.  This is the
+  dnl    site-packages directory, not the python standard library
+  dnl    directory like in previous automake betas.  This behavior
+  dnl    is more consistent with lispdir.m4 for example.
+  dnl Query distutils for this directory.
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON script directory (pythondir)],
+  [am_cv_python_pythondir],
+  [if test "x$am_cv_python_prefix" = x; then
+     am_py_prefix=$am__usable_prefix
+   else
+     am_py_prefix=$am_cv_python_prefix
+   fi
+   am_cv_python_pythondir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+  sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+else:
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
+   #
+   case $am_cv_python_pythondir in
+   $am_py_prefix*)
+     am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+     am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,\\${PYTHON_PREFIX},"`
+     ;;
+   *)
+     case $am_py_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pythondir="\${PYTHON_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
+     esac
+     ;;
+   esac
+  ])
+  AC_SUBST([pythondir], [$am_cv_python_pythondir])
+
+  dnl 2. pkgpythondir: $PACKAGE directory under pythondir.  Was
+  dnl    PYTHON_SITE_PACKAGE in previous betas, but this naming is
+  dnl    more consistent with the rest of automake.
+  dnl
+  AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
+
+  dnl 3. pyexecdir: directory for installing python extension modules
+  dnl    (shared libraries).
+  dnl Query distutils for this directory.
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory (pyexecdir)],
+  [am_cv_python_pyexecdir],
+  [if test "x$am_cv_python_exec_prefix" = x; then
+     am_py_exec_prefix=$am__usable_exec_prefix
+   else
+     am_py_exec_prefix=$am_cv_python_exec_prefix
+   fi
+   am_cv_python_pyexecdir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+  sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_exec_prefix'})
+else:
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')
+sys.stdout.write(sitedir)"`
+   #
+   case $am_cv_python_pyexecdir in
+   $am_py_exec_prefix*)
+     am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+     am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,\\${PYTHON_EXEC_PREFIX},"`
+     ;;
+   *)
+     case $am_py_exec_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pyexecdir="\${PYTHON_EXEC_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
+     esac
+     ;;
+   esac
+  ])
+  AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
+
+  dnl 4. pkgpyexecdir: $(pyexecdir)/$(PACKAGE)
+  dnl
+  AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+  dnl Run any user-specified action.
+  $2
+  fi
+])
+
+
+# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-FALSE otherwise.
+# This test uses sys.hexversion instead of the string equivalent (first
+# word of sys.version), in order to cope with versions such as 2.2c1.
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
+AC_DEFUN([AM_PYTHON_CHECK_VERSION],
+ [prog="import sys
+# split strings by '.' and convert to numeric.  Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
+sys.exit(sys.hexversion < minverhex)"
+  AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
+
 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -1460,9 +1804,9 @@
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
+m4_include([m4/ac_try_compile2.m4])
 m4_include([m4/libtool.m4])
 m4_include([m4/ltoptions.m4])
 m4_include([m4/ltsugar.m4])
 m4_include([m4/ltversion.m4])
 m4_include([m4/lt~obsolete.m4])
-m4_include([acinclude.m4])
diff --git a/src/check-relaxng-test-suite.py b/src/check-relaxng-test-suite.py
index f4a5a69..aa89cde 100755
--- a/src/check-relaxng-test-suite.py
+++ b/src/check-relaxng-test-suite.py
@@ -2,8 +2,12 @@
 import sys
 import time
 import os
-import string
-import StringIO
+try:
+    # Python 2
+    from StringIO import StringIO
+except ImportError:
+    # Python 3
+    from io import StringIO
 sys.path.insert(0, "python")
 import libxml2
 
@@ -45,10 +49,10 @@
 def resolver(URL, ID, ctxt):
     global resources
 
-    if string.find(URL, '#') != -1:
-        URL = URL[0:string.find(URL, '#')]
-    if resources.has_key(URL):
-        return(StringIO.StringIO(resources[URL]))
+    if URL.find('#') != -1:
+        URL = URL[0:URL.find('#')]
+    if URL in resources:
+        return(StringIO(resources[URL]))
     log.write("Resolver failure: asked %s\n" % (URL))
     log.write("resources: %s\n" % (resources))
     return None
@@ -63,7 +67,7 @@
 #    res = libxml2.parseFile(RES)
 #except:
 #    log.write("Could not parse %s" % (RES))
-    
+
 #
 # handle a valid instance
 #
@@ -76,33 +80,33 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nFailed to parse correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
-	return
+        nb_instances_failed = nb_instances_failed + 1
+        return
 
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
+        ret = doc.relaxNGValidateDoc(ctxt)
     except:
         ret = -1
     if ret != 0:
         log.write("\nFailed to validate correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
     doc.freeDoc()
 
 #
@@ -117,32 +121,32 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	return
+        return
 
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
+        ret = doc.relaxNGValidateDoc(ctxt)
     except:
         ret = -1
     if ret == 0:
         log.write("\nFailed to detect validation problem in instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
     doc.freeDoc()
 
 #
@@ -157,23 +161,23 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
-    if rngs == None:
+    if rngs is None:
         log.write("\nFailed to compile correct schema:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-	nb_schemas_success = nb_schemas_success + 1
+        nb_schemas_success = nb_schemas_success + 1
     return rngs
-        
+
 def handle_incorrect(node):
     global log
     global nb_schemas_success
@@ -183,24 +187,24 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
     if rngs != None:
         log.write("\nFailed to detect schema error in:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-#	log.write("\nSuccess detecting schema error in:\n-----\n")
-#	log.write(schema)
-#	log.write("\n-----\n")
-	nb_schemas_success = nb_schemas_success + 1
+#        log.write("\nSuccess detecting schema error in:\n-----\n")
+#        log.write(schema)
+#        log.write("\n-----\n")
+        nb_schemas_success = nb_schemas_success + 1
     return None
 
 #
@@ -210,14 +214,14 @@
     global resources
 
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -226,8 +230,8 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    res = res + child.serialize()
-	child = child.next
+            res = res + child.serialize()
+        child = child.next
     resources[name] = res
 
 #
@@ -235,14 +239,14 @@
 #
 def handle_dir(node, dir):
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -268,7 +272,7 @@
               nb_schemas_tests, node.lineNo(), sections))
     resources = {}
     if debug:
-        print "test %d line %d" % (nb_schemas_tests, node.lineNo())
+        print("test %d line %d" % (nb_schemas_tests, node.lineNo()))
 
     dirs = node.xpathEval('dir')
     for dir in dirs:
@@ -280,27 +284,27 @@
     tsts = node.xpathEval('incorrect')
     if tsts != []:
         if len(tsts) != 1:
-	    print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
-	schema = handle_incorrect(tsts[0])
+            print("warning test line %d has more than one <incorrect> example" %(node.lineNo()))
+        schema = handle_incorrect(tsts[0])
     else:
         tsts = node.xpathEval('correct')
-	if tsts != []:
-	    if len(tsts) != 1:
-		print "warning test line %d has more than one <correct> example"% (node.lineNo())
-	    schema = handle_correct(tsts[0])
-	else:
-	    print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
+        if tsts != []:
+            if len(tsts) != 1:
+                print("warning test line %d has more than one <correct> example"% (node.lineNo()))
+            schema = handle_correct(tsts[0])
+        else:
+            print("warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo()))
 
     nb_schemas_tests = nb_schemas_tests + 1;
-    
+
     valids = node.xpathEval('valid')
     invalids = node.xpathEval('invalid')
     nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
     if schema != None:
         for valid in valids:
-	    handle_valid(valid, schema)
+            handle_valid(valid, schema)
         for invalid in invalids:
-	    handle_invalid(invalid, schema)
+            handle_invalid(invalid, schema)
 
 
 #
@@ -311,53 +315,53 @@
     global nb_instances_tests, nb_instances_success, nb_instances_failed
     global quiet
     if level >= 1:
-	old_schemas_tests = nb_schemas_tests
-	old_schemas_success = nb_schemas_success
-	old_schemas_failed = nb_schemas_failed
-	old_instances_tests = nb_instances_tests
-	old_instances_success = nb_instances_success
-	old_instances_failed = nb_instances_failed
+        old_schemas_tests = nb_schemas_tests
+        old_schemas_success = nb_schemas_success
+        old_schemas_failed = nb_schemas_failed
+        old_instances_tests = nb_instances_tests
+        old_instances_success = nb_instances_success
+        old_instances_failed = nb_instances_failed
 
     docs = node.xpathEval('documentation')
     authors = node.xpathEval('author')
     if docs != []:
         msg = ""
         for doc in docs:
-	    msg = msg + doc.content + " "
-	if authors != []:
-	    msg = msg + "written by "
-	    for author in authors:
-	        msg = msg + author.content + " "
-	if quiet == 0:
-	    print msg
+            msg = msg + doc.content + " "
+        if authors != []:
+            msg = msg + "written by "
+            for author in authors:
+                msg = msg + author.content + " "
+        if quiet == 0:
+            print(msg)
     sections = node.xpathEval('section')
     if sections != [] and level <= 0:
         msg = ""
         for section in sections:
-	    msg = msg + section.content + " "
-	if quiet == 0:
-	    print "Tests for section %s" % (msg)
+            msg = msg + section.content + " "
+        if quiet == 0:
+            print("Tests for section %s" % (msg))
     for test in node.xpathEval('testCase'):
         handle_testCase(test)
     for test in node.xpathEval('testSuite'):
         handle_testSuite(test, level + 1)
-	        
+
 
     if verbose and level >= 1 and sections != []:
         msg = ""
         for section in sections:
-	    msg = msg + section.content + " "
-        print "Result of tests for section %s" % (msg)
+            msg = msg + section.content + " "
+        print("Result of tests for section %s" % (msg))
         if nb_schemas_tests != old_schemas_tests:
-	    print "found %d test schemas: %d success %d failures" % (
-		  nb_schemas_tests - old_schemas_tests,
-		  nb_schemas_success - old_schemas_success,
-		  nb_schemas_failed - old_schemas_failed)
-	if nb_instances_tests != old_instances_tests:
-	    print "found %d test instances: %d success %d failures" % (
-		  nb_instances_tests - old_instances_tests,
-		  nb_instances_success - old_instances_success,
-		  nb_instances_failed - old_instances_failed)
+            print("found %d test schemas: %d success %d failures" % (
+                  nb_schemas_tests - old_schemas_tests,
+                  nb_schemas_success - old_schemas_success,
+                  nb_schemas_failed - old_schemas_failed))
+        if nb_instances_tests != old_instances_tests:
+            print("found %d test instances: %d success %d failures" % (
+                  nb_instances_tests - old_instances_tests,
+                  nb_instances_success - old_instances_success,
+                  nb_instances_failed - old_instances_failed))
 #
 # Parse the conf file
 #
@@ -366,20 +370,20 @@
 libxml2.setEntityLoader(resolver)
 root = testsuite.getRootElement()
 if root.name != 'testSuite':
-    print "%s doesn't start with a testSuite element, aborting" % (CONF)
+    print("%s doesn't start with a testSuite element, aborting" % (CONF))
     sys.exit(1)
 if quiet == 0:
-    print "Running Relax NG testsuite"
+    print("Running Relax NG testsuite")
 handle_testSuite(root)
 
 if quiet == 0:
-    print "\nTOTAL:\n"
+    print("\nTOTAL:\n")
 if quiet == 0 or nb_schemas_failed != 0:
-    print "found %d test schemas: %d success %d failures" % (
-      nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
+    print("found %d test schemas: %d success %d failures" % (
+      nb_schemas_tests, nb_schemas_success, nb_schemas_failed))
 if quiet == 0 or nb_instances_failed != 0:
-    print "found %d test instances: %d success %d failures" % (
-      nb_instances_tests, nb_instances_success, nb_instances_failed)
+    print("found %d test instances: %d success %d failures" % (
+      nb_instances_tests, nb_instances_success, nb_instances_failed))
 
 testsuite.freeDoc()
 
@@ -388,7 +392,7 @@
 libxml2.cleanupParser()
 if libxml2.debugMemory(1) == 0:
     if quiet == 0:
-	print "OK"
+        print("OK")
 else:
-    print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
     libxml2.dumpMemory()
diff --git a/src/check-relaxng-test-suite2.py b/src/check-relaxng-test-suite2.py
index 8618db7..5bba5a4 100755
--- a/src/check-relaxng-test-suite2.py
+++ b/src/check-relaxng-test-suite2.py
@@ -2,8 +2,12 @@
 import sys
 import time
 import os
-import string
-import StringIO
+try:
+    # Python 2
+    from StringIO import StringIO
+except ImportError:
+    # Python 3
+    from io import StringIO
 sys.path.insert(0, "python")
 import libxml2
 
@@ -34,8 +38,8 @@
 def resolver(URL, ID, ctxt):
     global resources
 
-    if resources.has_key(URL):
-        return(StringIO.StringIO(resources[URL]))
+    if URL in resources:
+        return(StringIO(resources[URL]))
     log.write("Resolver failure: asked %s\n" % (URL))
     log.write("resources: %s\n" % (resources))
     return None
@@ -50,7 +54,7 @@
 #    res = libxml2.parseFile(RES)
 #except:
 #    log.write("Could not parse %s" % (RES))
-    
+
 #
 # handle a valid instance
 #
@@ -60,49 +64,49 @@
     global nb_instances_failed
 
     instance = node.prop("dtd")
-    if instance == None:
+    if instance is None:
         instance = ""
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
 #    mem = libxml2.debugMemory(1);
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nFailed to parse correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
-	return
+        nb_instances_failed = nb_instances_failed + 1
+        return
 
     if debug:
-        print "instance line %d" % (node.lineNo())
-       
+        print("instance line %d" % (node.lineNo()))
+
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
-	del ctxt
+        ret = doc.relaxNGValidateDoc(ctxt)
+        del ctxt
     except:
         ret = -1
 
     doc.freeDoc()
 #    if mem != libxml2.debugMemory(1):
-#	print "validating instance %d line %d leaks" % (
-#		  nb_instances_tests, node.lineNo())
+#        print("validating instance %d line %d leaks" % (
+#                  nb_instances_tests, node.lineNo()))
 
     if ret != 0:
         log.write("\nFailed to validate correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
 
 #
 # handle an invalid instance
@@ -113,34 +117,34 @@
     global nb_instances_failed
 
     instance = node.prop("dtd")
-    if instance == None:
+    if instance is None:
         instance = ""
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
 #    mem = libxml2.debugMemory(1);
 
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	return
+        return
 
     if debug:
-        print "instance line %d" % (node.lineNo())
-       
+        print("instance line %d" % (node.lineNo()))
+
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
-	del ctxt
+        ret = doc.relaxNGValidateDoc(ctxt)
+        del ctxt
 
     except:
         ret = -1
@@ -148,16 +152,16 @@
     doc.freeDoc()
 #    mem2 = libxml2.debugMemory(1)
 #    if mem != mem2:
-#	print "validating instance %d line %d leaks %d bytes" % (
-#		  nb_instances_tests, node.lineNo(), mem2 - mem)
-    
+#        print("validating instance %d line %d leaks %d bytes" % (
+#                  nb_instances_tests, node.lineNo(), mem2 - mem))
+
     if ret == 0:
         log.write("\nFailed to detect validation problem in instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
 
 #
 # handle an incorrect test
@@ -171,23 +175,23 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
-    if rngs == None:
+    if rngs is None:
         log.write("\nFailed to compile correct schema:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-	nb_schemas_success = nb_schemas_success + 1
+        nb_schemas_success = nb_schemas_success + 1
     return rngs
-        
+
 def handle_incorrect(node):
     global log
     global nb_schemas_success
@@ -197,24 +201,24 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
     if rngs != None:
         log.write("\nFailed to detect schema error in:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-#	log.write("\nSuccess detecting schema error in:\n-----\n")
-#	log.write(schema)
-#	log.write("\n-----\n")
-	nb_schemas_success = nb_schemas_success + 1
+#        log.write("\nSuccess detecting schema error in:\n-----\n")
+#        log.write(schema)
+#        log.write("\n-----\n")
+        nb_schemas_success = nb_schemas_success + 1
     return None
 
 #
@@ -224,14 +228,14 @@
     global resources
 
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -240,8 +244,8 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    res = res + child.serialize()
-	child = child.next
+            res = res + child.serialize()
+        child = child.next
     resources[name] = res
 
 #
@@ -249,14 +253,14 @@
 #
 def handle_dir(node, dir):
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -282,7 +286,7 @@
               nb_schemas_tests, node.lineNo(), sections))
     resources = {}
     if debug:
-        print "test %d line %d" % (nb_schemas_tests, node.lineNo())
+        print("test %d line %d" % (nb_schemas_tests, node.lineNo()))
 
     dirs = node.xpathEval('dir')
     for dir in dirs:
@@ -294,27 +298,27 @@
     tsts = node.xpathEval('incorrect')
     if tsts != []:
         if len(tsts) != 1:
-	    print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
-	schema = handle_incorrect(tsts[0])
+            print("warning test line %d has more than one <incorrect> example" %(node.lineNo()))
+        schema = handle_incorrect(tsts[0])
     else:
         tsts = node.xpathEval('correct')
-	if tsts != []:
-	    if len(tsts) != 1:
-		print "warning test line %d has more than one <correct> example"% (node.lineNo())
-	    schema = handle_correct(tsts[0])
-	else:
-	    print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
+        if tsts != []:
+            if len(tsts) != 1:
+                print("warning test line %d has more than one <correct> example"% (node.lineNo()))
+            schema = handle_correct(tsts[0])
+        else:
+            print("warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo()))
 
     nb_schemas_tests = nb_schemas_tests + 1;
-    
+
     valids = node.xpathEval('valid')
     invalids = node.xpathEval('invalid')
     nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
     if schema != None:
         for valid in valids:
-	    handle_valid(valid, schema)
+            handle_valid(valid, schema)
         for invalid in invalids:
-	    handle_invalid(invalid, schema)
+            handle_invalid(invalid, schema)
 
 
 #
@@ -324,53 +328,53 @@
     global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
     global nb_instances_tests, nb_instances_success, nb_instances_failed
     if level >= 1:
-	old_schemas_tests = nb_schemas_tests
-	old_schemas_success = nb_schemas_success
-	old_schemas_failed = nb_schemas_failed
-	old_instances_tests = nb_instances_tests
-	old_instances_success = nb_instances_success
-	old_instances_failed = nb_instances_failed
+        old_schemas_tests = nb_schemas_tests
+        old_schemas_success = nb_schemas_success
+        old_schemas_failed = nb_schemas_failed
+        old_instances_tests = nb_instances_tests
+        old_instances_success = nb_instances_success
+        old_instances_failed = nb_instances_failed
 
     docs = node.xpathEval('documentation')
     authors = node.xpathEval('author')
     if docs != []:
         msg = ""
         for doc in docs:
-	    msg = msg + doc.content + " "
-	if authors != []:
-	    msg = msg + "written by "
-	    for author in authors:
-	        msg = msg + author.content + " "
-	if quiet == 0:
-	    print msg
+            msg = msg + doc.content + " "
+        if authors != []:
+            msg = msg + "written by "
+            for author in authors:
+                msg = msg + author.content + " "
+        if quiet == 0:
+            print(msg)
     sections = node.xpathEval('section')
     if sections != [] and level <= 0:
         msg = ""
         for section in sections:
-	    msg = msg + section.content + " "
-	if quiet == 0:
-	    print "Tests for section %s" % (msg)
+            msg = msg + section.content + " "
+        if quiet == 0:
+            print("Tests for section %s" % (msg))
     for test in node.xpathEval('testCase'):
         handle_testCase(test)
     for test in node.xpathEval('testSuite'):
         handle_testSuite(test, level + 1)
-	        
+
 
     if level >= 1 and sections != []:
         msg = ""
         for section in sections:
-	    msg = msg + section.content + " "
-        print "Result of tests for section %s" % (msg)
+            msg = msg + section.content + " "
+        print("Result of tests for section %s" % (msg))
         if nb_schemas_tests != old_schemas_tests:
-	    print "found %d test schemas: %d success %d failures" % (
-		  nb_schemas_tests - old_schemas_tests,
-		  nb_schemas_success - old_schemas_success,
-		  nb_schemas_failed - old_schemas_failed)
-	if nb_instances_tests != old_instances_tests:
-	    print "found %d test instances: %d success %d failures" % (
-		  nb_instances_tests - old_instances_tests,
-		  nb_instances_success - old_instances_success,
-		  nb_instances_failed - old_instances_failed)
+            print("found %d test schemas: %d success %d failures" % (
+                  nb_schemas_tests - old_schemas_tests,
+                  nb_schemas_success - old_schemas_success,
+                  nb_schemas_failed - old_schemas_failed))
+        if nb_instances_tests != old_instances_tests:
+            print("found %d test instances: %d success %d failures" % (
+                  nb_instances_tests - old_instances_tests,
+                  nb_instances_success - old_instances_success,
+                  nb_instances_failed - old_instances_failed))
 #
 # Parse the conf file
 #
@@ -389,22 +393,22 @@
 libxml2.setEntityLoader(resolver)
 root = testsuite.getRootElement()
 if root.name != 'testSuite':
-    print "%s doesn't start with a testSuite element, aborting" % (CONF)
+    print("%s doesn't start with a testSuite element, aborting" % (CONF))
     sys.exit(1)
 if quiet == 0:
-    print "Running Relax NG testsuite"
+    print("Running Relax NG testsuite")
 handle_testSuite(root)
 
 if quiet == 0:
-    print "\nTOTAL:\n"
+    print("\nTOTAL:\n")
 if quiet == 0 or nb_schemas_failed != 0:
-    print "found %d test schemas: %d success %d failures" % (
-      nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
+    print("found %d test schemas: %d success %d failures" % (
+      nb_schemas_tests, nb_schemas_success, nb_schemas_failed))
 if quiet == 0 or nb_instances_failed != 0:
-    print "found %d test instances: %d success %d failures" % (
-      nb_instances_tests, nb_instances_success, nb_instances_failed)
+    print("found %d test instances: %d success %d failures" % (
+      nb_instances_tests, nb_instances_success, nb_instances_failed))
 
-
+log.close()
 testsuite.freeDoc()
 
 # Memory debug specific
@@ -412,7 +416,7 @@
 libxml2.cleanupParser()
 if libxml2.debugMemory(1) == 0:
     if quiet == 0:
-	print "OK"
+        print("OK")
 else:
-    print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
     libxml2.dumpMemory()
diff --git a/src/check-xinclude-test-suite.py b/src/check-xinclude-test-suite.py
index 416ea21..e803440 100755
--- a/src/check-xinclude-test-suite.py
+++ b/src/check-xinclude-test-suite.py
@@ -2,7 +2,6 @@
 import sys
 import time
 import os
-import string
 sys.path.insert(0, "python")
 import libxml2
 
@@ -31,13 +30,13 @@
     global error_nr
     global error_msg
 
-    if string.find(str, "error:") >= 0:
-	error_nr = error_nr + 1
+    if str.find("error:") >= 0:
+        error_nr = error_nr + 1
     if len(error_msg) < 300:
         if len(error_msg) == 0 or error_msg[-1] == '\n':
-	    error_msg = error_msg + "   >>" + str
-	else:
-	    error_msg = error_msg + str
+            error_msg = error_msg + "   >>" + str
+        else:
+            error_msg = error_msg + str
 
 libxml2.registerErrorHandler(errorHandler, None)
 
@@ -49,7 +48,7 @@
     error_nr = 0
     error_msg = ''
 
-    print "testXInclude(%s, %s)" % (filename, id)
+    print("testXInclude(%s, %s)" % (filename, id))
     return 1
 
 def runTest(test, basedir):
@@ -64,158 +63,158 @@
     uri = test.prop('href')
     id = test.prop('id')
     type = test.prop('type')
-    if uri == None:
-        print "Test without ID:", uri
-	return -1
-    if id == None:
-        print "Test without URI:", id
-	return -1
-    if type == None:
-        print "Test without URI:", id
-	return -1
+    if uri is None:
+        print("Test without ID:", uri)
+        return -1
+    if id is None:
+        print("Test without URI:", id)
+        return -1
+    if type is None:
+        print("Test without URI:", id)
+        return -1
     if basedir != None:
-	URI = basedir + "/" + uri
+        URI = basedir + "/" + uri
     else:
         URI = uri
     if os.access(URI, os.R_OK) == 0:
-        print "Test %s missing: base %s uri %s" % (URI, basedir, uri)
-	return -1
+        print("Test %s missing: base %s uri %s" % (URI, basedir, uri))
+        return -1
 
     expected = None
     outputfile = None
     diff = None
     if type != 'error':
-	output = test.xpathEval('string(output)')
-	if output == 'No output file.':
-	    output = None
-	if output == '':
-	    output = None
-	if output != None:
-	    if basedir != None:
-		output = basedir + "/" + output
-	    if os.access(output, os.R_OK) == 0:
-		print "Result for %s missing: %s" % (id, output)
-		output = None
-	    else:
-		try:
-		    f = open(output)
-		    expected = f.read()
-		    outputfile = output
-		except:
-		    print "Result for %s unreadable: %s" % (id, output)
+        output = test.xpathEval('string(output)')
+        if output == 'No output file.':
+            output = None
+        if output == '':
+            output = None
+        if output != None:
+            if basedir != None:
+                output = basedir + "/" + output
+            if os.access(output, os.R_OK) == 0:
+                print("Result for %s missing: %s" % (id, output))
+                output = None
+            else:
+                try:
+                    f = open(output)
+                    expected = f.read()
+                    outputfile = output
+                except:
+                    print("Result for %s unreadable: %s" % (id, output))
 
     try:
-        # print "testing %s" % (URI)
-	doc = libxml2.parseFile(URI)
+        # print("testing %s" % (URI))
+        doc = libxml2.parseFile(URI)
     except:
         doc = None
     if doc != None:
         res = doc.xincludeProcess()
-	if res >= 0 and expected != None:
-	    result = doc.serialize()
-	    if result != expected:
-	        print "Result for %s differs" % (id)
-		open("xinclude.res", "w").write(result)
-		diff = os.popen("diff %s xinclude.res" % outputfile).read()
+        if res >= 0 and expected != None:
+            result = doc.serialize()
+            if result != expected:
+                print("Result for %s differs" % (id))
+                open("xinclude.res", "w").write(result)
+                diff = os.popen("diff %s xinclude.res" % outputfile).read()
 
-	doc.freeDoc()
+        doc.freeDoc()
     else:
-        print "Failed to parse %s" % (URI)
-	res = -1
+        print("Failed to parse %s" % (URI))
+        res = -1
 
-    
+
 
     test_nr = test_nr + 1
     if type == 'success':
-	if res > 0:
-	    test_succeed = test_succeed + 1
-	elif res == 0:
-	    test_failed = test_failed + 1
-	    print "Test %s: no substitution done ???" % (id)
-	elif res < 0:
-	    test_error = test_error + 1
-	    print "Test %s: failed valid XInclude processing" % (id)
+        if res > 0:
+            test_succeed = test_succeed + 1
+        elif res == 0:
+            test_failed = test_failed + 1
+            print("Test %s: no substitution done ???" % (id))
+        elif res < 0:
+            test_error = test_error + 1
+            print("Test %s: failed valid XInclude processing" % (id))
     elif type == 'error':
-	if res > 0:
-	    test_error = test_error + 1
-	    print "Test %s: failed to detect invalid XInclude processing" % (id)
-	elif res == 0:
-	    test_failed = test_failed + 1
-	    print "Test %s: Invalid but no substitution done" % (id)
-	elif res < 0:
-	    test_succeed = test_succeed + 1
+        if res > 0:
+            test_error = test_error + 1
+            print("Test %s: failed to detect invalid XInclude processing" % (id))
+        elif res == 0:
+            test_failed = test_failed + 1
+            print("Test %s: Invalid but no substitution done" % (id))
+        elif res < 0:
+            test_succeed = test_succeed + 1
     elif type == 'optional':
-	if res > 0:
-	    test_succeed = test_succeed + 1
-	else:
-	    print "Test %s: failed optional test" % (id)
+        if res > 0:
+            test_succeed = test_succeed + 1
+        else:
+            print("Test %s: failed optional test" % (id))
 
     # Log the ontext
     if res != 1:
-	log.write("Test ID %s\n" % (id))
-	log.write("   File: %s\n" % (URI))
-	content = string.strip(test.content)
-	while content[-1] == '\n':
-	    content = content[0:-1]
-	log.write("   %s:%s\n\n" % (type, content))
-	if error_msg != '':
-	    log.write("   ----\n%s   ----\n" % (error_msg))
-	    error_msg = ''
-	log.write("\n")
+        log.write("Test ID %s\n" % (id))
+        log.write("   File: %s\n" % (URI))
+        content = test.content.strip()
+        while content[-1] == '\n':
+            content = content[0:-1]
+        log.write("   %s:%s\n\n" % (type, content))
+        if error_msg != '':
+            log.write("   ----\n%s   ----\n" % (error_msg))
+            error_msg = ''
+        log.write("\n")
     if diff != None:
         log.write("diff from test %s:\n" %(id))
-	log.write("   -----------\n%s\n   -----------\n" % (diff));
+        log.write("   -----------\n%s\n   -----------\n" % (diff));
 
     return 0
-	    
+
 
 def runTestCases(case):
     creator = case.prop('creator')
     if creator != None:
-	print "=>", creator
+        print("=>", creator)
     base = case.getBase(None)
     basedir = case.prop('basedir')
     if basedir != None:
-	base = libxml2.buildURI(basedir, base)
+        base = libxml2.buildURI(basedir, base)
     test = case.children
     while test != None:
         if test.name == 'testcase':
-	    runTest(test, base)
-	if test.name == 'testcases':
-	    runTestCases(test)
+            runTest(test, base)
+        if test.name == 'testcases':
+            runTestCases(test)
         test = test.next
-        
+
 conf = libxml2.parseFile(CONF)
-if conf == None:
-    print "Unable to load %s" % CONF
+if conf is None:
+    print("Unable to load %s" % CONF)
     sys.exit(1)
 
 testsuite = conf.getRootElement()
 if testsuite.name != 'testsuite':
-    print "Expecting TESTSUITE root element: aborting"
+    print("Expecting TESTSUITE root element: aborting")
     sys.exit(1)
 
 profile = testsuite.prop('PROFILE')
 if profile != None:
-    print profile
+    print(profile)
 
 start = time.time()
 
 case = testsuite.children
 while case != None:
     if case.name == 'testcases':
-	old_test_nr = test_nr
-	old_test_succeed = test_succeed
-	old_test_failed = test_failed
-	old_test_error = test_error
+        old_test_nr = test_nr
+        old_test_succeed = test_succeed
+        old_test_failed = test_failed
+        old_test_error = test_error
         runTestCases(case)
-	print "   Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
-	       test_nr - old_test_nr, test_succeed - old_test_succeed,
-	       test_failed - old_test_failed, test_error - old_test_error)
+        print("   Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
+               test_nr - old_test_nr, test_succeed - old_test_succeed,
+               test_failed - old_test_failed, test_error - old_test_error))
     case = case.next
 
 conf.freeDoc()
 log.close()
 
-print "Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
-      test_nr, test_succeed, test_failed, test_error, time.time() - start)
+print("Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
+      test_nr, test_succeed, test_failed, test_error, time.time() - start))
diff --git a/src/check-xml-test-suite.py b/src/check-xml-test-suite.py
index 399a8db..953a76c 100755
--- a/src/check-xml-test-suite.py
+++ b/src/check-xml-test-suite.py
@@ -2,7 +2,6 @@
 import sys
 import time
 import os
-import string
 sys.path.insert(0, "python")
 import libxml2
 
@@ -31,9 +30,9 @@
     error_nr = error_nr + 1
     if len(error_msg) < 300:
         if len(error_msg) == 0 or error_msg[-1] == '\n':
-	    error_msg = error_msg + "   >>" + str
-	else:
-	    error_msg = error_msg + str
+            error_msg = error_msg + "   >>" + str
+        else:
+            error_msg = error_msg + str
 
 libxml2.registerErrorHandler(errorHandler, None)
 
@@ -53,17 +52,17 @@
 #
 def loadNoentDoc(filename):
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return None
     ctxt.replaceEntities(1)
     ctxt.parseDocument()
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     if ctxt.wellFormed() != 1:
         doc.freeDoc()
-	return None
+        return None
     return doc
 
 #
@@ -79,20 +78,20 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     if doc != None:
-	doc.freeDoc()
+        doc.freeDoc()
     if ret == 0 or ctxt.wellFormed() != 0:
-        print "%s: error: Well Formedness error not detected" % (id)
-	log.write("%s: error: Well Formedness error not detected\n" % (id))
-	return 0
+        print("%s: error: Well Formedness error not detected" % (id))
+        log.write("%s: error: Well Formedness error not detected\n" % (id))
+        return 0
     return 1
 
 def testNotWfEnt(filename, id):
@@ -104,21 +103,21 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.replaceEntities(1)
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     if doc != None:
-	doc.freeDoc()
+        doc.freeDoc()
     if ret == 0 or ctxt.wellFormed() != 0:
-        print "%s: error: Well Formedness error not detected" % (id)
-	log.write("%s: error: Well Formedness error not detected\n" % (id))
-	return 0
+        print("%s: error: Well Formedness error not detected" % (id))
+        log.write("%s: error: Well Formedness error not detected\n" % (id))
+        return 0
     return 1
 
 def testNotWfEntDtd(filename, id):
@@ -130,22 +129,22 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.replaceEntities(1)
     ctxt.loadSubset(1)
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     if doc != None:
-	doc.freeDoc()
+        doc.freeDoc()
     if ret == 0 or ctxt.wellFormed() != 0:
-        print "%s: error: Well Formedness error not detected" % (id)
-	log.write("%s: error: Well Formedness error not detected\n" % (id))
-	return 0
+        print("%s: error: Well Formedness error not detected" % (id))
+        log.write("%s: error: Well Formedness error not detected\n" % (id))
+        return 0
     return 1
 
 def testWfEntDtd(filename, id):
@@ -157,27 +156,27 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.replaceEntities(1)
     ctxt.loadSubset(1)
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
-    if doc == None or ret != 0 or ctxt.wellFormed() == 0:
-        print "%s: error: wrongly failed to parse the document" % (id)
-	log.write("%s: error: wrongly failed to parse the document\n" % (id))
-	if doc != None:
-	    doc.freeDoc()
-	return 0
+    if doc is None or ret != 0 or ctxt.wellFormed() == 0:
+        print("%s: error: wrongly failed to parse the document" % (id))
+        log.write("%s: error: wrongly failed to parse the document\n" % (id))
+        if doc != None:
+            doc.freeDoc()
+        return 0
     if error_nr != 0:
-        print "%s: warning: WF document generated an error msg" % (id)
-	log.write("%s: error: WF document generated an error msg\n" % (id))
-	doc.freeDoc()
-	return 2
+        print("%s: warning: WF document generated an error msg" % (id))
+        log.write("%s: error: WF document generated an error msg\n" % (id))
+        doc.freeDoc()
+        return 2
     doc.freeDoc()
     return 1
 
@@ -190,26 +189,26 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.replaceEntities(1)
     ctxt.loadSubset(1)
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     if doc != None:
-	doc.freeDoc()
+        doc.freeDoc()
     if ctxt.wellFormed() == 0:
-        print "%s: warning: failed to parse the document but accepted" % (id)
-	log.write("%s: warning: failed to parse the document but accepte\n" % (id))
-	return 2
+        print("%s: warning: failed to parse the document but accepted" % (id))
+        log.write("%s: warning: failed to parse the document but accepte\n" % (id))
+        return 2
     if error_nr != 0:
-        print "%s: warning: WF document generated an error msg" % (id)
-	log.write("%s: error: WF document generated an error msg\n" % (id))
-	return 2
+        print("%s: warning: WF document generated an error msg" % (id))
+        log.write("%s: error: WF document generated an error msg\n" % (id))
+        return 2
     return 1
 
 def testInvalid(filename, id):
@@ -221,31 +220,31 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.validate(1)
     ret = ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     valid = ctxt.isValid()
-    if doc == None:
-        print "%s: error: wrongly failed to parse the document" % (id)
-	log.write("%s: error: wrongly failed to parse the document\n" % (id))
-	return 0
+    if doc is None:
+        print("%s: error: wrongly failed to parse the document" % (id))
+        log.write("%s: error: wrongly failed to parse the document\n" % (id))
+        return 0
     if valid == 1:
-        print "%s: error: Validity error not detected" % (id)
-	log.write("%s: error: Validity error not detected\n" % (id))
-	doc.freeDoc()
-	return 0
+        print("%s: error: Validity error not detected" % (id))
+        log.write("%s: error: Validity error not detected\n" % (id))
+        doc.freeDoc()
+        return 0
     if error_nr == 0:
-        print "%s: warning: Validity error not reported" % (id)
-	log.write("%s: warning: Validity error not reported\n" % (id))
-	doc.freeDoc()
-	return 2
-        
+        print("%s: warning: Validity error not reported" % (id))
+        log.write("%s: warning: Validity error not reported\n" % (id))
+        doc.freeDoc()
+        return 2
+
     doc.freeDoc()
     return 1
 
@@ -257,30 +256,30 @@
     error_msg = ''
 
     ctxt = libxml2.createFileParserCtxt(filename)
-    if ctxt == None:
+    if ctxt is None:
         return -1
     ctxt.validate(1)
     ctxt.parseDocument()
 
     try:
-	doc = ctxt.doc()
+        doc = ctxt.doc()
     except:
         doc = None
     valid = ctxt.isValid()
-    if doc == None:
-        print "%s: error: wrongly failed to parse the document" % (id)
-	log.write("%s: error: wrongly failed to parse the document\n" % (id))
-	return 0
+    if doc is None:
+        print("%s: error: wrongly failed to parse the document" % (id))
+        log.write("%s: error: wrongly failed to parse the document\n" % (id))
+        return 0
     if valid != 1:
-        print "%s: error: Validity check failed" % (id)
-	log.write("%s: error: Validity check failed\n" % (id))
-	doc.freeDoc()
-	return 0
+        print("%s: error: Validity check failed" % (id))
+        log.write("%s: error: Validity check failed\n" % (id))
+        doc.freeDoc()
+        return 0
     if error_nr != 0 or valid != 1:
-        print "%s: warning: valid document reported an error" % (id)
-	log.write("%s: warning: valid document reported an error\n" % (id))
-	doc.freeDoc()
-	return 2
+        print("%s: warning: valid document reported an error" % (id))
+        log.write("%s: warning: valid document reported an error\n" % (id))
+        doc.freeDoc()
+        return 2
     doc.freeDoc()
     return 1
 
@@ -293,21 +292,21 @@
 
     uri = test.prop('URI')
     id = test.prop('ID')
-    if uri == None:
-        print "Test without ID:", uri
-	return -1
-    if id == None:
-        print "Test without URI:", id
-	return -1
+    if uri is None:
+        print("Test without ID:", uri)
+        return -1
+    if id is None:
+        print("Test without URI:", id)
+        return -1
     base = test.getBase(None)
     URI = libxml2.buildURI(uri, base)
     if os.access(URI, os.R_OK) == 0:
-        print "Test %s missing: base %s uri %s" % (URI, base, uri)
-	return -1
+        print("Test %s missing: base %s uri %s" % (URI, base, uri))
+        return -1
     type = test.prop('TYPE')
-    if type == None:
-        print "Test %s missing TYPE" % (id)
-	return -1
+    if type is None:
+        print("Test %s missing TYPE" % (id))
+        return -1
 
     extra = None
     if type == "invalid":
@@ -316,94 +315,94 @@
         res = testValid(URI, id)
     elif type == "not-wf":
         extra =  test.prop('ENTITIES')
-	# print URI
-	#if extra == None:
-	#    res = testNotWfEntDtd(URI, id)
- 	#elif extra == 'none':
-	#    res = testNotWf(URI, id)
-	#elif extra == 'general':
-	#    res = testNotWfEnt(URI, id)
-	#elif extra == 'both' or extra == 'parameter':
-	res = testNotWfEntDtd(URI, id)
-	#else:
-	#    print "Unknown value %s for an ENTITIES test value" % (extra)
-	#    return -1
+        # print(URI)
+        #if extra is None:
+        #    res = testNotWfEntDtd(URI, id)
+         #elif extra == 'none':
+        #    res = testNotWf(URI, id)
+        #elif extra == 'general':
+        #    res = testNotWfEnt(URI, id)
+        #elif extra == 'both' or extra == 'parameter':
+        res = testNotWfEntDtd(URI, id)
+        #else:
+        #    print("Unknown value %s for an ENTITIES test value" % (extra))
+        #    return -1
     elif type == "error":
-	res = testError(URI, id)
+        res = testError(URI, id)
     else:
         # TODO skipped for now
-	return -1
+        return -1
 
     test_nr = test_nr + 1
     if res > 0:
-	test_succeed = test_succeed + 1
+        test_succeed = test_succeed + 1
     elif res == 0:
-	test_failed = test_failed + 1
+        test_failed = test_failed + 1
     elif res < 0:
-	test_error = test_error + 1
+        test_error = test_error + 1
 
     # Log the ontext
     if res != 1:
-	log.write("   File: %s\n" % (URI))
-	content = string.strip(test.content)
-	while content[-1] == '\n':
-	    content = content[0:-1]
-	if extra != None:
-	    log.write("   %s:%s:%s\n" % (type, extra, content))
-	else:
-	    log.write("   %s:%s\n\n" % (type, content))
-	if error_msg != '':
-	    log.write("   ----\n%s   ----\n" % (error_msg))
-	    error_msg = ''
-	log.write("\n")
+        log.write("   File: %s\n" % (URI))
+        content = test.content.strip()
+        while content[-1] == '\n':
+            content = content[0:-1]
+        if extra != None:
+            log.write("   %s:%s:%s\n" % (type, extra, content))
+        else:
+            log.write("   %s:%s\n\n" % (type, content))
+        if error_msg != '':
+            log.write("   ----\n%s   ----\n" % (error_msg))
+            error_msg = ''
+        log.write("\n")
 
     return 0
-	    
+
 
 def runTestCases(case):
     profile = case.prop('PROFILE')
     if profile != None and \
-       string.find(profile, "IBM XML Conformance Test Suite - Production") < 0:
-	print "=>", profile
+       profile.find("IBM XML Conformance Test Suite - Production") < 0:
+        print("=>", profile)
     test = case.children
     while test != None:
         if test.name == 'TEST':
-	    runTest(test)
-	if test.name == 'TESTCASES':
-	    runTestCases(test)
+            runTest(test)
+        if test.name == 'TESTCASES':
+            runTestCases(test)
         test = test.next
-        
+
 conf = loadNoentDoc(CONF)
-if conf == None:
-    print "Unable to load %s" % CONF
+if conf is None:
+    print("Unable to load %s" % CONF)
     sys.exit(1)
 
 testsuite = conf.getRootElement()
 if testsuite.name != 'TESTSUITE':
-    print "Expecting TESTSUITE root element: aborting"
+    print("Expecting TESTSUITE root element: aborting")
     sys.exit(1)
 
 profile = testsuite.prop('PROFILE')
 if profile != None:
-    print profile
+    print(profile)
 
 start = time.time()
 
 case = testsuite.children
 while case != None:
     if case.name == 'TESTCASES':
-	old_test_nr = test_nr
-	old_test_succeed = test_succeed
-	old_test_failed = test_failed
-	old_test_error = test_error
+        old_test_nr = test_nr
+        old_test_succeed = test_succeed
+        old_test_failed = test_failed
+        old_test_error = test_error
         runTestCases(case)
-	print "   Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
-	       test_nr - old_test_nr, test_succeed - old_test_succeed,
-	       test_failed - old_test_failed, test_error - old_test_error)
+        print("   Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
+               test_nr - old_test_nr, test_succeed - old_test_succeed,
+               test_failed - old_test_failed, test_error - old_test_error))
     case = case.next
 
 conf.freeDoc()
 log.close()
 
-print "Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
-      test_nr, test_succeed, test_failed, test_error, time.time() - start)
+print("Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
+      test_nr, test_succeed, test_failed, test_error, time.time() - start))
diff --git a/src/check-xsddata-test-suite.py b/src/check-xsddata-test-suite.py
index c946129..9ed72aa 100755
--- a/src/check-xsddata-test-suite.py
+++ b/src/check-xsddata-test-suite.py
@@ -2,8 +2,12 @@
 import sys
 import time
 import os
-import string
-import StringIO
+try:
+    # Python 2
+    from StringIO import StringIO
+except ImportError:
+    # Python 3
+    from io import StringIO
 sys.path.insert(0, "python")
 import libxml2
 
@@ -44,8 +48,8 @@
 def resolver(URL, ID, ctxt):
     global resources
 
-    if resources.has_key(URL):
-        return(StringIO.StringIO(resources[URL]))
+    if URL in resources:
+        return(StringIO(resources[URL]))
     log.write("Resolver failure: asked %s\n" % (URL))
     log.write("resources: %s\n" % (resources))
     return None
@@ -59,49 +63,49 @@
     global nb_instances_failed
 
     instance = node.prop("dtd")
-    if instance == None:
+    if instance is None:
         instance = ""
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
     mem = libxml2.debugMemory(1);
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nFailed to parse correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
-	return
+        nb_instances_failed = nb_instances_failed + 1
+        return
 
     if debug:
-        print "instance line %d" % (node.lineNo())
-       
+        print("instance line %d" % (node.lineNo()))
+
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
-	del ctxt
+        ret = doc.relaxNGValidateDoc(ctxt)
+        del ctxt
     except:
         ret = -1
 
     doc.freeDoc()
     if mem != libxml2.debugMemory(1):
-	print "validating instance %d line %d leaks" % (
-		  nb_instances_tests, node.lineNo())
+        print("validating instance %d line %d leaks" % (
+                  nb_instances_tests, node.lineNo()))
 
     if ret != 0:
         log.write("\nFailed to validate correct instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
 
 #
 # handle an invalid instance
@@ -112,50 +116,50 @@
     global nb_instances_failed
 
     instance = node.prop("dtd")
-    if instance == None:
+    if instance is None:
         instance = ""
     child = node.children
     while child != None:
         if child.type != 'text':
-	    instance = instance + child.serialize()
-	child = child.next
+            instance = instance + child.serialize()
+        child = child.next
 
 #    mem = libxml2.debugMemory(1);
 
     try:
-	doc = libxml2.parseDoc(instance)
+        doc = libxml2.parseDoc(instance)
     except:
         doc = None
 
-    if doc == None:
+    if doc is None:
         log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	return
+        return
 
     if debug:
-        print "instance line %d" % (node.lineNo())
-       
+        print("instance line %d" % (node.lineNo()))
+
     try:
         ctxt = schema.relaxNGNewValidCtxt()
-	ret = doc.relaxNGValidateDoc(ctxt)
-	del ctxt
+        ret = doc.relaxNGValidateDoc(ctxt)
+        del ctxt
 
     except:
         ret = -1
 
     doc.freeDoc()
 #    if mem != libxml2.debugMemory(1):
-#	print "validating instance %d line %d leaks" % (
-#		  nb_instances_tests, node.lineNo())
-    
+#        print("validating instance %d line %d leaks" % (
+#                  nb_instances_tests, node.lineNo()))
+
     if ret == 0:
         log.write("\nFailed to detect validation problem in instance:\n-----\n")
-	log.write(instance)
+        log.write(instance)
         log.write("\n-----\n")
-	nb_instances_failed = nb_instances_failed + 1
+        nb_instances_failed = nb_instances_failed + 1
     else:
-	nb_instances_success = nb_instances_success + 1
+        nb_instances_success = nb_instances_success + 1
 
 #
 # handle an incorrect test
@@ -169,23 +173,23 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
-    if rngs == None:
+    if rngs is None:
         log.write("\nFailed to compile correct schema:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-	nb_schemas_success = nb_schemas_success + 1
+        nb_schemas_success = nb_schemas_success + 1
     return rngs
-        
+
 def handle_incorrect(node):
     global log
     global nb_schemas_success
@@ -195,24 +199,24 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    schema = schema + child.serialize()
-	child = child.next
+            schema = schema + child.serialize()
+        child = child.next
 
     try:
-	rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
-	rngs = rngp.relaxNGParse()
+        rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
+        rngs = rngp.relaxNGParse()
     except:
         rngs = None
     if rngs != None:
         log.write("\nFailed to detect schema error in:\n-----\n")
-	log.write(schema)
+        log.write(schema)
         log.write("\n-----\n")
-	nb_schemas_failed = nb_schemas_failed + 1
+        nb_schemas_failed = nb_schemas_failed + 1
     else:
-#	log.write("\nSuccess detecting schema error in:\n-----\n")
-#	log.write(schema)
-#	log.write("\n-----\n")
-	nb_schemas_success = nb_schemas_success + 1
+#        log.write("\nSuccess detecting schema error in:\n-----\n")
+#        log.write(schema)
+#        log.write("\n-----\n")
+        nb_schemas_success = nb_schemas_success + 1
     return None
 
 #
@@ -222,14 +226,14 @@
     global resources
 
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -238,8 +242,8 @@
     child = node.children
     while child != None:
         if child.type != 'text':
-	    res = res + child.serialize()
-	child = child.next
+            res = res + child.serialize()
+        child = child.next
     resources[name] = res
 
 #
@@ -247,14 +251,14 @@
 #
 def handle_dir(node, dir):
     try:
-	name = node.prop('name')
+        name = node.prop('name')
     except:
         name = None
 
-    if name == None or name == '':
+    if name is None or name == '':
         log.write("resource has no name")
-	return;
-        
+        return;
+
     if dir != None:
 #        name = libxml2.buildURI(name, dir)
         name = dir + '/' + name
@@ -280,7 +284,7 @@
               nb_schemas_tests, node.lineNo(), sections))
     resources = {}
     if debug:
-        print "test %d line %d" % (nb_schemas_tests, node.lineNo())
+        print("test %d line %d" % (nb_schemas_tests, node.lineNo()))
 
     dirs = node.xpathEval('dir')
     for dir in dirs:
@@ -292,27 +296,27 @@
     tsts = node.xpathEval('incorrect')
     if tsts != []:
         if len(tsts) != 1:
-	    print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
-	schema = handle_incorrect(tsts[0])
+            print("warning test line %d has more than one <incorrect> example" %(node.lineNo()))
+        schema = handle_incorrect(tsts[0])
     else:
         tsts = node.xpathEval('correct')
-	if tsts != []:
-	    if len(tsts) != 1:
-		print "warning test line %d has more than one <correct> example"% (node.lineNo())
-	    schema = handle_correct(tsts[0])
-	else:
-	    print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
+        if tsts != []:
+            if len(tsts) != 1:
+                print("warning test line %d has more than one <correct> example"% (node.lineNo()))
+            schema = handle_correct(tsts[0])
+        else:
+            print("warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo()))
 
     nb_schemas_tests = nb_schemas_tests + 1;
-    
+
     valids = node.xpathEval('valid')
     invalids = node.xpathEval('invalid')
     nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
     if schema != None:
         for valid in valids:
-	    handle_valid(valid, schema)
+            handle_valid(valid, schema)
         for invalid in invalids:
-	    handle_invalid(invalid, schema)
+            handle_invalid(invalid, schema)
 
 
 #
@@ -322,60 +326,60 @@
     global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
     global nb_instances_tests, nb_instances_success, nb_instances_failed
     if verbose and level >= 0:
-	old_schemas_tests = nb_schemas_tests
-	old_schemas_success = nb_schemas_success
-	old_schemas_failed = nb_schemas_failed
-	old_instances_tests = nb_instances_tests
-	old_instances_success = nb_instances_success
-	old_instances_failed = nb_instances_failed
+        old_schemas_tests = nb_schemas_tests
+        old_schemas_success = nb_schemas_success
+        old_schemas_failed = nb_schemas_failed
+        old_instances_tests = nb_instances_tests
+        old_instances_success = nb_instances_success
+        old_instances_failed = nb_instances_failed
 
     docs = node.xpathEval('documentation')
     authors = node.xpathEval('author')
     if docs != []:
         msg = ""
         for doc in docs:
-	    msg = msg + doc.content + " "
-	if authors != []:
-	    msg = msg + "written by "
-	    for author in authors:
-	        msg = msg + author.content + " "
-	if quiet == 0:
-	    print msg
+            msg = msg + doc.content + " "
+        if authors != []:
+            msg = msg + "written by "
+            for author in authors:
+                msg = msg + author.content + " "
+        if quiet == 0:
+            print(msg)
     sections = node.xpathEval('section')
     if verbose and sections != [] and level <= 0:
         msg = ""
         for section in sections:
-	    msg = msg + section.content + " "
-	if quiet == 0:
-	    print "Tests for section %s" % (msg)
+            msg = msg + section.content + " "
+        if quiet == 0:
+            print("Tests for section %s" % (msg))
     for test in node.xpathEval('testCase'):
         handle_testCase(test)
     for test in node.xpathEval('testSuite'):
         handle_testSuite(test, level + 1)
-	        
+
 
     if verbose and level >= 0 :
         if sections != []:
-	    msg = ""
-	    for section in sections:
-		msg = msg + section.content + " "
-	    print "Result of tests for section %s" % (msg)
-	elif docs != []:
-	    msg = ""
-	    for doc in docs:
-	        msg = msg + doc.content + " "
-	    print "Result of tests for %s" % (msg)
+            msg = ""
+            for section in sections:
+                msg = msg + section.content + " "
+            print("Result of tests for section %s" % (msg))
+        elif docs != []:
+            msg = ""
+            for doc in docs:
+                msg = msg + doc.content + " "
+            print("Result of tests for %s" % (msg))
 
         if nb_schemas_tests != old_schemas_tests:
-	    print "found %d test schemas: %d success %d failures" % (
-		  nb_schemas_tests - old_schemas_tests,
-		  nb_schemas_success - old_schemas_success,
-		  nb_schemas_failed - old_schemas_failed)
-	if nb_instances_tests != old_instances_tests:
-	    print "found %d test instances: %d success %d failures" % (
-		  nb_instances_tests - old_instances_tests,
-		  nb_instances_success - old_instances_success,
-		  nb_instances_failed - old_instances_failed)
+            print("found %d test schemas: %d success %d failures" % (
+                  nb_schemas_tests - old_schemas_tests,
+                  nb_schemas_success - old_schemas_success,
+                  nb_schemas_failed - old_schemas_failed))
+        if nb_instances_tests != old_instances_tests:
+            print("found %d test instances: %d success %d failures" % (
+                  nb_instances_tests - old_instances_tests,
+                  nb_instances_success - old_instances_success,
+                  nb_instances_failed - old_instances_failed))
 #
 # Parse the conf file
 #
@@ -394,18 +398,18 @@
 libxml2.setEntityLoader(resolver)
 root = testsuite.getRootElement()
 if root.name != 'testSuite':
-    print "%s doesn't start with a testSuite element, aborting" % (CONF)
+    print("%s doesn't start with a testSuite element, aborting" % (CONF))
     sys.exit(1)
 if quiet == 0:
-    print "Running Relax NG testsuite"
+    print("Running Relax NG testsuite")
 handle_testSuite(root)
 
 if quiet == 0 or nb_schemas_failed != 0:
-    print "\nTOTAL:\nfound %d test schemas: %d success %d failures" % (
-      nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
+    print("\nTOTAL:\nfound %d test schemas: %d success %d failures" % (
+      nb_schemas_tests, nb_schemas_success, nb_schemas_failed))
 if quiet == 0 or nb_instances_failed != 0:
-    print "found %d test instances: %d success %d failures" % (
-      nb_instances_tests, nb_instances_success, nb_instances_failed)
+    print("found %d test instances: %d success %d failures" % (
+      nb_instances_tests, nb_instances_success, nb_instances_failed))
 
 testsuite.freeDoc()
 
@@ -414,7 +418,7 @@
 libxml2.cleanupParser()
 if libxml2.debugMemory(1) == 0:
     if quiet == 0:
-	print "OK"
+        print("OK")
 else:
-    print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
     libxml2.dumpMemory()
diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in
index bb9d340..5af19f9 100644
--- a/src/config.h.cmake.in
+++ b/src/config.h.cmake.in
@@ -123,9 +123,6 @@
 /* Whether __va_copy() is available */
 #cmakedefine HAVE___VA_COPY 1
 
-/* Define as const if the declaration of iconv() needs const. */
-#define ICONV_CONST @ICONV_CONST@
-
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #cmakedefine LT_OBJDIR "@LT_OBJDIR@"
 
diff --git a/src/config.h.in b/src/config.h.in
index 20feceb..c2dd854 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -146,9 +146,6 @@
 /* Whether __va_copy() is available */
 #undef HAVE___VA_COPY
 
-/* Define as const if the declaration of iconv() needs const. */
-#undef ICONV_CONST
-
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
diff --git a/src/configure.ac b/src/configure.ac
index 5f9dfa7..3d36ea5 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -8,7 +8,6 @@
 AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION])
 AC_CONFIG_SRCDIR([entities.c])
 AC_CONFIG_HEADERS([config.h])
-AM_MAINTAINER_MODE([enable])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_HOST
 
@@ -40,12 +39,9 @@
 
 VERSION=${LIBXML_VERSION}
 
-AM_INIT_AUTOMAKE([foreign])
-
-# Support silent build rules, requires at least automake-1.11. Disable
-# by either passing --disable-silent-rules to configure or passing V=1
-# to make
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AM_INIT_AUTOMAKE([1.15 foreign no-dist-gzip dist-xz])
+AM_MAINTAINER_MODE([enable])
+AM_SILENT_RULES([yes])
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -61,7 +57,8 @@
 AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
 PKG_PROG_PKG_CONFIG
 
-LT_INIT
+LT_INIT([disable-static])
+LT_LIB_M
 
 dnl
 dnl if the system support linker version scripts for symbol versioning
@@ -97,8 +94,6 @@
 [  --with-catalog          add the Catalog support (on)])
 AC_ARG_WITH(debug,
 [  --with-debug            add the debugging module (on)])
-AC_ARG_WITH(docbook,
-[  --with-docbook          add Docbook SGML support (off)])
 AC_ARG_WITH(fexceptions,
 [  --with-fexceptions      add GCC flag -fexceptions for C++ exceptions (off)])
 AC_ARG_WITH(ftp,
@@ -107,15 +102,6 @@
 [  --with-history          add history support to xmllint shell(off)])
 AC_ARG_WITH(html,
 [  --with-html             add the HTML support (on)])
-dnl Specific dir for HTML output ?
-AC_ARG_WITH(html-dir, AS_HELP_STRING([--with-html-dir=path],
-            [path to base html directory, default $docdir/html]),
-            [HTML_DIR=$withval], [HTML_DIR='$(docdir)/html'])
-
-AC_ARG_WITH(html-subdir, AS_HELP_STRING([--with-html-subdir=path],
-            [directory used under html-dir, default '']),
-            [test "x$withval" != "x" && HTML_DIR="$HTML_DIR/$withval"])
-AC_SUBST(HTML_DIR)
 AC_ARG_WITH(http,
 [  --with-http             add the HTTP support (on)])
 AC_ARG_WITH(iconv,
@@ -137,15 +123,12 @@
 AC_ARG_WITH(push,
 [  --with-push             add the PUSH parser interfaces (on)])
 AC_ARG_WITH(python,
-[  --with-python[[=DIR]]     build Python bindings if found])
-AC_ARG_WITH(python_install_dir,
-[  --with-python-install-dir=DIR
-                          install Python bindings in DIR])
+[  --with-python           build Python bindings (on)])
 AC_ARG_WITH(reader,
 [  --with-reader           add the xmlReader parsing interface (on)])
 AC_ARG_WITH(readline,
 [  --with-readline=DIR     use readline in DIR],[
-  if test "$withval" != "no" -a "$withval" != "yes"; then
+  if test "$withval" != "no" && test "$withval" != "yes"; then
     RDL_DIR=$withval
     CPPFLAGS="${CPPFLAGS} -I$withval/include"
     LDFLAGS="${LDFLAGS} -L$withval/lib"
@@ -181,7 +164,7 @@
 [  --with-modules          add the dynamic modules support (on)])
 AC_ARG_WITH(zlib,
 [  --with-zlib[[=DIR]]       use libz in DIR],[
-  if test "$withval" != "no" -a "$withval" != "yes"; then
+  if test "$withval" != "no" && test "$withval" != "yes"; then
     Z_DIR=$withval
     CPPFLAGS="${CPPFLAGS} -I$withval/include"
     LDFLAGS="${LDFLAGS} -L$withval/lib"
@@ -189,7 +172,7 @@
 ])
 AC_ARG_WITH(lzma,
 [  --with-lzma[[=DIR]]       use liblzma in DIR],[
-  if test "$withval" != "no" -a "$withval" != "yes"; then
+  if test "$withval" != "no" && test "$withval" != "yes"; then
     LZMA_DIR=$withval
     CPPFLAGS="${CPPFLAGS} -I$withval/include"
     LDFLAGS="${LDFLAGS} -L$withval/lib"
@@ -198,13 +181,6 @@
 AC_ARG_WITH(coverage,
 [  --with-coverage         build for code coverage with GCC (off)])
 
-AC_ARG_ENABLE(rebuild-docs,
-[  --enable-rebuild-docs[[=yes/no]]  rebuild some generated docs [[default=no]]])
-if test "$enable_rebuild_docs" = "yes" -a "$srcdir" != "."; then
-  AC_MSG_ERROR([cannot rebuild docs when builddir != srcdir])
-fi
-AM_CONDITIONAL([REBUILD_DOCS], [test "$enable_rebuild_docs" = "yes"])
-
 dnl
 dnl hard dependencies on options
 dnl
@@ -773,107 +749,15 @@
 dnl check for python
 dnl
 
-PYTHON_VERSION=
-PYTHON_INCLUDES=
-PYTHON_SITE_PACKAGES=
 PYTHON_TESTS=
-pythondir=
-if test "$with_python" != "no" ; then
-    if test -x "$with_python/bin/python"
-    then
-        echo Found python in $with_python/bin/python
-        PYTHON="$with_python/bin/python"
-    else
-        if test -x "$with_python/python.exe"
-        then
-            echo Found python in $with_python/python.exe
-            PYTHON="$with_python/python.exe"
-        else
-            if test -x "$with_python"
-            then
-                echo Found python in $with_python
-                PYTHON="$with_python"
-            else
-                if test -x "$PYTHON"
-                then
-                    echo Found python in environment PYTHON=$PYTHON
-                    with_python=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
-                else
-                    AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
-		fi
-	    fi
-	fi
-    fi
-    if test "$PYTHON" != ""
-    then
-        PYTHON_VERSION=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_version())"`
-	PYTHON_INCLUDES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`
-# does not work as it produce a /usr/lib/python path instead of/usr/lib64/python
-#
-#	PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
-	echo Found Python version $PYTHON_VERSION
-    fi
-    if test "$PYTHON_VERSION" != "" -a "$PYTHON_INCLUDES" = ""
-    then
-	if test -r $with_python/include/python$PYTHON_VERSION/Python.h
-	then
-	    PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
-	else
-	    if test -r $prefix/include/python$PYTHON_VERSION/Python.h
-	    then
-	        PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
-	    else
-		if test -r /usr/include/python$PYTHON_VERSION/Python.h
-		then
-		    PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
-		else
-	            if test -r $with_python/include/Python.h
-	            then
-	                PYTHON_INCLUDES=$with_python/include
-	            else
-		        echo could not find python$PYTHON_VERSION/Python.h or $with_python/include/Python.h
-		    fi
-		fi
-	    fi
-	fi
-    fi
-    if test "$with_python_install_dir" != ""
-    then
-	PYTHON_SITE_PACKAGES="$with_python_install_dir"
-    fi
-    if test "$PYTHON_VERSION" != "" -a "$PYTHON_SITE_PACKAGES" = ""
-    then
-	if test -d $libdir/python$PYTHON_VERSION/site-packages
-	then
-	    PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
-	else
-	    if test -d $with_python/lib/site-packages
-	    then
-		PYTHON_SITE_PACKAGES=$with_python/lib/site-packages
-	    else
-		PYTHON_SITE_PACKAGES=$($PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(True,False,"${exec_prefix}"))')
-	    fi
-	fi
-    fi
-    pythondir='$(PYTHON_SITE_PACKAGES)'
-    PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
-else
-    PYTHON=
-fi
-AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
-if test "$PYTHON_INCLUDES" != ""
-then
-    PYTHON_SUBDIR=python
-else
-    PYTHON_SUBDIR=
-fi
-AC_SUBST(pythondir)
-AC_SUBST(PYTHON_SUBDIR)
-AC_SUBST(PYTHON_LIBS)
+AS_IF([test "x$with_python" != "xno"], [
+    AM_PATH_PYTHON
+    PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
+])
+AM_CONDITIONAL([WITH_PYTHON], [test "x$with_python" != "xno"])
 
 dnl check for dso support
 WITH_MODULES=0
-TEST_MODULES=
 
 if test "$with_modules" != "no" ; then
  case "$host" in
@@ -922,14 +806,9 @@
  esac
 fi
 
-if test "${WITH_MODULES}" = "1"; then
-  TEST_MODULES="ModuleTests"
-fi  
-
 AC_SUBST(WITH_MODULES)
 AC_SUBST(MODULE_PLATFORM_LIBS)
 AC_SUBST(MODULE_EXTENSION)
-AC_SUBST(TEST_MODULES)
 
 dnl
 dnl Check for trio string functions
@@ -956,7 +835,6 @@
 BASE_THREAD_LIBS=""
 WITH_THREADS=0
 THREAD_CFLAGS=""
-TEST_THREADS=""
 THREADS_W32=""
 WITH_THREAD_ALLOC=0
 
@@ -1017,10 +895,9 @@
     esac
     if test "$WITH_THREADS" = "1" ; then
 	THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
-	TEST_THREADS="Threadtests"
     fi
 fi
-if test "$with_thread_alloc" = "yes" -a "$WITH_THREADS" = "1" ; then
+if test "$with_thread_alloc" = "yes" && test "$WITH_THREADS" = "1" ; then
     WITH_THREAD_ALLOC=1
 fi
 
@@ -1028,7 +905,6 @@
 AC_SUBST(BASE_THREAD_LIBS)
 AC_SUBST(WITH_THREADS)
 AC_SUBST(THREAD_CFLAGS)
-AC_SUBST(TEST_THREADS)
 AC_SUBST(WITH_THREAD_ALLOC)
 AM_CONDITIONAL([THREADS_W32],[test -n "$THREADS_W32"])
 
@@ -1053,7 +929,7 @@
 	AC_CHECK_LIB(readline, readline,[
 	   RDL_LIBS="-lreadline $RDL_LIBS $tcap"
 	   AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
-    if test -n "$RDL_DIR" -a -n "$RDL_LIBS"; then
+    if test -n "$RDL_DIR" && test -n "$RDL_LIBS"; then
 	CPPFLAGS="$CPPFLAGS -I${RDL_DIR}/include"
 	RDL_LIBS="-L${RDL_DIR}/lib $RDL_LIBS"
     fi
@@ -1103,17 +979,14 @@
 if test "$with_reader" = "no" ; then
     echo Disabling the xmlReader parsing interface
     WITH_READER=0
-    READER_TEST=
 else    
     WITH_READER=1
-    READER_TEST=Readertests
     if test "$with_push" = "no" ; then
         echo xmlReader requires Push interface - enabling it
 	with_push=yes
     fi
 fi
 AC_SUBST(WITH_READER)
-AC_SUBST(READER_TEST)
 
 if test "$with_writer" = "no" ; then
     echo Disabling the xmlWriter saving interface
@@ -1137,65 +1010,44 @@
 if test "$with_pattern" = "no" ; then
     echo Disabling the xmlPattern parsing interface
     WITH_PATTERN=0
-    TEST_PATTERN=
 else    
     WITH_PATTERN=1
-    TEST_PATTERN=Patterntests
 fi
 AC_SUBST(WITH_PATTERN)
-AC_SUBST(TEST_PATTERN)
 
 if test "$with_sax1" = "no" ; then
     echo Disabling the older SAX1 interface
     WITH_SAX1=0
-    TEST_SAX=
 else    
     WITH_SAX1=1
-    TEST_SAX=SAXtests
 fi
 AC_SUBST(WITH_SAX1)
-AM_CONDITIONAL(WITH_SAX1_SOURCES, test "${WITH_TRIO}" = "1")
-AC_SUBST(TEST_SAX)
 
 if test "$with_push" = "no" ; then
     echo Disabling the PUSH parser interfaces
     WITH_PUSH=0
-    TEST_PUSH=
 else    
     WITH_PUSH=1
-    TEST_PUSH="XMLPushtests"
 fi
 AC_SUBST(WITH_PUSH)
-AC_SUBST(TEST_PUSH)
 
 if test "$with_html" = "no" ; then
     echo Disabling HTML support
     WITH_HTML=0
     HTML_OBJ=
-    TEST_HTML=
 else    
     WITH_HTML=1
     HTML_OBJ="HTMLparser.o HTMLtree.o"
-    TEST_HTML=HTMLtests
-    if test "$with_push" != "no" ; then
-        TEST_PHTML=HTMLPushtests
-    else
-        TEST_PHTML=
-    fi
 fi
 AC_SUBST(WITH_HTML)
 AC_SUBST(HTML_OBJ)
-AC_SUBST(TEST_HTML)
-AC_SUBST(TEST_PHTML)
 
 if test "$with_valid" = "no" ; then
     echo Disabling DTD validation support
     WITH_VALID=0
-    TEST_VALID=
     TEST_VTIME=
 else    
     WITH_VALID=1
-    TEST_VALID=Validtests
     TEST_VTIME=VTimingtests
 fi
 AC_SUBST(WITH_VALID)
@@ -1216,27 +1068,13 @@
 AC_SUBST(CATALOG_OBJ)
 AC_SUBST(TEST_CATALOG)
 
-if test "$with_docbook" != "yes" ; then
-    echo Disabling Docbook support
-    WITH_DOCB=0
-    DOCB_OBJ=
-else    
-    WITH_DOCB=1
-    DOCB_OBJ="DOCBparser.o"
-fi
-AC_SUBST(WITH_DOCB)
-AC_SUBST(DOCB_OBJ)
-
-
 if test "$with_xptr" = "no" ; then
     echo Disabling XPointer support
     WITH_XPTR=0
     XPTR_OBJ=
-    TEST_XPTR=
 else    
     WITH_XPTR=1
     XPTR_OBJ=xpointer.o
-    TEST_XPTR=XPtrtests
     if test "$with_xpath" = "no" ; then
         echo XPointer requires XPath support - enabling it
 	with_xpath=yes
@@ -1244,17 +1082,14 @@
 fi
 AC_SUBST(WITH_XPTR)
 AC_SUBST(XPTR_OBJ)
-AC_SUBST(TEST_XPTR)
 
 if test "$with_c14n" = "no" ; then
     echo Disabling C14N support
     WITH_C14N=0
     C14N_OBJ=
-    TEST_C14N=
 else    
     WITH_C14N=1
     C14N_OBJ="c14n.c"
-    TEST_C14N=C14Ntests
     if test "$with_xpath" = "no" ; then
         echo C14N requires XPath support - enabling it
 	with_xpath=yes
@@ -1262,18 +1097,15 @@
 fi
 AC_SUBST(WITH_C14N)
 AC_SUBST(C14N_OBJ)
-AC_SUBST(TEST_C14N)
 
 if test "$with_xinclude" = "no" ; then
     echo Disabling XInclude support
     WITH_XINCLUDE=0
     XINCLUDE_OBJ=
     with_xinclude="no"
-    TEST_XINCLUDE=
 else    
     WITH_XINCLUDE=1
     XINCLUDE_OBJ=xinclude.o
-    TEST_XINCLUDE=XIncludetests
     if test "$with_xpath" = "no" ; then
         echo XInclude requires XPath support - enabling it
 	with_xpath=yes
@@ -1281,13 +1113,12 @@
 fi
 AC_SUBST(WITH_XINCLUDE)
 AC_SUBST(XINCLUDE_OBJ)
-AC_SUBST(TEST_XINCLUDE)
 
-if test "$with_xptr" = "" -a "$with_xpath" = "no" ; then
+if test "$with_xptr" = "" && test "$with_xpath" = "no" ; then
     with_xptr=no
 fi
 
-if test "$with_schematron" = "" -a "$with_xpath" = "no" ; then
+if test "$with_schematron" = "" && test "$with_xpath" = "no" ; then
     with_schematron=no
 fi
 
@@ -1310,15 +1141,12 @@
     echo Disabling XPATH support
     WITH_XPATH=0
     XPATH_OBJ=
-    TEST_XPATH=
 else    
     WITH_XPATH=1
     XPATH_OBJ=xpath.o
-    TEST_XPATH=XPathtests
 fi
 AC_SUBST(WITH_XPATH)
 AC_SUBST(XPATH_OBJ)
-AC_SUBST(TEST_XPATH)
 
 dnl
 dnl output functions
@@ -1335,7 +1163,7 @@
 if test "$with_iconv" = "no" ; then
     echo Disabling ICONV support
 else
-    if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
+    if test "$with_iconv" != "yes" && test "$with_iconv" != "" ; then
 	CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
 	# Export this since our headers include iconv.h
 	XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
@@ -1370,40 +1198,7 @@
 		AC_MSG_RESULT(no)
 		LIBS="${_libs}"
 		LDFLAGS="${_ldflags}"])]))
-
-	if test "$WITH_ICONV" = "1" ; then
-		AC_MSG_CHECKING([for iconv declaration])
-		AC_CACHE_VAL(xml_cv_iconv_arg2, [
-			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
-#include <iconv.h>
-extern
-#ifdef __cplusplus
-"C"
-#endif
-#if defined(__STDC__) || defined(__cplusplus)
-size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
-#else
-size_t iconv();
-#endif
-]], [])], xml_cv_iconv_arg2="", xml_cv_iconv_arg2="const")])
-
-		xml_cv_iconv_decl="extern size_t iconv (iconv_t cd, $xml_cv_iconv_arg2 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
-		AC_MSG_RESULT([${xml_xxx:-
-	}$xml_cv_iconv_decl])
-		AC_DEFINE_UNQUOTED(ICONV_CONST, $xml_cv_iconv_arg2,
-			[Define as const if the declaration of iconv() needs const.])
-	fi
 fi
-case "$host" in
-	*mingw*) M_LIBS=""
-	;;
-	*beos*) M_LIBS=""
-	;;
-        *haiku*) M_LIBS=""
-        ;;
-	*) M_LIBS="-lm"
-	;;
-esac
 AC_SUBST(WITH_ICONV)
 
 WITH_ICU=0
@@ -1417,6 +1212,13 @@
         [have_libicu=yes],
         [have_libicu=no])
 
+    if test "x$have_libicu" = "xyes"; then
+        PKG_CHECK_VAR([ICU_DEFS], [icu-i18n], [DEFS])
+        if test "x$ICU_DEFS" != "x"; then
+            CPPFLAGS="$CPPFLAGS $ICU_DEFS"
+        fi
+    fi
+
     # If pkg-config failed, fall back to AC_CHECK_LIB. This
     # will not pick up the necessary LIBS flags for liblzma's
     # private dependencies, though, so static linking may fail.
@@ -1428,7 +1230,7 @@
             have_libicu=yes
             echo Enabling ICU support
         else
-            if test "$with_icu" != "yes" -a "$with_iconv" != "" ; then
+            if test "$with_icu" != "yes" && test "$with_iconv" != "" ; then
                 CPPFLAGS="${CPPFLAGS} -I$with_icu"
             fi
 
@@ -1465,7 +1267,6 @@
     fi
 fi
 XML_LIBS="-lxml2"
-XML_PRIVATE_LIBS="$Z_LIBS $LZMA_LIBS $THREAD_LIBS $ICONV_LIBS $ICU_LIBS $M_LIBS $LIBS"
 XML_LIBTOOLLIBS="libxml2.la"
 AC_SUBST(WITH_ICU)
 
@@ -1481,18 +1282,15 @@
 if test "$with_schemas" = "no" ; then
     echo "Disabling Schemas/Relax-NG support"
     WITH_SCHEMAS=0
-    TEST_SCHEMAS=
 else    
     echo "Enabled Schemas/Relax-NG support"
     WITH_SCHEMAS=1
-    TEST_SCHEMAS="Schemastests Relaxtests"
-    if test "$PYTHON_INCLUDES" != "" ; then
+    AS_IF([test "x$with_python" != "xno"], [
         PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests"
-    fi
+    ])
     with_regexps=yes
 fi
 AC_SUBST(WITH_SCHEMAS)
-AC_SUBST(TEST_SCHEMAS)
 
 if test "$with_regexps" = "no" ; then
     echo Disabling Regexps support
@@ -1500,7 +1298,7 @@
     TEST_REGEXPS=
 else    
     WITH_REGEXPS=1
-    TEST_REGEXPS="Regexptests Automatatests"
+    TEST_REGEXPS="Automatatests"
 fi
 AC_SUBST(WITH_REGEXPS)
 AC_SUBST(TEST_REGEXPS)
@@ -1570,6 +1368,9 @@
  fi
  ;;
 esac
+
+XML_PRIVATE_LIBS="$Z_LIBS $LZMA_LIBS $THREAD_LIBS $ICONV_LIBS $ICU_LIBS $LIBM $WIN32_EXTRA_LIBADD"
+
 AC_SUBST(WIN32_EXTRA_LIBADD)
 AC_SUBST(WIN32_EXTRA_LDFLAGS)
 AC_SUBST(WIN32_EXTRA_PYTHON_LIBADD)
@@ -1594,7 +1395,7 @@
 AC_CHECK_FUNCS(snprintf vsnprintf,,
 	NEED_TRIO=1)
 
-if test "$with_coverage" = "yes" -a "${GCC}" = "yes"
+if test "$with_coverage" = "yes" && test "${GCC}" = "yes"
 then
     echo Enabling code coverage for GCC
     EXTRA_CFLAGS="$EXTRA_CFLAGS -fprofile-arcs -ftest-coverage"
@@ -1603,9 +1404,7 @@
     echo Disabling code coverage for GCC
 fi
 
-AC_SUBST(CPPFLAGS)
 AC_SUBST(EXTRA_CFLAGS)
-AC_SUBST(LDFLAGS)
 AC_SUBST(XML_CFLAGS)
 
 AC_SUBST(XML_LIBDIR)
@@ -1615,13 +1414,7 @@
 AC_SUBST(ICONV_LIBS)
 AC_SUBST(ICU_LIBS)
 AC_SUBST(XML_INCLUDEDIR)
-AC_SUBST(HTML_DIR)
-AC_SUBST(PYTHON)
-AC_SUBST(PYTHON_VERSION)
-AC_SUBST(PYTHON_INCLUDES)
-AC_SUBST(PYTHON_SITE_PACKAGES)
 
-AC_SUBST(M_LIBS)
 AC_SUBST(RDL_LIBS)
 
 dnl for the spec file
@@ -1629,9 +1422,6 @@
 AC_SUBST(RELDATE)
 AC_SUBST(PYTHON_TESTS)
 
-rm -f COPYING.LIB COPYING
-ln -s $srcdir/Copyright COPYING
-
 # keep on one line for cygwin c.f. #130896
 AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake])
 AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py])
diff --git a/src/dict.c b/src/dict.c
index ecc90e0..c29d2af 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -127,7 +127,7 @@
  * A mutex for modifying the reference counter for shared
  * dictionaries.
  */
-static xmlRMutexPtr xmlDictMutex = NULL;
+static xmlMutexPtr xmlDictMutex = NULL;
 
 /*
  * Whether the dictionary mutex was initialized.
@@ -146,8 +146,10 @@
 /**
  * xmlInitializeDict:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Do the dictionary mutex initialization.
- * this function is deprecated
  *
  * Returns 0 if initialization was already done, and 1 if that
  * call led to the initialization
@@ -172,9 +174,9 @@
     if (xmlDictInitialized)
         return(1);
 
-    if ((xmlDictMutex = xmlNewRMutex()) == NULL)
+    if ((xmlDictMutex = xmlNewMutex()) == NULL)
         return(0);
-    xmlRMutexLock(xmlDictMutex);
+    xmlMutexLock(xmlDictMutex);
 
 #ifdef DICT_RANDOMIZATION
 #ifdef HAVE_RAND_R
@@ -185,7 +187,7 @@
 #endif
 #endif
     xmlDictInitialized = 1;
-    xmlRMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(xmlDictMutex);
     return(1);
 }
 
@@ -196,13 +198,13 @@
     if (xmlDictInitialized == 0)
         __xmlInitializeDict();
 
-    xmlRMutexLock(xmlDictMutex);
+    xmlMutexLock(xmlDictMutex);
 #ifdef HAVE_RAND_R
     ret = rand_r(& rand_seed);
 #else
     ret = rand();
 #endif
-    xmlRMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(xmlDictMutex);
     return(ret);
 }
 #endif
@@ -210,6 +212,11 @@
 /**
  * xmlDictCleanup:
  *
+ * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ *
  * Free the dictionary mutex. Do not call unless sure the library
  * is not in use anymore !
  */
@@ -218,7 +225,7 @@
     if (!xmlDictInitialized)
         return;
 
-    xmlFreeRMutex(xmlDictMutex);
+    xmlFreeMutex(xmlDictMutex);
 
     xmlDictInitialized = 0;
 }
@@ -643,9 +650,9 @@
             return(-1);
 
     if (dict == NULL) return -1;
-    xmlRMutexLock(xmlDictMutex);
+    xmlMutexLock(xmlDictMutex);
     dict->ref_counter++;
-    xmlRMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(xmlDictMutex);
     return(0);
 }
 
@@ -807,14 +814,14 @@
             return;
 
     /* decrement the counter, it may be shared by a parser and docs */
-    xmlRMutexLock(xmlDictMutex);
+    xmlMutexLock(xmlDictMutex);
     dict->ref_counter--;
     if (dict->ref_counter > 0) {
-        xmlRMutexUnlock(xmlDictMutex);
+        xmlMutexUnlock(xmlDictMutex);
         return;
     }
 
-    xmlRMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(xmlDictMutex);
 
     if (dict->subdict != NULL) {
         xmlDictFree(dict->subdict);
diff --git a/src/encoding.c b/src/encoding.c
index 8b01b96..2e527c0 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -1408,6 +1408,9 @@
 /**
  * xmlInitCharEncodingHandlers:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Initialize the char encoding support, it registers the default
  * encoding supported.
  * NOTE: while public, this function usually doesn't need to be called
@@ -1468,6 +1471,11 @@
 /**
  * xmlCleanupCharEncodingHandlers:
  *
+ * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ *
  * Cleanup the memory allocated for the char encoding support, it
  * unregisters all the encoding handlers and the aliases.
  */
@@ -1747,6 +1755,10 @@
     } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
 	    xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
 		    "iconv : problems with filters for '%s'\n", name);
+	    if (icv_in != (iconv_t) -1)
+		iconv_close(icv_in);
+	    else
+		iconv_close(icv_out);
     }
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
@@ -1840,7 +1852,10 @@
     }
     icv_inlen = *inlen;
     icv_outlen = *outlen;
-    ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+    /*
+     * Some versions take const, other versions take non-const input.
+     */
+    ret = iconv(cd, (void *) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
     *inlen -= icv_inlen;
     *outlen -= icv_outlen;
     if ((icv_inlen != 0) || (ret == (size_t) -1)) {
diff --git a/src/fuzz/Makefile.am b/src/fuzz/Makefile.am
index 69410bc..6d59816 100644
--- a/src/fuzz/Makefile.am
+++ b/src/fuzz/Makefile.am
@@ -6,7 +6,7 @@
 CLEANFILES = $(EXTRA_PROGRAMS)
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
 DEPENDENCIES = $(top_builddir)/libxml2.la
-LDADD = $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
+LDADD = $(top_builddir)/libxml2.la
 
 XML_MAX_LEN = 80000
 # Single quotes to avoid wildcard expansion by the shell
@@ -15,6 +15,7 @@
     '$(top_srcdir)/test/errors/*.xml' \
     '$(top_srcdir)/test/errors10/*.xml' \
     '$(top_srcdir)/test/namespaces/*' \
+    '$(top_srcdir)/test/SVG/*.xml' \
     '$(top_srcdir)/test/valid/*.xml' \
     '$(top_srcdir)/test/VC/*' \
     '$(top_srcdir)/test/VCM/*' \
@@ -23,14 +24,13 @@
 
 testFuzzer_SOURCES = testFuzzer.c fuzz.c
 
-.PHONY: tests corpus clean-corpus
+.PHONY: corpus clean-corpus
 
 corpus: seed/html.stamp seed/regexp.stamp seed/schema.stamp seed/uri.stamp \
     seed/xml.stamp seed/xpath.stamp
 
-tests: testFuzzer$(EXEEXT) corpus
-	@echo "## Running fuzzer tests"
-	@./testFuzzer$(EXEEXT)
+check-local: corpus
+	./testFuzzer$(EXEEXT)
 
 clean-corpus:
 	rm -rf seed
diff --git a/src/fuzz/Makefile.in b/src/fuzz/Makefile.in
index 95ba6a9..b1a79f1 100644
--- a/src/fuzz/Makefile.in
+++ b/src/fuzz/Makefile.in
@@ -92,10 +92,10 @@
 check_PROGRAMS = testFuzzer$(EXEEXT)
 subdir = fuzz
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_try_compile2.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -106,11 +106,7 @@
 am_genSeed_OBJECTS = genSeed.$(OBJEXT) fuzz.$(OBJEXT)
 genSeed_OBJECTS = $(am_genSeed_OBJECTS)
 genSeed_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-genSeed_DEPENDENCIES = $(top_builddir)/libxml2.la \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+genSeed_DEPENDENCIES = $(top_builddir)/libxml2.la
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
@@ -118,67 +114,46 @@
 am_html_OBJECTS = html.$(OBJEXT) fuzz.$(OBJEXT)
 html_OBJECTS = $(am_html_OBJECTS)
 html_LDADD = $(LDADD)
-html_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+html_DEPENDENCIES = $(top_builddir)/libxml2.la
 html_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(html_LDFLAGS) $(LDFLAGS) -o $@
 am_regexp_OBJECTS = regexp.$(OBJEXT) fuzz.$(OBJEXT)
 regexp_OBJECTS = $(am_regexp_OBJECTS)
 regexp_LDADD = $(LDADD)
-regexp_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+regexp_DEPENDENCIES = $(top_builddir)/libxml2.la
 regexp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(regexp_LDFLAGS) $(LDFLAGS) -o $@
 am_schema_OBJECTS = schema.$(OBJEXT) fuzz.$(OBJEXT)
 schema_OBJECTS = $(am_schema_OBJECTS)
 schema_LDADD = $(LDADD)
-schema_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+schema_DEPENDENCIES = $(top_builddir)/libxml2.la
 schema_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(schema_LDFLAGS) $(LDFLAGS) -o $@
 am_testFuzzer_OBJECTS = testFuzzer.$(OBJEXT) fuzz.$(OBJEXT)
 testFuzzer_OBJECTS = $(am_testFuzzer_OBJECTS)
 testFuzzer_LDADD = $(LDADD)
-testFuzzer_DEPENDENCIES = $(top_builddir)/libxml2.la \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+testFuzzer_DEPENDENCIES = $(top_builddir)/libxml2.la
 am_uri_OBJECTS = uri.$(OBJEXT) fuzz.$(OBJEXT)
 uri_OBJECTS = $(am_uri_OBJECTS)
 uri_LDADD = $(LDADD)
-uri_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+uri_DEPENDENCIES = $(top_builddir)/libxml2.la
 uri_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(uri_LDFLAGS) $(LDFLAGS) -o $@
 am_xml_OBJECTS = xml.$(OBJEXT) fuzz.$(OBJEXT)
 xml_OBJECTS = $(am_xml_OBJECTS)
 xml_LDADD = $(LDADD)
-xml_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+xml_DEPENDENCIES = $(top_builddir)/libxml2.la
 xml_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(xml_LDFLAGS) $(LDFLAGS) -o $@
 am_xpath_OBJECTS = xpath.$(OBJEXT) fuzz.$(OBJEXT)
 xpath_OBJECTS = $(am_xpath_OBJECTS)
 xpath_LDADD = $(LDADD)
-xpath_DEPENDENCIES = $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+xpath_DEPENDENCIES = $(top_builddir)/libxml2.la
 xpath_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(xpath_LDFLAGS) $(LDFLAGS) -o $@
@@ -275,7 +250,6 @@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
-DOCB_OBJ = @DOCB_OBJ@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
 ECHO_C = @ECHO_C@
@@ -288,11 +262,11 @@
 FGREP = @FGREP@
 FTP_OBJ = @FTP_OBJ@
 GREP = @GREP@
-HTML_DIR = @HTML_DIR@
 HTML_OBJ = @HTML_OBJ@
 HTTP_OBJ = @HTTP_OBJ@
 ICONV_LIBS = @ICONV_LIBS@
 ICU_CFLAGS = @ICU_CFLAGS@
+ICU_DEFS = @ICU_DEFS@
 ICU_LIBS = @ICU_LIBS@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -301,6 +275,7 @@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
+LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -324,7 +299,6 @@
 MODULE_EXTENSION = @MODULE_EXTENSION@
 MODULE_PLATFORM_LIBS = @MODULE_PLATFORM_LIBS@
 MV = @MV@
-M_LIBS = @M_LIBS@
 NM = @NM@
 NMEDIT = @NMEDIT@
 OBJDUMP = @OBJDUMP@
@@ -344,39 +318,27 @@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 PYTHON = @PYTHON@
-PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
 PYTHON_LIBS = @PYTHON_LIBS@
-PYTHON_SITE_PACKAGES = @PYTHON_SITE_PACKAGES@
-PYTHON_SUBDIR = @PYTHON_SUBDIR@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_TESTS = @PYTHON_TESTS@
 PYTHON_VERSION = @PYTHON_VERSION@
 RANLIB = @RANLIB@
 RDL_LIBS = @RDL_LIBS@
-READER_TEST = @READER_TEST@
 RELDATE = @RELDATE@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
 TAR = @TAR@
-TEST_C14N = @TEST_C14N@
 TEST_CATALOG = @TEST_CATALOG@
 TEST_DEBUG = @TEST_DEBUG@
-TEST_HTML = @TEST_HTML@
-TEST_MODULES = @TEST_MODULES@
-TEST_PATTERN = @TEST_PATTERN@
-TEST_PHTML = @TEST_PHTML@
-TEST_PUSH = @TEST_PUSH@
 TEST_REGEXPS = @TEST_REGEXPS@
-TEST_SAX = @TEST_SAX@
-TEST_SCHEMAS = @TEST_SCHEMAS@
 TEST_SCHEMATRON = @TEST_SCHEMATRON@
-TEST_THREADS = @TEST_THREADS@
 TEST_VALID = @TEST_VALID@
 TEST_VTIME = @TEST_VTIME@
-TEST_XINCLUDE = @TEST_XINCLUDE@
-TEST_XPATH = @TEST_XPATH@
-TEST_XPTR = @TEST_XPTR@
 THREAD_CFLAGS = @THREAD_CFLAGS@
 THREAD_LIBS = @THREAD_LIBS@
 VERSION = @VERSION@
@@ -388,7 +350,6 @@
 WITH_C14N = @WITH_C14N@
 WITH_CATALOG = @WITH_CATALOG@
 WITH_DEBUG = @WITH_DEBUG@
-WITH_DOCB = @WITH_DOCB@
 WITH_FTP = @WITH_FTP@
 WITH_HTML = @WITH_HTML@
 WITH_HTTP = @WITH_HTTP@
@@ -472,9 +433,12 @@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+pyexecdir = @pyexecdir@
 pythondir = @pythondir@
 runstatedir = @runstatedir@
 sbindir = @sbindir@
@@ -492,7 +456,7 @@
 CLEANFILES = $(EXTRA_PROGRAMS)
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
 DEPENDENCIES = $(top_builddir)/libxml2.la
-LDADD = $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD)
+LDADD = $(top_builddir)/libxml2.la
 XML_MAX_LEN = 80000
 # Single quotes to avoid wildcard expansion by the shell
 XML_SEED_CORPUS_SRC = \
@@ -500,6 +464,7 @@
     '$(top_srcdir)/test/errors/*.xml' \
     '$(top_srcdir)/test/errors10/*.xml' \
     '$(top_srcdir)/test/namespaces/*' \
+    '$(top_srcdir)/test/SVG/*.xml' \
     '$(top_srcdir)/test/valid/*.xml' \
     '$(top_srcdir)/test/VC/*' \
     '$(top_srcdir)/test/VCM/*' \
@@ -732,6 +697,7 @@
 	done
 check-am: all-am
 	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+	$(MAKE) $(AM_MAKEFLAGS) check-local
 check: check-am
 all-am: Makefile
 installdirs:
@@ -853,16 +819,17 @@
 
 .MAKE: check-am install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
-	clean-checkPROGRAMS clean-generic clean-libtool clean-local \
-	cscopelist-am ctags ctags-am distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am \
+	check-local clean clean-checkPROGRAMS clean-generic \
+	clean-libtool clean-local cscopelist-am ctags ctags-am \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
@@ -870,14 +837,13 @@
 .PRECIOUS: Makefile
 
 
-.PHONY: tests corpus clean-corpus
+.PHONY: corpus clean-corpus
 
 corpus: seed/html.stamp seed/regexp.stamp seed/schema.stamp seed/uri.stamp \
     seed/xml.stamp seed/xpath.stamp
 
-tests: testFuzzer$(EXEEXT) corpus
-	@echo "## Running fuzzer tests"
-	@./testFuzzer$(EXEEXT)
+check-local: corpus
+	./testFuzzer$(EXEEXT)
 
 clean-corpus:
 	rm -rf seed
diff --git a/src/gentest.py b/src/gentest.py
index 88f88f1..6fa044a 100755
--- a/src/gentest.py
+++ b/src/gentest.py
@@ -21,8 +21,6 @@
 #
 skipped_modules = [ "SAX", "xlink", "threads", "globals",
   "xmlmemory", "xmlversion", "xmlexports",
-  #deprecated
-  "DOCBparser",
 ]
 
 #
@@ -43,7 +41,6 @@
     "xmlregexp" : "LIBXML_REGEXP_ENABLED",
     "xmlautomata" : "LIBXML_AUTOMATA_ENABLED",
     "xmlsave" : "LIBXML_OUTPUT_ENABLED",
-    "DOCBparser" : "LIBXML_DOCB_ENABLED",
     "xmlmodule" : "LIBXML_MODULES_ENABLED",
     "pattern" : "LIBXML_PATTERN_ENABLED",
     "schematron" : "LIBXML_SCHEMATRON_ENABLED",
@@ -94,7 +91,6 @@
     "xmlSprintfElementContent": "LIBXML_OUTPUT_ENABLED",
     "xmlValidGetPotentialChildren" : "LIBXML_VALID_ENABLED",
     "xmlValidGetValidElements" : "LIBXML_VALID_ENABLED",
-    "docbDefaultSAXHandlerInit" : "LIBXML_DOCB_ENABLED",
     "xmlTextReaderPreservePattern" : "LIBXML_PATTERN_ENABLED",
 }
 
diff --git a/src/globals.c b/src/globals.c
index 4aec812..a15ac30 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -40,6 +40,9 @@
 /**
  * xmlInitGlobals:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Additional initialisation for multi-threading
  */
 void xmlInitGlobals(void)
@@ -134,7 +137,6 @@
 #include <libxml/globals.h>
 #include <libxml/SAX.h>
 
-#undef	docbDefaultSAXHandler
 #undef	htmlDefaultSAXHandler
 #undef	oldXMLWDcompatibility
 #undef	xmlBufferAllocScheme
@@ -441,44 +443,6 @@
 };
 #endif /* LIBXML_HTML_ENABLED */
 
-#ifdef LIBXML_DOCB_ENABLED
-/**
- * docbDefaultSAXHandler:
- *
- * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
- */
-xmlSAXHandlerV1 docbDefaultSAXHandler = {
-    xmlSAX2InternalSubset,
-    xmlSAX2IsStandalone,
-    xmlSAX2HasInternalSubset,
-    xmlSAX2HasExternalSubset,
-    xmlSAX2ResolveEntity,
-    xmlSAX2GetEntity,
-    xmlSAX2EntityDecl,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    xmlSAX2SetDocumentLocator,
-    xmlSAX2StartDocument,
-    xmlSAX2EndDocument,
-    xmlSAX2StartElement,
-    xmlSAX2EndElement,
-    xmlSAX2Reference,
-    xmlSAX2Characters,
-    xmlSAX2IgnorableWhitespace,
-    NULL,
-    xmlSAX2Comment,
-    xmlParserWarning,
-    xmlParserError,
-    xmlParserError,
-    xmlSAX2GetParameterEntity,
-    NULL,
-    NULL,
-    0,
-};
-#endif /* LIBXML_DOCB_ENABLED */
-
 /**
  * xmlInitializeGlobalState:
  * @gs: a pointer to a newly allocated global state
@@ -502,9 +466,6 @@
 
     xmlMutexLock(xmlThrDefMutex);
 
-#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
-    initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
-#endif
 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
     inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
 #endif
@@ -562,6 +523,27 @@
 }
 
 /**
+ * xmlCleanupGlobals:
+ *
+ * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ *
+ * Additional cleanup for multi-threading
+ */
+void xmlCleanupGlobals(void)
+{
+    xmlResetError(&xmlLastError);
+
+    if (xmlThrDefMutex != NULL) {
+	xmlFreeMutex(xmlThrDefMutex);
+	xmlThrDefMutex = NULL;
+    }
+    __xmlGlobalInitMutexDestroy();
+}
+
+/**
  * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
  *               those are really internal work
  */
@@ -685,17 +667,6 @@
     return(old);
 }
 
-#ifdef LIBXML_DOCB_ENABLED
-#undef	docbDefaultSAXHandler
-xmlSAXHandlerV1 *
-__docbDefaultSAXHandler(void) {
-    if (IS_MAIN_THREAD)
-	return (&docbDefaultSAXHandler);
-    else
-	return (&xmlGetGlobalState()->docbDefaultSAXHandler);
-}
-#endif
-
 #ifdef LIBXML_HTML_ENABLED
 #undef	htmlDefaultSAXHandler
 xmlSAXHandlerV1 *
@@ -1106,19 +1077,3 @@
 	return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
 }
 
-/**
- * xmlCleanupGlobals:
- *
- * Additional cleanup for multi-threading
- */
-void xmlCleanupGlobals(void)
-{
-    xmlResetError(&xmlLastError);
-
-    if (xmlThrDefMutex != NULL) {
-	xmlFreeMutex(xmlThrDefMutex);
-	xmlThrDefMutex = NULL;
-    }
-    __xmlGlobalInitMutexDestroy();
-}
-
diff --git a/src/include/libxml/DOCBparser.h b/src/include/libxml/DOCBparser.h
deleted file mode 100644
index 748e1ab..0000000
--- a/src/include/libxml/DOCBparser.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Summary: old DocBook SGML parser
- * Description: interface for a DocBook SGML non-verifying parser
- * This code is DEPRECATED, and should not be used anymore.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-#ifndef __DOCB_PARSER_H__
-#define __DOCB_PARSER_H__
-#include <libxml/xmlversion.h>
-
-#ifdef LIBXML_DOCB_ENABLED
-
-#include <libxml/parser.h>
-#include <libxml/parserInternals.h>
-
-#ifndef IN_LIBXML
-#ifdef __GNUC__
-#warning "The DOCBparser module has been deprecated in libxml2-2.6.0"
-#endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Most of the back-end structures from XML and SGML are shared.
- */
-typedef xmlParserCtxt docbParserCtxt;
-typedef xmlParserCtxtPtr docbParserCtxtPtr;
-typedef xmlSAXHandler docbSAXHandler;
-typedef xmlSAXHandlerPtr docbSAXHandlerPtr;
-typedef xmlParserInput docbParserInput;
-typedef xmlParserInputPtr docbParserInputPtr;
-typedef xmlDocPtr docbDocPtr;
-
-/*
- * There is only few public functions.
- */
-XML_DEPRECATED
-XMLPUBFUN int XMLCALL
-		     docbEncodeEntities(unsigned char *out,
-                                        int *outlen,
-                                        const unsigned char *in,
-                                        int *inlen, int quoteChar);
-
-XML_DEPRECATED
-XMLPUBFUN docbDocPtr XMLCALL
-		     docbSAXParseDoc   (xmlChar *cur,
-                                        const char *encoding,
-                                        docbSAXHandlerPtr sax,
-                                        void *userData);
-XML_DEPRECATED
-XMLPUBFUN docbDocPtr XMLCALL
-		     docbParseDoc      (xmlChar *cur,
-                                        const char *encoding);
-XML_DEPRECATED
-XMLPUBFUN docbDocPtr XMLCALL
-		     docbSAXParseFile  (const char *filename,
-                                        const char *encoding,
-                                        docbSAXHandlerPtr sax,
-                                        void *userData);
-XML_DEPRECATED
-XMLPUBFUN docbDocPtr XMLCALL
-		     docbParseFile     (const char *filename,
-                                        const char *encoding);
-
-/**
- * Interfaces for the Push mode.
- */
-XML_DEPRECATED
-XMLPUBFUN void XMLCALL
-		     docbFreeParserCtxt      (docbParserCtxtPtr ctxt);
-XML_DEPRECATED
-XMLPUBFUN docbParserCtxtPtr XMLCALL
-		     docbCreatePushParserCtxt(docbSAXHandlerPtr sax,
-                                              void *user_data,
-                                              const char *chunk,
-                                              int size,
-                                              const char *filename,
-                                              xmlCharEncoding enc);
-XML_DEPRECATED
-XMLPUBFUN int XMLCALL
-		     docbParseChunk          (docbParserCtxtPtr ctxt,
-                                              const char *chunk,
-                                              int size,
-                                              int terminate);
-XML_DEPRECATED
-XMLPUBFUN docbParserCtxtPtr XMLCALL
-		     docbCreateFileParserCtxt(const char *filename,
-                                              const char *encoding);
-XML_DEPRECATED
-XMLPUBFUN int XMLCALL
-		     docbParseDocument       (docbParserCtxtPtr ctxt);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBXML_DOCB_ENABLED */
-
-#endif /* __DOCB_PARSER_H__ */
diff --git a/src/include/libxml/Makefile.am b/src/include/libxml/Makefile.am
index cf9297a..6373bc7 100644
--- a/src/include/libxml/Makefile.am
+++ b/src/include/libxml/Makefile.am
@@ -27,7 +27,6 @@
 		valid.h \
 		xlink.h \
 		xmlversion.h \
-		DOCBparser.h \
 		catalog.h \
 		threads.h \
 		globals.h \
diff --git a/src/include/libxml/SAX.h b/src/include/libxml/SAX.h
index 61876d1..fa50568 100644
--- a/src/include/libxml/SAX.h
+++ b/src/include/libxml/SAX.h
@@ -16,7 +16,6 @@
 #include <stdlib.h>
 #include <libxml/xmlversion.h>
 #include <libxml/parser.h>
-#include <libxml/xlink.h>
 
 #ifdef LIBXML_LEGACY_ENABLED
 
@@ -194,11 +193,6 @@
 XMLPUBFUN void XMLCALL
 		inithtmlDefaultSAXHandler	(xmlSAXHandlerV1 *hdlr);
 #endif
-#ifdef LIBXML_DOCB_ENABLED
-XML_DEPRECATED
-XMLPUBFUN void XMLCALL
-		initdocbDefaultSAXHandler	(xmlSAXHandlerV1 *hdlr);
-#endif
 #endif /* LIBXML_SAX1_ENABLED */
 
 #ifdef __cplusplus
diff --git a/src/include/libxml/SAX2.h b/src/include/libxml/SAX2.h
index a55212e..8e9b0b9 100644
--- a/src/include/libxml/SAX2.h
+++ b/src/include/libxml/SAX2.h
@@ -16,7 +16,6 @@
 #include <stdlib.h>
 #include <libxml/xmlversion.h>
 #include <libxml/parser.h>
-#include <libxml/xlink.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -99,8 +98,7 @@
 XMLPUBFUN void XMLCALL
 		xmlSAX2EndDocument		(void *ctx);
 #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
-    defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \
-    defined(LIBXML_LEGACY_ENABLED)
+    defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 XMLPUBFUN void XMLCALL
 		xmlSAX2StartElement		(void *ctx,
 						 const xmlChar *fullname,
@@ -161,15 +159,11 @@
 #ifdef LIBXML_HTML_ENABLED
 XMLPUBFUN void XMLCALL
 		xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 		htmlDefaultSAXHandlerInit	(void);
 #endif
-#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN void XMLCALL
-		xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
-XMLPUBFUN void XMLCALL
-		docbDefaultSAXHandlerInit	(void);
-#endif
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 		xmlDefaultSAXHandlerInit	(void);
 #ifdef __cplusplus
diff --git a/src/include/libxml/dict.h b/src/include/libxml/dict.h
index cf54af1..91f74d1 100644
--- a/src/include/libxml/dict.h
+++ b/src/include/libxml/dict.h
@@ -27,6 +27,7 @@
 /*
  * Initializer
  */
+XML_DEPRECATED
 XMLPUBFUN int XMLCALL  xmlInitializeDict(void);
 
 /*
@@ -70,6 +71,7 @@
 /*
  * Cleanup function
  */
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
                         xmlDictCleanup  (void);
 
diff --git a/src/include/libxml/encoding.h b/src/include/libxml/encoding.h
index 77f137f..381e188 100644
--- a/src/include/libxml/encoding.h
+++ b/src/include/libxml/encoding.h
@@ -153,8 +153,10 @@
 /*
  * Interfaces for encoding handlers.
  */
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 	xmlInitCharEncodingHandlers	(void);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 	xmlCleanupCharEncodingHandlers	(void);
 XMLPUBFUN void XMLCALL
diff --git a/src/include/libxml/globals.h b/src/include/libxml/globals.h
index 5e41b7b..d57ccb0 100644
--- a/src/include/libxml/globals.h
+++ b/src/include/libxml/globals.h
@@ -24,7 +24,9 @@
 extern "C" {
 #endif
 
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL xmlInitGlobals(void);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
 
 /**
@@ -67,7 +69,6 @@
  * compatibility support.
  */
 
-#undef	docbDefaultSAXHandler
 #undef	htmlDefaultSAXHandler
 #undef	oldXMLWDcompatibility
 #undef	xmlBufferAllocScheme
@@ -124,7 +125,7 @@
 
 	xmlSAXLocator xmlDefaultSAXLocator;
 	xmlSAXHandlerV1 xmlDefaultSAXHandler;
-	xmlSAXHandlerV1 docbDefaultSAXHandler;
+	xmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */
 	xmlSAXHandlerV1 htmlDefaultSAXHandler;
 
 	xmlFreeFunc xmlFree;
@@ -251,16 +252,6 @@
 XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
 #endif /* LIBXML_THREAD_ALLOC_ENABLED */
 
-#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN  xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define docbDefaultSAXHandler \
-(*(__docbDefaultSAXHandler()))
-#else
-XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
-#endif
-#endif
-
 #ifdef LIBXML_HTML_ENABLED
 XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
 #ifdef LIBXML_THREAD_ENABLED
diff --git a/src/include/libxml/parser.h b/src/include/libxml/parser.h
index 5dad587..82c61d6 100644
--- a/src/include/libxml/parser.h
+++ b/src/include/libxml/parser.h
@@ -10,8 +10,6 @@
 #ifndef __XML_PARSER_H__
 #define __XML_PARSER_H__
 
-#include <stdarg.h>
-
 #include <libxml/xmlversion.h>
 #include <libxml/tree.h>
 #include <libxml/dict.h>
@@ -192,7 +190,7 @@
     const xmlChar    *version;        /* the XML version string */
     const xmlChar   *encoding;        /* the declared encoding, if any */
     int            standalone;        /* standalone document */
-    int                  html;        /* an HTML(1)/Docbook(2) document
+    int                  html;        /* an HTML(1) document
                                        * 3 is HTML after <head>
                                        * 10 is HTML after <body>
                                        */
diff --git a/src/include/libxml/parserInternals.h b/src/include/libxml/parserInternals.h
index 9f3c76f..656ee46 100644
--- a/src/include/libxml/parserInternals.h
+++ b/src/include/libxml/parserInternals.h
@@ -339,6 +339,7 @@
 XMLPUBFUN int XMLCALL
 			xmlSwitchToEncoding	(xmlParserCtxtPtr ctxt,
 					 xmlCharEncodingHandlerPtr handler);
+XML_DEPRECATED
 XMLPUBFUN int XMLCALL
 			xmlSwitchInputEncoding	(xmlParserCtxtPtr ctxt,
 						 xmlParserInputPtr input,
@@ -574,6 +575,7 @@
 /*
  * Actually comes from the HTML parser but launched from the init stuff.
  */
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL			htmlInitAutoClose	(void);
 XMLPUBFUN htmlParserCtxtPtr XMLCALL	htmlCreateFileParserCtxt(const char *filename,
 	                                         const char *encoding);
diff --git a/src/include/libxml/relaxng.h b/src/include/libxml/relaxng.h
index f269c9e..6369785 100644
--- a/src/include/libxml/relaxng.h
+++ b/src/include/libxml/relaxng.h
@@ -118,6 +118,7 @@
 
 XMLPUBFUN int XMLCALL
 		    xmlRelaxNGInitTypes		(void);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 		    xmlRelaxNGCleanupTypes	(void);
 
diff --git a/src/include/libxml/threads.h b/src/include/libxml/threads.h
index 9969ae7..6eedac1 100644
--- a/src/include/libxml/threads.h
+++ b/src/include/libxml/threads.h
@@ -57,6 +57,7 @@
 /*
  * Library wide APIs.
  */
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 			xmlInitThreads	(void);
 XMLPUBFUN void XMLCALL
@@ -67,6 +68,7 @@
 			xmlGetThreadId	(void);
 XMLPUBFUN int XMLCALL
 			xmlIsMainThread	(void);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 			xmlCleanupThreads(void);
 XMLPUBFUN xmlGlobalStatePtr XMLCALL
diff --git a/src/include/libxml/tree.h b/src/include/libxml/tree.h
index 9823654..98e2087 100644
--- a/src/include/libxml/tree.h
+++ b/src/include/libxml/tree.h
@@ -177,11 +177,11 @@
     XML_NAMESPACE_DECL=		18,
     XML_XINCLUDE_START=		19,
     XML_XINCLUDE_END=		20
-#ifdef LIBXML_DOCB_ENABLED
-   ,XML_DOCB_DOCUMENT_NODE=	21
-#endif
+    /* XML_DOCB_DOCUMENT_NODE=	21 */ /* removed */
 } xmlElementType;
 
+/* For backward compatibility */
+#define XML_DOCB_DOCUMENT_NODE 21
 
 /**
  * xmlNotation:
@@ -659,7 +659,7 @@
     defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \
     defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \
     defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \
-    defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+    defined(LIBXML_LEGACY_ENABLED)
 XMLPUBFUN int XMLCALL
 		xmlValidateNCName	(const xmlChar *value,
 					 int space);
diff --git a/src/include/libxml/xmlmemory.h b/src/include/libxml/xmlmemory.h
index 17e375a..ae2a427 100644
--- a/src/include/libxml/xmlmemory.h
+++ b/src/include/libxml/xmlmemory.h
@@ -126,12 +126,14 @@
 /*
  * Initialization of the memory layer.
  */
+XML_DEPRECATED
 XMLPUBFUN int XMLCALL
 	xmlInitMemory	(void);
 
 /*
  * Cleanup of the memory layer.
  */
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
                 xmlCleanupMemory        (void);
 /*
diff --git a/src/include/libxml/xmlschemastypes.h b/src/include/libxml/xmlschemastypes.h
index 35d48d4..5d588f9 100644
--- a/src/include/libxml/xmlschemastypes.h
+++ b/src/include/libxml/xmlschemastypes.h
@@ -32,6 +32,7 @@
 
 XMLPUBFUN void XMLCALL
 		xmlSchemaInitTypes		(void);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 		xmlSchemaCleanupTypes		(void);
 XMLPUBFUN xmlSchemaTypePtr XMLCALL
diff --git a/src/include/libxml/xmlversion.h.in b/src/include/libxml/xmlversion.h.in
index b1d2a20..944920b 100644
--- a/src/include/libxml/xmlversion.h.in
+++ b/src/include/libxml/xmlversion.h.in
@@ -230,15 +230,6 @@
 #endif
 
 /**
- * LIBXML_DOCB_ENABLED:
- *
- * Whether the SGML Docbook support is configured in
- */
-#if @WITH_DOCB@
-#define LIBXML_DOCB_ENABLED
-#endif
-
-/**
  * LIBXML_XPATH_ENABLED:
  *
  * Whether XPath is configured in
diff --git a/src/include/libxml/xpath.h b/src/include/libxml/xpath.h
index 539593f..a6e3644 100644
--- a/src/include/libxml/xpath.h
+++ b/src/include/libxml/xpath.h
@@ -549,6 +549,7 @@
 		    xmlXPathFreeCompExpr	(xmlXPathCompExprPtr comp);
 #endif /* LIBXML_XPATH_ENABLED */
 #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
 		    xmlXPathInit		(void);
 XMLPUBFUN int XMLCALL
diff --git a/src/include/win32config.h b/src/include/win32config.h
index d804404..4f99ae0 100644
--- a/src/include/win32config.h
+++ b/src/include/win32config.h
@@ -7,104 +7,14 @@
 #define HAVE_SYS_STAT_H
 #define HAVE_STAT
 #define HAVE_FCNTL_H
-#include <io.h>
-#include <direct.h>
 
-#include <libxml/xmlversion.h>
-
-#ifndef ICONV_CONST
-#define ICONV_CONST const
+#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
+#define HAVE_STDINT_H
 #endif
 
-/*
- * Windows platforms may define except 
- */
-#undef except
-
-#define HAVE_ISINF
-#define HAVE_ISNAN
-#include <math.h>
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-/* MS C-runtime has functions which can be used in order to determine if
-   a given floating-point variable contains NaN, (+-)INF. These are 
-   preferred, because floating-point technology is considered proprietary
-   by MS and we can assume that their functions know more about their 
-   oddities than we do. */
-#include <float.h>
-/* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass
-   function. */
-#ifndef isinf
-#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
-	: ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
-#endif
-/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
-#ifndef isnan
-#define isnan(d) (_isnan(d))
-#endif
-#else /* _MSC_VER */
-#ifndef isinf
-static int isinf (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 1;
-        } else if (val == -0.5) {
-            return -1;
-        } else {
-            return 0;
-        }
-    } else {
-        return 0;
-    }
-}
-#endif
-#ifndef isnan
-static int isnan (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 0;
-        } else if (val == -0.5) {
-            return 0;
-        } else {
-            return 1;
-        }
-    } else {
-        return 0;
-    }
-}
-#endif
-#endif /* _MSC_VER */
-
-#if defined(_MSC_VER)
-#define mkdir(p,m) _mkdir(p)
-#if _MSC_VER < 1900
+#if defined(_MSC_VER) && _MSC_VER < 1900
 #define snprintf _snprintf
-#endif
-#if _MSC_VER < 1500
-#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
-#endif
-#elif defined(__MINGW32__)
-#define mkdir(p,m) _mkdir(p)
-#endif
-
-/* Threading API to use should be specified here for compatibility reasons.
-   This is however best specified on the compiler's command-line. */
-#if defined(LIBXML_THREAD_ENABLED)
-#if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE)
-#define HAVE_WIN32_THREADS
-#endif
-#endif
-
-/* Some third-party libraries far from our control assume the following
-   is defined, which it is not if we don't include windows.h. */
-#if !defined(FALSE)
-#define FALSE 0
-#endif
-#if !defined(TRUE)
-#define TRUE (!(FALSE))
+#define vsnprintf _vsnprintf
 #endif
 
 #endif /* __LIBXML_WIN32_CONFIG__ */
diff --git a/src/libxml-2.0-uninstalled.pc.in b/src/libxml-2.0-uninstalled.pc.in
index 60b886b..0c3186f 100644
--- a/src/libxml-2.0-uninstalled.pc.in
+++ b/src/libxml-2.0-uninstalled.pc.in
@@ -2,11 +2,12 @@
 exec_prefix=
 libdir=${pcfiledir}
 includedir=${pcfiledir}/include
-
+modules=@WITH_MODULES@
 
 Name: libXML
 Version: @VERSION@
 Description: libXML library version2.
 Requires:
-Libs: -L${libdir} -lxml2 @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@
-Cflags: -I${includedir} @XML_INCLUDEDIR@ @XML_CFLAGS@
+Libs: -L${libdir} @XML_LIBS@
+Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
+Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
diff --git a/src/libxml-2.0.pc.in b/src/libxml-2.0.pc.in
index 2653a7c..88e3963 100644
--- a/src/libxml-2.0.pc.in
+++ b/src/libxml-2.0.pc.in
@@ -8,6 +8,6 @@
 Version: @VERSION@
 Description: libXML library version2.
 Requires:
-Libs: -L${libdir} -lxml2
-Libs.private: @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@
+Libs: -L${libdir} @XML_LIBS@
+Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
 Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
diff --git a/src/libxml.3 b/src/libxml.3
deleted file mode 100644
index b3e9fef..0000000
--- a/src/libxml.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.TH libxml 3 "12 April 2000"
-.SH NAME
-libxml \- library used to parse XML files
-.SH DESCRIPTION
-The
-.I  libxml
-library is used to parse XML files. 
-Its internal document representation is as close as possible to the 
-.I DOM 
-(Document Object Model) interface,
-an API for accessing XML or HTML structured documents.
-.LP
-The
-.I libxml
-library also has a 
-.IR SAX -like
-interface, 
-which is designed to be compatible with 
-.IR expat (1).
-NOTE:
-.IR SAX , 
-the Simple API for XML,
-is a standard interface for event-based XML parsing,
-developed collaboratively by the members of the XML-DEV mailing list, 
-currently hosted by OASIS.
-The
-.I expat
-library is a XML 1.0 parser written in C,
-which aims to be fully conforming. 
-It is currently not a validating XML processor.
-.LP
-The
-.I libxml 
-library now includes a nearly complete 
-.I XPath 
-implementation. 
-The
-.I XPath
-(XML Path Language) is a language for addressing parts of an 
-XML document,
-designed to be used by both 
-.I XSLT 
-and 
-.IR XPointer .
-.LP
-The
-.I libxml 
-library exports Push and Pull type parser interfaces for both XML and 
-.IR html . 
-.SH FILES
-.TP 2.2i
-.B /depot/lib/libxml_2.0.0/libxml.a
-static library
-.TP
-.B /depot/lib/libxml_2.0.0/libxml.so
-shared library
-.TP
-.B /depot/package/libxml_2.0.0/bin/xmllint
-binary application for parsing XML files
-.SH AUTHORS
-Daniel Veillard (daniel@veillard.com).
-Red Hat Inc.
-Manual page by Ziying Sherwin (sherwin@nlm.nih.gov),
-Lister Hill National Center for Biomedical Communications,
-U.S. National Library of Medicine.
-.SH SEE ALSO
-.IR xmllint (1),
-.IR libxslt (3),
-.IR libexslt (3),
-.IR xsltproc (1)
-.\" end of manual page
diff --git a/src/libxml.h b/src/libxml.h
index 1330552..910ca49 100644
--- a/src/libxml.h
+++ b/src/libxml.h
@@ -28,6 +28,10 @@
 #include "config.h"
 #include <libxml/xmlversion.h>
 
+#ifndef SYSCONFDIR
+  #define SYSCONFDIR "/etc"
+#endif
+
 #if defined(__Lynx__)
 #include <stdio.h> /* pull definition of size_t */
 #include <varargs.h>
diff --git a/src/libxml.spec.in b/src/libxml.spec.in
index 73c6fd9..ea593d0 100644
--- a/src/libxml.spec.in
+++ b/src/libxml.spec.in
@@ -144,7 +144,6 @@
 %doc NEWS README.md Copyright TODO
 %doc %{_mandir}/man1/xmllint.1*
 %doc %{_mandir}/man1/xmlcatalog.1*
-%doc %{_mandir}/man3/libxml.3*
 
 %{_libdir}/lib*.so.*
 %{_bindir}/xmllint
diff --git a/src/libxml2.spec b/src/libxml2.spec
index 13820db..4de040b 100644
--- a/src/libxml2.spec
+++ b/src/libxml2.spec
@@ -144,7 +144,6 @@
 %doc NEWS README.md Copyright TODO
 %doc %{_mandir}/man1/xmllint.1*
 %doc %{_mandir}/man1/xmlcatalog.1*
-%doc %{_mandir}/man3/libxml.3*
 
 %{_libdir}/lib*.so.*
 %{_bindir}/xmllint
@@ -204,6 +203,6 @@
 %endif # with_python3
 
 %changelog
-* Fri Mar  4 2022 Daniel Veillard <veillard@redhat.com>
+* Mon Apr  4 2022 Daniel Veillard <veillard@redhat.com>
 - upstream release 2.9.13
 
diff --git a/src/libxml2.syms b/src/libxml2.syms
index 33bc112..f692a1c 100644
--- a/src/libxml2.syms
+++ b/src/libxml2.syms
@@ -76,7 +76,7 @@
   comment;
 
 # SAX2
-  docbDefaultSAXHandlerInit;
+# docbDefaultSAXHandlerInit; removed in 2.10.0
 
 # SAX
   elementDecl;
@@ -100,7 +100,7 @@
 
 # SAX
   ignorableWhitespace;
-  initdocbDefaultSAXHandler;
+# initdocbDefaultSAXHandler; removed in 2.10.0
   inithtmlDefaultSAXHandler;
   initxmlDefaultSAXHandler;
   internalSubset;
@@ -453,16 +453,16 @@
   xmlNanoFTPUpdateURL;
 
 # DOCBparser
-  docbCreateFileParserCtxt;
-  docbCreatePushParserCtxt;
-  docbEncodeEntities;
-  docbFreeParserCtxt;
-  docbParseChunk;
-  docbParseDoc;
-  docbParseDocument;
-  docbParseFile;
-  docbSAXParseDoc;
-  docbSAXParseFile;
+# docbCreateFileParserCtxt; removed in 2.10.0
+# docbCreatePushParserCtxt; removed in 2.10.0
+# docbEncodeEntities; removed in 2.10.0
+# docbFreeParserCtxt; removed in 2.10.0
+# docbParseChunk; removed in 2.10.0
+# docbParseDoc; removed in 2.10.0
+# docbParseDocument; removed in 2.10.0
+# docbParseFile; removed in 2.10.0
+# docbSAXParseDoc; removed in 2.10.0
+# docbSAXParseFile; removed in 2.10.0
 
 # xpath
   xmlXPathCastBooleanToNumber;
@@ -818,7 +818,7 @@
   xmlTextReaderXmlLang;
 
 # globals
-  docbDefaultSAXHandler; # variable
+# docbDefaultSAXHandler; removed in 2.10.0
   htmlDefaultSAXHandler; # variable
   xmlDefaultSAXHandler; # variable
   xmlDefaultSAXLocator; # variable
@@ -1503,7 +1503,7 @@
   xmlSAX2HasInternalSubset;
   xmlSAX2IgnorableWhitespace;
   xmlSAX2InitDefaultSAXHandler;
-  xmlSAX2InitDocbDefaultSAXHandler;
+# xmlSAX2InitDocbDefaultSAXHandler; removed in 2.10.0
   xmlSAX2InitHtmlDefaultSAXHandler;
   xmlSAX2InternalSubset;
   xmlSAX2IsStandalone;
diff --git a/src/parser.c b/src/parser.c
index ce20bd1..d207a02 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -70,15 +70,6 @@
 #include <libxml/xmlschemastypes.h>
 #include <libxml/relaxng.h>
 #endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "buf.h"
 #include "enc.h"
@@ -2183,6 +2174,9 @@
     if (l == 1) b[i++] = (xmlChar) v;					\
     else i += xmlCopyCharMultiByte(&b[i],v)
 
+#define CUR_CONSUMED \
+    (ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))
+
 /**
  * xmlSkipBlankChars:
  * @ctxt:  the XML parser context
@@ -6820,12 +6814,12 @@
             }
             SKIP(3);
         } else {
-            const xmlChar *check = CUR_PTR;
-            unsigned int cons = ctxt->input->consumed;
+            int id = ctxt->input->id;
+            unsigned long cons = CUR_CONSUMED;
 
             xmlParseMarkupDecl(ctxt);
 
-            if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
+            if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
                 xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
                 xmlHaltParser(ctxt);
                 goto error;
@@ -7044,8 +7038,8 @@
     while (((RAW == '<') && (NXT(1) == '?')) ||
            ((RAW == '<') && (NXT(1) == '!')) ||
 	   (RAW == '%')) {
-	const xmlChar *check = CUR_PTR;
-	unsigned int cons = ctxt->input->consumed;
+	int id = ctxt->input->id;
+	unsigned long cons = CUR_CONSUMED;
 
 	GROW;
         if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
@@ -7054,7 +7048,7 @@
 	    xmlParseMarkupDecl(ctxt);
         SKIP_BLANKS;
 
-	if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
+	if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
 	    xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
 	    break;
 	}
@@ -8095,6 +8089,7 @@
 	            "xmlLoadEntityContent parameter error");
         return(-1);
     }
+    xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 
     input = xmlNewEntityInputStream(ctxt, entity);
     if (input == NULL) {
@@ -8377,8 +8372,8 @@
 	 */
 	while (((RAW != ']') || (ctxt->inputNr > baseInputNr)) &&
                (ctxt->instate != XML_PARSER_EOF)) {
-	    const xmlChar *check = CUR_PTR;
-	    unsigned int cons = ctxt->input->consumed;
+	    int id = ctxt->input->id;
+	    unsigned long cons = CUR_CONSUMED;
 
 	    SKIP_BLANKS;
 	    xmlParseMarkupDecl(ctxt);
@@ -8393,7 +8388,7 @@
                 xmlParseConditionalSections(ctxt);
             }
 
-	    if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
+	    if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
 		xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 	     "xmlParseInternalSubset: error detected in Markup declaration\n");
                 if (ctxt->inputNr > baseInputNr)
@@ -8572,8 +8567,8 @@
     while (((RAW != '>') &&
 	   ((RAW != '/') || (NXT(1) != '>')) &&
 	   (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
-	const xmlChar *q = CUR_PTR;
-	unsigned int cons = ctxt->input->consumed;
+        int id = ctxt->input->id;
+	unsigned long cons = CUR_CONSUMED;
 
 	attname = xmlParseAttribute(ctxt, &attvalue);
         if ((attname != NULL) && (attvalue != NULL)) {
@@ -8638,7 +8633,7 @@
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "attributes construct error\n");
 	}
-        if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
+        if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
             (attname == NULL) && (attvalue == NULL)) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
 			   "xmlParseStartTag: problem parsing attributes\n");
@@ -9322,8 +9317,8 @@
     while (((RAW != '>') &&
 	   ((RAW != '/') || (NXT(1) != '>')) &&
 	   (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
-	const xmlChar *q = CUR_PTR;
-	unsigned int cons = ctxt->input->consumed;
+	int id = ctxt->input->id;
+	unsigned long cons = CUR_CONSUMED;
 	int len = -1, alloc = 0;
 
 	attname = xmlParseAttribute2(ctxt, prefix, localname,
@@ -9504,7 +9499,7 @@
 			   "attributes construct error\n");
 	    break;
 	}
-        if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
+        if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
             (attname == NULL) && (attvalue == NULL)) {
 	    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 	         "xmlParseStartTag: problem parsing attributes\n");
@@ -9888,8 +9883,8 @@
     GROW;
     while ((RAW != 0) &&
 	   (ctxt->instate != XML_PARSER_EOF)) {
-	const xmlChar *test = CUR_PTR;
-	unsigned int cons = ctxt->input->consumed;
+        int id = ctxt->input->id;
+	unsigned long cons = CUR_CONSUMED;
 	const xmlChar *cur = ctxt->input->cur;
 
 	/*
@@ -9948,7 +9943,7 @@
 	GROW;
 	SHRINK;
 
-	if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
+	if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
 	    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 	                "detected an error in element content\n");
 	    xmlHaltParser(ctxt);
@@ -10905,8 +10900,6 @@
     if ((ctxt == NULL) || (ctxt->input == NULL))
         return(-1);
 
-    xmlDefaultSAXHandlerInit();
-
     xmlDetectSAX2(ctxt);
 
     GROW;
@@ -11543,15 +11536,15 @@
                 break;
 	    }
             case XML_PARSER_CONTENT: {
-		const xmlChar *test;
-		unsigned int cons;
+		int id;
+		unsigned long cons;
 		if ((avail < 2) && (ctxt->inputNr == 1))
 		    goto done;
 		cur = ctxt->input->cur[0];
 		next = ctxt->input->cur[1];
 
-		test = CUR_PTR;
-	        cons = ctxt->input->consumed;
+		id = ctxt->input->id;
+	        cons = CUR_CONSUMED;
 		if ((cur == '<') && (next == '/')) {
 		    ctxt->instate = XML_PARSER_END_TAG;
 		    break;
@@ -11632,7 +11625,7 @@
 		    ctxt->checkIndex = 0;
 		    xmlParseCharData(ctxt, 0);
 		}
-		if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
+		if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
 		    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 		                "detected an error in element content\n");
 		    xmlHaltParser(ctxt);
diff --git a/src/parserInternals.c b/src/parserInternals.c
index 7d3d13b..bdc0b0f 100644
--- a/src/parserInternals.c
+++ b/src/parserInternals.c
@@ -20,19 +20,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef LIBXML_ZLIB_ENABLED
-#include <zlib.h>
-#endif
-
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
@@ -297,7 +284,6 @@
 xmlParserInputGrow(xmlParserInputPtr in, int len) {
     int ret;
     size_t indx;
-    const xmlChar *content;
 
     if ((in == NULL) || (len < 0)) return(-1);
 #ifdef DEBUG_INPUT
@@ -322,22 +308,8 @@
     } else
         return(0);
 
-    /*
-     * NOTE : in->base may be a "dangling" i.e. freed pointer in this
-     *        block, but we use it really as an integer to do some
-     *        pointer arithmetic. Insure will raise it as a bug but in
-     *        that specific case, that's not !
-     */
-
-    content = xmlBufContent(in->buf->buffer);
-    if (in->base != content) {
-        /*
-	 * the buffer has been reallocated
-	 */
-	indx = in->cur - in->base;
-	in->base = content;
-	in->cur = &content[indx];
-    }
+    in->base = xmlBufContent(in->buf->buffer);
+    in->cur = in->base + indx;
     in->end = xmlBufEnd(in->buf->buffer);
 
     CHECK_BUFFER(in);
@@ -355,8 +327,6 @@
 xmlParserInputShrink(xmlParserInputPtr in) {
     size_t used;
     size_t ret;
-    size_t indx;
-    const xmlChar *content;
 
 #ifdef DEBUG_INPUT
     xmlGenericError(xmlGenericErrorContext, "Shrink\n");
@@ -369,7 +339,7 @@
 
     CHECK_BUFFER(in);
 
-    used = in->cur - xmlBufContent(in->buf->buffer);
+    used = in->cur - in->base;
     /*
      * Do not shrink on large buffers whose only a tiny fraction
      * was consumed
@@ -377,27 +347,17 @@
     if (used > INPUT_CHUNK) {
 	ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
 	if (ret > 0) {
-	    in->cur -= ret;
+            used -= ret;
 	    in->consumed += ret;
 	}
-	in->end = xmlBufEnd(in->buf->buffer);
     }
 
-    CHECK_BUFFER(in);
+    if (xmlBufUse(in->buf->buffer) <= INPUT_CHUNK) {
+        xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
+    }
 
-    if (xmlBufUse(in->buf->buffer) > INPUT_CHUNK) {
-        return;
-    }
-    xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
-    content = xmlBufContent(in->buf->buffer);
-    if (in->base != content) {
-        /*
-	 * the buffer has been reallocated
-	 */
-	indx = in->cur - in->base;
-	in->base = content;
-	in->cur = &content[indx];
-    }
+    in->base = xmlBufContent(in->buf->buffer);
+    in->cur = in->base + used;
     in->end = xmlBufEnd(in->buf->buffer);
 
     CHECK_BUFFER(in);
@@ -906,9 +866,6 @@
  ************************************************************************/
 
 static int
-xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
-                       xmlCharEncodingHandlerPtr handler, int len);
-static int
 xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
                           xmlCharEncodingHandlerPtr handler, int len);
 /**
@@ -1008,55 +965,7 @@
 		/* default encoding, no conversion should be needed */
 		ctxt->charset = XML_CHAR_ENCODING_UTF8;
 		return(0);
-	    case XML_CHAR_ENCODING_UTF16LE:
-		break;
-	    case XML_CHAR_ENCODING_UTF16BE:
-		break;
-	    case XML_CHAR_ENCODING_UCS4LE:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "USC4 little endian", NULL);
-		break;
-	    case XML_CHAR_ENCODING_UCS4BE:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "USC4 big endian", NULL);
-		break;
-	    case XML_CHAR_ENCODING_EBCDIC:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "EBCDIC", NULL);
-		break;
-	    case XML_CHAR_ENCODING_UCS4_2143:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "UCS4 2143", NULL);
-		break;
-	    case XML_CHAR_ENCODING_UCS4_3412:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "UCS4 3412", NULL);
-		break;
-	    case XML_CHAR_ENCODING_UCS2:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "UCS2", NULL);
-		break;
 	    case XML_CHAR_ENCODING_8859_1:
-	    case XML_CHAR_ENCODING_8859_2:
-	    case XML_CHAR_ENCODING_8859_3:
-	    case XML_CHAR_ENCODING_8859_4:
-	    case XML_CHAR_ENCODING_8859_5:
-	    case XML_CHAR_ENCODING_8859_6:
-	    case XML_CHAR_ENCODING_8859_7:
-	    case XML_CHAR_ENCODING_8859_8:
-	    case XML_CHAR_ENCODING_8859_9:
-		/*
-		 * We used to keep the internal content in the
-		 * document encoding however this turns being unmaintainable
-		 * So xmlGetCharEncodingHandler() will return non-null
-		 * values for this now.
-		 */
 		if ((ctxt->inputNr == 1) &&
 		    (ctxt->encoding == NULL) &&
 		    (ctxt->input != NULL) &&
@@ -1065,36 +974,20 @@
 		}
 		ctxt->charset = enc;
 		return(0);
-	    case XML_CHAR_ENCODING_2022_JP:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "ISO-2022-JP", NULL);
-		break;
-	    case XML_CHAR_ENCODING_SHIFT_JIS:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "Shift_JIS", NULL);
-		break;
-	    case XML_CHAR_ENCODING_EUC_JP:
-		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-			       "encoding not supported %s\n",
-			       BAD_CAST "EUC-JP", NULL);
-		break;
 	    default:
-	        break;
-	}
+		__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
+                        "encoding not supported: %s\n",
+			BAD_CAST xmlGetCharEncodingName(enc), NULL);
+                /*
+                 * TODO: We could recover from errors in external entities
+                 * if we didn't stop the parser. But most callers of this
+                 * function don't check the return value.
+                 */
+                xmlStopParser(ctxt);
+                return(-1);
+        }
     }
-    /*
-     * TODO: We could recover from errors in external entities if we
-     * didn't stop the parser. But most callers of this function don't
-     * check the return value.
-     */
-    if (handler == NULL) {
-        xmlStopParser(ctxt);
-	return(-1);
-    }
-    ctxt->charset = XML_CHAR_ENCODING_UTF8;
-    ret = xmlSwitchToEncodingInt(ctxt, handler, len);
+    ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
     if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
         /*
 	 * on encoding conversion errors, stop the parser
@@ -1106,7 +999,7 @@
 }
 
 /**
- * xmlSwitchInputEncoding:
+ * xmlSwitchInputEncodingInt:
  * @ctxt:  the parser context
  * @input:  the input stream
  * @handler:  the encoding handler
@@ -1128,6 +1021,8 @@
     if (input == NULL)
         return (-1);
     if (input->buf != NULL) {
+	ctxt->charset = XML_CHAR_ENCODING_UTF8;
+
         if (input->buf->encoder != NULL) {
             /*
              * Check in case the auto encoding detection triggered
@@ -1231,12 +1126,9 @@
 	    input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
         }
         return (0);
-    } else if (input->length == 0) {
-	/*
-	 * When parsing a static memory array one must know the
-	 * size to be able to convert the buffer.
-	 */
-	xmlErrInternal(ctxt, "switching encoding : no input\n", NULL);
+    } else {
+	xmlErrInternal(ctxt,
+                "static memory buffer doesn't support encoding\n", NULL);
         /*
          * Callers assume that the input buffer takes ownership of the
          * encoding handler. xmlCharEncCloseFunc frees unregistered
@@ -1245,11 +1137,6 @@
         xmlCharEncCloseFunc(handler);
 	return (-1);
     }
-    /*
-     * We should actually raise an error here, see issue #34.
-     */
-    xmlCharEncCloseFunc(handler);
-    return (0);
 }
 
 /**
@@ -1258,6 +1145,8 @@
  * @input:  the input stream
  * @handler:  the encoding handler
  *
+ * DEPRECATED: Use xmlSwitchToEncoding
+ *
  * change the input functions when discovering the character encoding
  * of a given entity.
  *
@@ -1270,41 +1159,6 @@
 }
 
 /**
- * xmlSwitchToEncodingInt:
- * @ctxt:  the parser context
- * @handler:  the encoding handler
- * @len: the length to convert or -1
- *
- * change the input functions when discovering the character encoding
- * of a given entity, and convert only @len bytes of the output, this
- * is needed on auto detect to allows any declared encoding later to
- * convert the actual content after the xmlDecl
- *
- * Returns 0 in case of success, -1 otherwise
- */
-static int
-xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
-                       xmlCharEncodingHandlerPtr handler, int len) {
-    int ret = 0;
-
-    if (handler != NULL) {
-        if (ctxt->input != NULL) {
-	    ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
-	} else {
-	    xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
-	                   NULL);
-	    return(-1);
-	}
-	/*
-	 * The parsing is now done in UTF8 natively
-	 */
-	ctxt->charset = XML_CHAR_ENCODING_UTF8;
-    } else
-	return(-1);
-    return(ret);
-}
-
-/**
  * xmlSwitchToEncoding:
  * @ctxt:  the parser context
  * @handler:  the encoding handler
@@ -1317,7 +1171,9 @@
 int
 xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 {
-    return (xmlSwitchToEncodingInt(ctxt, handler, -1));
+    if (ctxt == NULL)
+        return(-1);
+    return(xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, -1));
 }
 
 /************************************************************************
@@ -1599,7 +1455,7 @@
         return(-1);
     }
 
-    xmlDefaultSAXHandlerInit();
+    xmlInitParser();
 
     if (ctxt->dict == NULL)
 	ctxt->dict = xmlDictCreate();
diff --git a/src/pattern.c b/src/pattern.c
index 73851a1..cff4469 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -516,9 +516,6 @@
 		    goto rollback;
 		node = node->parent;
 		if ((node->type == XML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-		    (node->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
 		    (node->type == XML_HTML_DOCUMENT_NODE))
 		    continue;
 		goto rollback;
@@ -548,9 +545,6 @@
 
 		if ((node->type != XML_ELEMENT_NODE) &&
 		    (node->type != XML_DOCUMENT_NODE) &&
-#ifdef LIBXML_DOCB_ENABLED
-		    (node->type != XML_DOCB_DOCUMENT_NODE) &&
-#endif
 		    (node->type != XML_HTML_DOCUMENT_NODE))
 		    goto rollback;
 
@@ -590,9 +584,6 @@
             case XML_OP_PARENT:
 		if ((node->type == XML_DOCUMENT_NODE) ||
 		    (node->type == XML_HTML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-		    (node->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
 		    (node->type == XML_NAMESPACE_DECL))
 		    goto rollback;
 		node = node->parent;
@@ -631,9 +622,6 @@
 		    goto rollback;
 		if ((node->type == XML_DOCUMENT_NODE) ||
 		    (node->type == XML_HTML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-		    (node->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
 		    (node->type == XML_NAMESPACE_DECL))
 		    goto rollback;
 		node = node->parent;
diff --git a/src/py-compile b/src/py-compile
new file mode 100755
index 0000000..81b122b
--- /dev/null
+++ b/src/py-compile
@@ -0,0 +1,189 @@
+#!/bin/sh
+# py-compile - Compile a Python program
+
+scriptversion=2021-02-27.01; # UTC
+
+# Copyright (C) 2000-2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+if test -z "$PYTHON"; then
+  PYTHON=python
+fi
+
+me=py-compile
+
+usage_error ()
+{
+  echo "$me: $*" >&2
+  echo "Try '$me --help' for more information." >&2
+  exit 1
+}
+
+basedir=
+destdir=
+while test $# -ne 0; do
+  case "$1" in
+    --basedir)
+      if test $# -lt 2; then
+        usage_error "option '--basedir' requires an argument"
+      else
+        basedir=$2
+      fi
+      shift
+      ;;
+    --destdir)
+      if test $# -lt 2; then
+        usage_error "option '--destdir' requires an argument"
+      else
+        destdir=$2
+      fi
+      shift
+      ;;
+    -h|--help)
+      cat <<\EOF
+Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
+
+Byte compile some python scripts FILES.  Use --destdir to specify any
+leading directory path to the FILES that you don't want to include in the
+byte compiled file.  Specify --basedir for any additional path information you
+do want to be shown in the byte compiled file.
+
+Example:
+  py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+      exit $?
+      ;;
+    -v|--version)
+      echo "$me $scriptversion"
+      exit $?
+      ;;
+    --)
+      shift
+      break
+      ;;
+    -*)
+      usage_error "unrecognized option '$1'"
+      ;;
+    *)
+      break
+      ;;
+  esac
+  shift
+done
+
+files=$*
+if test -z "$files"; then
+  usage_error "no files given"
+fi
+
+# if basedir was given, then it should be prepended to filenames before
+# byte compilation.
+if test -z "$basedir"; then
+  pathtrans="path = file"
+else
+  pathtrans="path = os.path.join('$basedir', file)"
+fi
+
+# if destdir was given, then it needs to be prepended to the filename to
+# byte compile but not go into the compiled file.
+if test -z "$destdir"; then
+  filetrans="filepath = path"
+else
+  filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
+fi
+
+python_major=`$PYTHON -V 2>&1 | sed -e 's/.* //;s/\..*$//;1q'`
+if test -z "$python_major"; then
+  echo "$me: could not determine $PYTHON major version, guessing 3" >&2
+  python_major=3
+fi
+
+# The old way to import libraries was deprecated.
+if test "$python_major" -le 2; then
+  import_lib=imp
+  import_test="hasattr(imp, 'get_tag')"
+  import_call=imp.cache_from_source
+  import_arg2=', False' # needed in one call and not the other
+else
+  import_lib=importlib
+  import_test="hasattr(sys.implementation, 'cache_tag')"
+  import_call=importlib.util.cache_from_source
+  import_arg2=
+fi
+
+$PYTHON -c "
+import sys, os, py_compile, $import_lib
+
+files = '''$files'''
+
+sys.stdout.write('Byte-compiling python modules...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+	    continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    if $import_test:
+        py_compile.compile(filepath, $import_call(filepath), path)
+    else:
+        py_compile.compile(filepath, filepath + 'c', path)
+sys.stdout.write('\n')" || exit $?
+
+# this will fail for python < 1.5, but that doesn't matter ...
+$PYTHON -O -c "
+import sys, os, py_compile, $import_lib
+
+# pypy does not use .pyo optimization
+if hasattr(sys, 'pypy_translation_info'):
+    sys.exit(0)
+
+files = '''$files'''
+sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+	    continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    if $import_test:
+        py_compile.compile(filepath, $import_call(filepath$import_arg2), path)
+    else:
+        py_compile.compile(filepath, filepath + 'o', path)
+sys.stdout.write('\n')" 2>/dev/null || exit $?
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/src/regressions.py b/src/regressions.py
deleted file mode 100755
index 0e813c2..0000000
--- a/src/regressions.py
+++ /dev/null
@@ -1,350 +0,0 @@
-#!/usr/bin/python -u
-import glob, os, string, sys, thread, time
-# import difflib
-import libxml2
-
-###
-#
-# This is a "Work in Progress" attempt at a python script to run the
-# various regression tests.  The rationale for this is that it should be
-# possible to run this on most major platforms, including those (such as
-# Windows) which don't support gnu Make.
-#
-# The script is driven by a parameter file which defines the various tests
-# to be run, together with the unique settings for each of these tests.  A
-# script for Linux is included (regressions.xml), with comments indicating
-# the significance of the various parameters.  To run the tests under Windows,
-# edit regressions.xml and remove the comment around the default parameter
-# "<execpath>" (i.e. make it point to the location of the binary executables).
-#
-# Note that this current version requires the Python bindings for libxml2 to
-# have been previously installed and accessible
-#
-# See Copyright for the status of this software.
-# William Brack (wbrack@mmm.com.hk)
-#
-###
-defaultParams = {}	# will be used as a dictionary to hold the parsed params
-
-# This routine is used for comparing the expected stdout / stdin with the results.
-# The expected data has already been read in; the result is a file descriptor.
-# Within the two sets of data, lines may begin with a path string.  If so, the
-# code "relativises" it by removing the path component.  The first argument is a
-# list already read in by a separate thread; the second is a file descriptor.
-# The two 'base' arguments are to let me "relativise" the results files, allowing
-# the script to be run from any directory.
-def compFiles(res, expected, base1, base2):
-    l1 = len(base1)
-    exp = expected.readlines()
-    expected.close()
-    # the "relativisation" is done here
-    for i in range(len(res)):
-        j = string.find(res[i],base1)
-        if (j == 0) or ((j == 2) and (res[i][0:2] == './')):
-            col = string.find(res[i],':')
-            if col > 0:
-                start = string.rfind(res[i][:col], '/')
-                if start > 0:
-                    res[i] = res[i][start+1:]
-
-    for i in range(len(exp)):
-        j = string.find(exp[i],base2)
-        if (j == 0) or ((j == 2) and (exp[i][0:2] == './')):
-            col = string.find(exp[i],':')
-            if col > 0:
-                start = string.rfind(exp[i][:col], '/')
-                if start > 0:
-                    exp[i] = exp[i][start+1:]
-
-    ret = 0
-    # ideally we would like to use difflib functions here to do a
-    # nice comparison of the two sets.  Unfortunately, during testing
-    # (using python 2.3.3 and 2.3.4) the following code went into
-    # a dead loop under windows.  I'll pursue this later.
-#    diff = difflib.ndiff(res, exp)
-#    diff = list(diff)
-#    for line in diff:
-#        if line[:2] != '  ':
-#            print string.strip(line)
-#            ret = -1
-
-    # the following simple compare is fine for when the two data sets
-    # (actual result vs. expected result) are equal, which should be true for
-    # us.  Unfortunately, if the test fails it's not nice at all.
-    rl = len(res)
-    el = len(exp)
-    if el != rl:
-        print 'Length of expected is %d, result is %d' % (el, rl)
-	ret = -1
-    for i in range(min(el, rl)):
-        if string.strip(res[i]) != string.strip(exp[i]):
-            print '+:%s-:%s' % (res[i], exp[i])
-            ret = -1
-    if el > rl:
-        for i in range(rl, el):
-            print '-:%s' % exp[i]
-            ret = -1
-    elif rl > el:
-        for i in range (el, rl):
-            print '+:%s' % res[i]
-            ret = -1
-    return ret
-
-# Separate threads to handle stdout and stderr are created to run this function
-def readPfile(file, list, flag):
-    data = file.readlines()	# no call by reference, so I cheat
-    for l in data:
-        list.append(l)
-    file.close()
-    flag.append('ok')
-
-# This routine runs the test program (e.g. xmllint)
-def runOneTest(testDescription, filename, inbase, errbase):
-    if 'execpath' in testDescription:
-        dir = testDescription['execpath'] + '/'
-    else:
-        dir = ''
-    cmd = os.path.abspath(dir + testDescription['testprog'])
-    if 'flag' in testDescription:
-        for f in string.split(testDescription['flag']):
-            cmd += ' ' + f
-    if 'stdin' not in testDescription:
-        cmd += ' ' + inbase + filename
-    if 'extarg' in testDescription:
-        cmd += ' ' + testDescription['extarg']
-
-    noResult = 0
-    expout = None
-    if 'resext' in testDescription:
-        if testDescription['resext'] == 'None':
-            noResult = 1
-        else:
-            ext = '.' + testDescription['resext']
-    else:
-        ext = ''
-    if not noResult:
-        try:
-            fname = errbase + filename + ext
-            expout = open(fname, 'rt')
-        except:
-            print "Can't open result file %s - bypassing test" % fname
-            return
-
-    noErrors = 0
-    if 'reserrext' in testDescription:
-        if testDescription['reserrext'] == 'None':
-            noErrors = 1
-        else:
-            if len(testDescription['reserrext'])>0:
-                ext = '.' + testDescription['reserrext']
-            else:
-                ext = ''
-    else:
-        ext = ''
-    if not noErrors:
-        try:
-            fname = errbase + filename + ext
-            experr = open(fname, 'rt')
-        except:
-            experr = None
-    else:
-        experr = None
-
-    pin, pout, perr = os.popen3(cmd)
-    if 'stdin' in testDescription:
-        infile = open(inbase + filename, 'rt')
-        pin.writelines(infile.readlines())
-        infile.close()
-        pin.close()
-
-    # popen is great fun, but can lead to the old "deadly embrace", because
-    # synchronizing the writing (by the task being run) of stdout and stderr
-    # with respect to the reading (by this task) is basically impossible.  I
-    # tried several ways to cheat, but the only way I have found which works
-    # is to do a *very* elementary multi-threading approach.  We can only hope
-    # that Python threads are implemented on the target system (it's okay for
-    # Linux and Windows)
-
-    th1Flag = []	# flags to show when threads finish
-    th2Flag = []
-    outfile = []	# lists to contain the pipe data
-    errfile = []
-    th1 = thread.start_new_thread(readPfile, (pout, outfile, th1Flag))
-    th2 = thread.start_new_thread(readPfile, (perr, errfile, th2Flag))
-    while (len(th1Flag)==0) or (len(th2Flag)==0):
-        time.sleep(0.001)
-    if not noResult:
-        ret = compFiles(outfile, expout, inbase, 'test/')
-        if ret != 0:
-            print 'trouble with %s' % cmd
-    else:
-        if len(outfile) != 0:
-            for l in outfile:
-                print l
-            print 'trouble with %s' % cmd
-    if experr != None:
-        ret = compFiles(errfile, experr, inbase, 'test/')
-        if ret != 0:
-            print 'trouble with %s' % cmd
-    else:
-        if not noErrors:
-            if len(errfile) != 0:
-                for l in errfile:
-                    print l
-                print 'trouble with %s' % cmd
-
-    if 'stdin' not in testDescription:
-        pin.close()
-
-# This routine is called by the parameter decoding routine whenever the end of a
-# 'test' section is encountered.  Depending upon file globbing, a large number of
-# individual tests may be run.
-def runTest(description):
-    testDescription = defaultParams.copy()		# set defaults
-    testDescription.update(description)			# override with current ent
-    if 'testname' in testDescription:
-        print "## %s" % testDescription['testname']
-    if not 'file' in testDescription:
-        print "No file specified - can't run this test!"
-        return
-    # Set up the source and results directory paths from the decoded params
-    dir = ''
-    if 'srcdir' in testDescription:
-        dir += testDescription['srcdir'] + '/'
-    if 'srcsub' in testDescription:
-        dir += testDescription['srcsub'] + '/'
-
-    rdir = ''
-    if 'resdir' in testDescription:
-        rdir += testDescription['resdir'] + '/'
-    if 'ressub' in testDescription:
-        rdir += testDescription['ressub'] + '/'
-
-    testFiles = glob.glob(os.path.abspath(dir + testDescription['file']))
-    if testFiles == []:
-        print "No files result from '%s'" % testDescription['file']
-        return
-
-    # Some test programs just don't work (yet).  For now we exclude them.
-    count = 0
-    excl = []
-    if 'exclfile' in testDescription:
-        for f in string.split(testDescription['exclfile']):
-            glb = glob.glob(dir + f)
-            for g in glb:
-                excl.append(os.path.abspath(g))
-
-    # Run the specified test program
-    for f in testFiles:
-        if not os.path.isdir(f):
-            if f not in excl:
-                count = count + 1
-                runOneTest(testDescription, os.path.basename(f), dir, rdir)
-
-#
-# The following classes are used with the xmlreader interface to interpret the
-# parameter file.  Once a test section has been identified, runTest is called
-# with a dictionary containing the parsed results of the interpretation.
-#
-
-class testDefaults:
-    curText = ''	# accumulates text content of parameter
-
-    def addToDict(self, key):
-        txt = string.strip(self.curText)
-#        if txt == '':
-#            return
-        if key not in defaultParams:
-            defaultParams[key] = txt
-        else:
-            defaultParams[key] += ' ' + txt
-        
-    def processNode(self, reader, curClass):
-        if reader.Depth() == 2:
-            if reader.NodeType() == 1:
-                self.curText = ''	# clear the working variable
-            elif reader.NodeType() == 15:
-                if (reader.Name() != '#text') and (reader.Name() != '#comment'):
-                    self.addToDict(reader.Name())
-        elif reader.Depth() == 3:
-            if reader.Name() == '#text':
-                self.curText += reader.Value()
-
-        elif reader.NodeType() == 15:	# end of element
-            print "Defaults have been set to:"
-            for k in defaultParams.keys():
-                print "   %s : '%s'" % (k, defaultParams[k])
-            curClass = rootClass()
-        return curClass
-
-
-class testClass:
-    def __init__(self):
-        self.testParams = {}	# start with an empty set of params
-        self.curText = ''	# and empty text
-
-    def addToDict(self, key):
-        data = string.strip(self.curText)
-        if key not in self.testParams:
-            self.testParams[key] = data
-        else:
-            if self.testParams[key] != '':
-                data = ' ' + data
-            self.testParams[key] += data
-
-    def processNode(self, reader, curClass):
-        if reader.Depth() == 2:
-            if reader.NodeType() == 1:
-                self.curText = ''	# clear the working variable
-                if reader.Name() not in self.testParams:
-                    self.testParams[reader.Name()] = ''
-            elif reader.NodeType() == 15:
-                if (reader.Name() != '#text') and (reader.Name() != '#comment'):
-                    self.addToDict(reader.Name())
-        elif reader.Depth() == 3:
-            if reader.Name() == '#text':
-                self.curText += reader.Value()
-
-        elif reader.NodeType() == 15:	# end of element
-            runTest(self.testParams)
-            curClass = rootClass()
-        return curClass
-
-
-class rootClass:
-    def processNode(self, reader, curClass):
-        if reader.Depth() == 0:
-            return curClass
-        if reader.Depth() != 1:
-            print "Unexpected junk: Level %d, type %d, name %s" % (
-                  reader.Depth(), reader.NodeType(), reader.Name())
-            return curClass
-        if reader.Name() == 'test':
-            curClass = testClass()
-            curClass.testParams = {}
-        elif reader.Name() == 'defaults':
-            curClass = testDefaults()
-        return curClass
-
-def streamFile(filename):
-    try:
-        reader = libxml2.newTextReaderFilename(filename)
-    except:
-        print "unable to open %s" % (filename)
-        return
-
-    curClass = rootClass()
-    ret = reader.Read()
-    while ret == 1:
-        curClass = curClass.processNode(reader, curClass)
-        ret = reader.Read()
-
-    if ret != 0:
-        print "%s : failed to parse" % (filename)
-
-# OK, we're finished with all the routines.  Now for the main program:-
-if len(sys.argv) != 2:
-    print "Usage: maketest {filename}"
-    sys.exit(-1)
-
-streamFile(sys.argv[1])
diff --git a/src/regressions.xml b/src/regressions.xml
deleted file mode 100644
index c78838a..0000000
--- a/src/regressions.xml
+++ /dev/null
@@ -1,226 +0,0 @@
-<RegressionTests>
-<!--
-  Within the following test descriptions the possible elements are:
-    Element Name    Description
-     testname       Plain text name of test
-     execpath       pathname for test program(s)
-     testprog       program to run for the test 
-     flag           flags for program (may have several)
-     file           filename of input file (several, or glob ok)
-     exclfile       filename to be excuded (several, or glob ok)
-     srcdir         global source directory for input file(s)
-     srcsub         subdirectory for input
-     resdir         directory for results file(s)
-     ressub         subdirectory for results    
-     resext         extension for expected result
-     reserrext      extension for error result ('None' => no chk)
-     extarg         additional argument for command
-     errexcl        string to ignore when checking diffs
-     stdin          pipe input file to stdin
--->
-
-<!--
-  Note:  These defaults are set to run from the root of the build directory
--->
-  <defaults>
-    <testname>noname</testname>
-<!--    <execpath>win32/bin.msvc</execpath> -->
-    <execpath>.</execpath>
-    <testprog>xmllint</testprog>
-    <srcdir>test</srcdir>
-    <resdir>result</resdir>
-    <file>*.xml</file>
-    <reserrext>err</reserrext>
-    <errexcl/>
-  </defaults>
-
-  <test>
-    <testname>XML Regression Tests</testname>
-    <errexcl>failed to load external entity</errexcl>
-  </test>
-  <test>
-    <testname>XML Entity Subst Regression Tests</testname>
-    <ressub>noent</ressub>
-    <flag>--noent</flag>
-  </test>
-  <test>
-    <testname>XML Namespaces Regression Tests</testname>
-    <srcsub>namespaces</srcsub>
-    <ressub>namespaces</ressub>
-  </test>
-  <test>
-    <testname>xml:id Regression Tests</testname>
-    <testprog>testXPath</testprog>
-    <srcsub>xmlid</srcsub>
-    <ressub>xmlid</ressub>
-    <flag>-i</flag>
-    <file>id_*.xml</file>
-    <extarg>"id('bar')"</extarg>
-  </test>
-  <test>
-    <testname>Error Cases Regression Tests</testname>
-    <srcsub>errors</srcsub>
-    <ressub>errors</ressub>
-  </test>
-  <test>
-    <testname>Error Cases Stream Regression Tests</testname>
-    <srcsub>errors</srcsub>
-    <ressub>errors</ressub>
-    <reserrext>str</reserrext>
-    <flag>--stream</flag>
-  </test>
-  <test>
-    <testname>Reader Regression Tests</testname>
-    <resext>rdr</resext>
-    <flag>--nonet</flag>
-    <flag>--debug</flag>
-    <flag>--stream</flag>
-    <file>*</file>
-    <reserrext>None</reserrext>
-  </test>
-  <test>
-    <testname>Walker Regression Tests</testname>
-    <resext>rdr</resext>
-    <flag>--nonet</flag>
-    <flag>--debug</flag>
-    <flag>--walker</flag>
-    <file>*</file>
-    <reserrext>None</reserrext>
-  </test>
-  <test>
-    <testname>Reader Entities Substitution Regression Tests</testname>
-    <resext>rde</resext>
-    <flag>--nonet</flag>
-    <flag>--debug</flag>
-    <flag>--stream</flag>
-    <flag>--noent</flag>
-    <file>*</file>
-    <reserrext>None</reserrext>
-  </test>
-  <test>
-    <testname>SAX Callbacks Regression Tests</testname>
-    <testprog>testSAX</testprog>
-    <resext>sax</resext>
-    <file>*</file>
-    <exclfile>utf16*.xml</exclfile>
-    <reserrext>None</reserrext>
-  </test>
-  <test>
-    <testname>XML Push Regression Tests</testname>
-    <flag>--push</flag>
-    <errexcl>failed to load external entity</errexcl>
-  </test>
-  <test>
-    <testname>HTML Regression Tests</testname>
-    <testprog>testHTML</testprog>
-    <srcsub>HTML</srcsub>
-    <ressub>HTML</ressub>
-    <file>*</file>
-    <exclfile>wired.html</exclfile>
-  </test>
-  <test>
-    <testname>Push HTML Regression Tests</testname>
-    <testprog>testHTML</testprog>
-    <flag>--push</flag>
-    <srcsub>HTML</srcsub>
-    <ressub>HTML</ressub>
-    <file>*</file>
-  </test>
-  <test>
-    <testname>HTML SAX Regression Tests</testname>
-    <testprog>testHTML</testprog>
-    <flag>--sax</flag>
-    <srcsub>HTML</srcsub>
-    <ressub>HTML</ressub>
-    <resext>sax</resext>
-    <reserrext>None</reserrext>
-    <file>*</file>
-  </test>
-  <test>
-    <testname>Push HTML SAX Regression Tests</testname>
-    <testprog>testHTML</testprog>
-    <flag>--sax</flag>
-    <flag>--push</flag>
-    <srcsub>HTML</srcsub>
-    <ressub>HTML</ressub>
-    <resext>sax</resext>
-    <reserrext>None</reserrext>
-    <file>*</file>
-  </test>
-  <test>
-    <testname>Valid Documents Regression Tests</testname>
-    <srcsub>VCM</srcsub>
-    <ressub>VCM</ressub>
-    <resext>None</resext>
-    <reserrext>None</reserrext>
-    <file>*</file>
-    <flag>--valid</flag>
-    <flag>--noout</flag>
-    <flag>--nowarning</flag>
-  </test>
-  <test>
-    <testname>Validity Checking Regression Tests</testname>
-    <srcsub>VC</srcsub>
-    <ressub>VC</ressub>
-    <resext>None</resext>
-    <reserrext/>
-    <file>*</file>
-    <flag>--valid</flag>
-    <flag>--noout</flag>
-  </test>
-  <test>
-    <testname>General Documents Valid Regression Tests</testname>
-    <srcsub>valid</srcsub>
-    <ressub>valid</ressub>
-    <file>*</file>
-    <flag>--valid</flag>
-  </test>
-  <test>
-    <testname>URI Module Regression Tests (1)</testname>
-    <testprog>testURI</testprog>
-    <srcsub>URI</srcsub>
-    <stdin/>
-    <ressub>URI</ressub>
-    <reserrext>None</reserrext>
-    <file>*.data</file>
-    <!-- Note - the following arg needs to use ", not ' -->
-    <flag>-base "http://foo.com/path/to/index.html?orig#help"</flag>
-  </test>
-  <test>
-    <testname>URI Module Regression Tests (2)</testname>
-    <testprog>testURI</testprog>
-    <srcsub>URI</srcsub>
-    <stdin/>
-    <ressub>URI</ressub>
-    <reserrext>None</reserrext>
-    <file>*.uri</file>
-  </test>
-  <test>
-    <testname>XPath Regression Tests (1)</testname>
-    <testprog>testXPath</testprog>
-    <srcsub>XPath/expr</srcsub>
-    <ressub>XPath/expr</ressub>
-    <file>*</file>
-    <flag>-f</flag>
-    <flag>--expr</flag>
-  </test>
-  <test>
-    <testname>XInclude Regression Tests</testname>
-    <srcsub>XInclude/docs</srcsub>
-    <ressub>XInclude</ressub>
-    <file>*</file>
-    <flag>--nowarning</flag>
-    <flag>--xinclude</flag>
-  </test>
-  <test>
-    <testname>XInclude xmlReader Regression Tests</testname>
-    <srcsub>XInclude/docs</srcsub>
-    <ressub>XInclude</ressub>
-    <resext>rdr</resext>
-    <file>*</file>
-    <flag>--nowarning</flag>
-    <flag>--xinclude</flag>
-    <flag>--stream</flag>
-    <flag>--debug</flag>
-  </test>
-</RegressionTests>
diff --git a/src/runsuite.c b/src/runsuite.c
index f7957ce..483490a 100644
--- a/src/runsuite.c
+++ b/src/runsuite.c
@@ -325,6 +325,7 @@
         fprintf(stderr, "out of memory !\n");
 	fatalError();
     }
+    xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlNodeDump(buf, test->doc, test, 0, 0);
     pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use);
     xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler,
@@ -363,6 +364,7 @@
         fprintf(stderr, "out of memory !\n");
 	fatalError();
     }
+    xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlNodeDump(buf, tst->doc, tst, 0, 0);
 
     while (tst != NULL) {
@@ -458,6 +460,7 @@
         fprintf(stderr, "out of memory !\n");
 	fatalError();
     }
+    xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlNodeDump(buf, test->doc, test, 0, 0);
     pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use);
     xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler,
diff --git a/src/runtest.c b/src/runtest.c
index 2644348..31bb5c6 100644
--- a/src/runtest.c
+++ b/src/runtest.c
@@ -531,7 +531,6 @@
 
 static void
 initializeLibxml2(void) {
-    xmlGetWarningsDefaultValue = 0;
     xmlPedanticParserDefault(0);
 
     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
@@ -611,7 +610,7 @@
 }
 
 static int compareFiles(const char *r1 /* temp */, const char *r2 /* result */) {
-    int res1, res2;
+    int res1, res2, total;
     int fd1, fd2;
     char bytes1[4096];
     char bytes2[4096];
@@ -625,16 +624,20 @@
             close(fd1);
             return(-1);
         }
+        total = 0;
         do {
             res1 = read(fd1, bytes1, 4096);
             if (res1 <= 0)
                 break;
+            total += res1;
             res2 = write(fd2, bytes1, res1);
             if (res2 <= 0 || res2 != res1)
                 break;
         } while (1);
         close(fd2);
         close(fd1);
+        if (total == 0)
+            unlink(r2);
         return(res1 != 0);
     }
 
@@ -642,28 +645,27 @@
     if (fd1 < 0)
         return(-1);
     fd2 = open(r2, RD_FLAGS);
-    if (fd2 < 0) {
-        close(fd1);
-        return(-1);
-    }
     while (1) {
         res1 = read(fd1, bytes1, 4096);
-        res2 = read(fd2, bytes2, 4096);
+        res2 = fd2 >= 0 ? read(fd2, bytes2, 4096) : 0;
 	if ((res1 != res2) || (res1 < 0)) {
 	    close(fd1);
-	    close(fd2);
+            if (fd2 >= 0)
+                close(fd2);
 	    return(1);
 	}
 	if (res1 == 0)
 	    break;
 	if (memcmp(bytes1, bytes2, res1) != 0) {
 	    close(fd1);
-	    close(fd2);
+            if (fd2 >= 0)
+                close(fd2);
 	    return(1);
 	}
     }
     close(fd1);
-    close(fd2);
+    if (fd2 >= 0)
+        close(fd2);
     return(0);
 }
 
@@ -675,6 +677,10 @@
     struct stat info;
 
     if (update_results) {
+        if (size == 0) {
+            unlink(filename);
+            return(0);
+        }
         fd = open(filename, WR_FLAGS, 0644);
         if (fd < 0) {
 	    fprintf(stderr, "failed to open %s for writing", filename);
@@ -686,6 +692,8 @@
     }
 
     if (stat(filename, &info) < 0) {
+        if (size == 0)
+            return(0);
         fprintf(stderr, "failed to stat %s\n", filename);
 	return(-1);
     }
@@ -2091,10 +2099,8 @@
     } else
 #endif
     {
-	xmlGetWarningsDefaultValue = 1;
 	doc = xmlReadFile(filename, NULL, options);
     }
-    xmlGetWarningsDefaultValue = 0;
     if (result) {
 	if (doc == NULL) {
 	    base = "";
@@ -2157,11 +2163,9 @@
     } else
 #endif
     {
-	xmlGetWarningsDefaultValue = 1;
 	doc = xmlReadFd(fd, filename, NULL, options);
     }
     close(fd);
-    xmlGetWarningsDefaultValue = 0;
     if (result) {
 	if (doc == NULL) {
 	    base = "";
@@ -2274,7 +2278,6 @@
 	}
     }
 #endif
-    xmlGetWarningsDefaultValue = 1;
     ret = xmlTextReaderRead(reader);
     while (ret == 1) {
 	if ((t != NULL) && (rng == NULL))
@@ -2291,7 +2294,6 @@
 	    testErrorHandler(NULL, "%s validates\n", filename);
 	}
     }
-    xmlGetWarningsDefaultValue = 0;
     if (t != NULL) {
         fclose(t);
 	ret = compareFiles(temp, result);
@@ -2927,7 +2929,7 @@
  */
 static int
 uripMatch(const char * URI) {
-    if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog")))
+    if ((URI == NULL) || (!strcmp(URI, "file://" SYSCONFDIR "/xml/catalog")))
         return(0);
     /* Verify we received the escaped URL */
     if (strcmp(urip_rcvsURLs[urip_current], URI))
@@ -2946,7 +2948,7 @@
  */
 static void *
 uripOpen(const char * URI) {
-    if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog")))
+    if ((URI == NULL) || (!strcmp(URI, "file://" SYSCONFDIR "/xml/catalog")))
         return(NULL);
     /* Verify we received the escaped URL */
     if (strcmp(urip_rcvsURLs[urip_current], URI))
@@ -3063,7 +3065,6 @@
 schemasOneTest(const char *sch,
                const char *filename,
                const char *result,
-	       const char *err,
 	       int options,
 	       xmlSchemaPtr schemas) {
     xmlDocPtr doc;
@@ -3115,13 +3116,6 @@
         free(temp);
     }
 
-    if ((validResult != 0) && (err != NULL)) {
-	if (compareFileMem(err, testErrors, testErrorsSize)) {
-	    fprintf(stderr, "Error for %s on %s failed\n", filename, sch);
-	    ret = 1;
-	}
-    }
-
     xmlSchemaFreeValidCtxt(ctxt);
     xmlFreeDoc(doc);
     return(ret);
@@ -3148,6 +3142,7 @@
     xmlSchemaParserCtxtPtr ctxt;
     xmlSchemaPtr schemas;
     int res = 0, len, ret;
+    int parseErrorsSize;
     char pattern[500];
     char prefix[500];
     char result[500];
@@ -3161,6 +3156,7 @@
     xmlSchemaSetParserErrors(ctxt, testErrorHandler, testErrorHandler, ctxt);
     schemas = xmlSchemaParse(ctxt);
     xmlSchemaFreeParserCtxt(ctxt);
+    parseErrorsSize = testErrorsSize;
 
     /*
      * most of the mess is about the output filenames generated by the Makefile
@@ -3180,7 +3176,7 @@
     memcpy(prefix, base, len);
     prefix[len] = 0;
 
-    if (snprintf(pattern, 499, "./test/schemas/%s_?.xml", prefix) >= 499)
+    if (snprintf(pattern, 499, "./test/schemas/%s_*.xml", prefix) >= 499)
         pattern[499] = 0;
 
     if (base[len] == '_') {
@@ -3192,8 +3188,8 @@
     globbuf.gl_offs = 0;
     glob(pattern, GLOB_DOOFFS, NULL, &globbuf);
     for (i = 0;i < globbuf.gl_pathc;i++) {
-        testErrorsSize = 0;
-	testErrors[0] = 0;
+        testErrorsSize = parseErrorsSize;
+        testErrors[parseErrorsSize] = 0;
         instance = globbuf.gl_pathv[i];
 	base2 = baseFilename(instance);
 	len = strlen(base2);
@@ -3211,14 +3207,17 @@
 	    fprintf(stderr, "don't know how to process %s\n", instance);
 	    continue;
 	}
-	if (schemas == NULL) {
-	} else {
+	if (schemas != NULL) {
 	    nb_tests++;
-	    ret = schemasOneTest(filename, instance, result, err,
-	                         options, schemas);
+	    ret = schemasOneTest(filename, instance, result, options, schemas);
 	    if (ret != 0)
 		res = ret;
 	}
+        if (compareFileMem(err, testErrors, testErrorsSize)) {
+            fprintf(stderr, "Error for %s on %s failed\n", instance,
+                    filename);
+            res = 1;
+        }
     }
     globfree(&globbuf);
     xmlSchemaFree(schemas);
@@ -3235,7 +3234,6 @@
 rngOneTest(const char *sch,
                const char *filename,
                const char *result,
-	       const char *err,
 	       int options,
 	       xmlRelaxNGPtr schemas) {
     xmlDocPtr doc;
@@ -3287,15 +3285,6 @@
         free(temp);
     }
 
-    if (err != NULL) {
-	if (compareFileMem(err, testErrors, testErrorsSize)) {
-	    fprintf(stderr, "Error for %s on %s failed\n", filename, sch);
-	    ret = 1;
-	    printf("%s", testErrors);
-	}
-    }
-
-
     xmlRelaxNGFreeValidCtxt(ctxt);
     xmlFreeDoc(doc);
     return(ret);
@@ -3321,6 +3310,7 @@
     xmlRelaxNGParserCtxtPtr ctxt;
     xmlRelaxNGPtr schemas;
     int res = 0, len, ret = 0;
+    int parseErrorsSize;
     char pattern[500];
     char prefix[500];
     char result[500];
@@ -3334,6 +3324,10 @@
     xmlRelaxNGSetParserErrors(ctxt, testErrorHandler, testErrorHandler, ctxt);
     schemas = xmlRelaxNGParse(ctxt);
     xmlRelaxNGFreeParserCtxt(ctxt);
+    if (schemas == NULL)
+        testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n",
+                         filename);
+    parseErrorsSize = testErrorsSize;
 
     /*
      * most of the mess is about the output filenames generated by the Makefile
@@ -3353,8 +3347,8 @@
     globbuf.gl_offs = 0;
     glob(pattern, GLOB_DOOFFS, NULL, &globbuf);
     for (i = 0;i < globbuf.gl_pathc;i++) {
-        testErrorsSize = 0;
-	testErrors[0] = 0;
+        testErrorsSize = parseErrorsSize;
+        testErrors[parseErrorsSize] = 0;
         instance = globbuf.gl_pathv[i];
 	base2 = baseFilename(instance);
 	len = strlen(base2);
@@ -3372,14 +3366,17 @@
 	    fprintf(stderr, "don't know how to process %s\n", instance);
 	    continue;
 	}
-	if (schemas == NULL) {
-	} else {
+	if (schemas != NULL) {
 	    nb_tests++;
-	    res = rngOneTest(filename, instance, result, err,
-	                         options, schemas);
+	    res = rngOneTest(filename, instance, result, options, schemas);
 	    if (res != 0)
 		ret = res;
 	}
+        if (compareFileMem(err, testErrors, testErrorsSize)) {
+            fprintf(stderr, "Error for %s on %s failed\n", instance,
+                    filename);
+            res = 1;
+        }
     }
     globfree(&globbuf);
     xmlRelaxNGFree(schemas);
@@ -3591,10 +3588,6 @@
 	fprintf(stderr, "Missing xml file %s\n", xml);
 	return(-1);
     }
-    if (!checkTestFile(result) && !update_results) {
-	fprintf(stderr, "Missing result file %s\n", result);
-	return(-1);
-    }
     f = fopen(filename, "rb");
     if (f == NULL) {
         fprintf(stderr, "Failed to open %s\n", filename);
@@ -3963,10 +3956,6 @@
 
     if (snprintf(buf, 499, "result/c14n/%s/%s", subdir, prefix) >= 499)
         buf[499] = 0;
-    if (!checkTestFile(buf) && !update_results) {
-        fprintf(stderr, "Missing result file %s", buf);
-	return(-1);
-    }
     result = strdup(buf);
     if (snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir, prefix) >= 499)
         buf[499] = 0;
@@ -4297,6 +4286,113 @@
     return(testThread());
 }
 #endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+/************************************************************************
+ *									*
+ *			Regexp tests					*
+ *									*
+ ************************************************************************/
+
+static void testRegexp(FILE *output, xmlRegexpPtr comp, const char *value) {
+    int ret;
+
+    ret = xmlRegexpExec(comp, (const xmlChar *) value);
+    if (ret == 1)
+	fprintf(output, "%s: Ok\n", value);
+    else if (ret == 0)
+	fprintf(output, "%s: Fail\n", value);
+    else
+	fprintf(output, "%s: Error: %d\n", value, ret);
+}
+
+static int
+regexpTest(const char *filename, const char *result, const char *err,
+	   int options ATTRIBUTE_UNUSED) {
+    xmlRegexpPtr comp = NULL;
+    FILE *input, *output;
+    char *temp;
+    char expression[5000];
+    int len, ret, res = 0;
+
+    input = fopen(filename, "r");
+    if (input == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+		"Cannot open %s for reading\n", filename);
+	return(-1);
+    }
+    temp = resultFilename(filename, "", ".res");
+    if (temp == NULL) {
+        fprintf(stderr, "Out of memory\n");
+        fatalError();
+    }
+    output = fopen(temp, "wb");
+    if (output == NULL) {
+	fprintf(stderr, "failed to open output file %s\n", temp);
+        free(temp);
+	return(-1);
+    }
+    while (fgets(expression, 4500, input) != NULL) {
+	len = strlen(expression);
+	len--;
+	while ((len >= 0) &&
+	       ((expression[len] == '\n') || (expression[len] == '\t') ||
+		(expression[len] == '\r') || (expression[len] == ' '))) len--;
+	expression[len + 1] = 0;
+	if (len >= 0) {
+	    if (expression[0] == '#')
+		continue;
+	    if ((expression[0] == '=') && (expression[1] == '>')) {
+		char *pattern = &expression[2];
+
+		if (comp != NULL) {
+		    xmlRegFreeRegexp(comp);
+		    comp = NULL;
+		}
+		fprintf(output, "Regexp: %s\n", pattern) ;
+		comp = xmlRegexpCompile((const xmlChar *) pattern);
+		if (comp == NULL) {
+		    fprintf(output, "   failed to compile\n");
+		    break;
+		}
+	    } else if (comp == NULL) {
+		fprintf(output, "Regexp: %s\n", expression) ;
+		comp = xmlRegexpCompile((const xmlChar *) expression);
+		if (comp == NULL) {
+		    fprintf(output, "   failed to compile\n");
+		    break;
+		}
+	    } else if (comp != NULL) {
+		testRegexp(output, comp, expression);
+	    }
+	}
+    }
+    fclose(output);
+    fclose(input);
+    if (comp != NULL)
+	xmlRegFreeRegexp(comp);
+
+    ret = compareFiles(temp, result);
+    if (ret) {
+        fprintf(stderr, "Result for %s failed in %s\n", filename, result);
+        res = 1;
+    }
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
+
+    ret = compareFileMem(err, testErrors, testErrorsSize);
+    if (ret != 0) {
+        fprintf(stderr, "Error for %s failed\n", filename);
+        res = 1;
+    }
+
+    return(res);
+}
+
+#endif
+
 /************************************************************************
  *									*
  *			Tests Descriptions				*
@@ -4491,6 +4587,14 @@
       threadsTest, NULL, NULL, NULL, NULL,
       0 },
 #endif
+    { "SVG parsing regression tests" ,
+      oldParseTest, "./test/SVG/*.xml", "result/SVG/", "", NULL,
+      0 },
+#if defined(LIBXML_REGEXP_ENABLED)
+    { "Regexp regression tests" ,
+      regexpTest, "./test/regexp/*", "result/regexp/", "", ".err",
+      0 },
+#endif
     {NULL, NULL, NULL, NULL, NULL, NULL, 0}
 };
 
@@ -4546,35 +4650,29 @@
 	    } else {
 	        error = NULL;
 	    }
-	    if ((result) &&(!checkTestFile(result)) && !update_results) {
-	        fprintf(stderr, "Missing result file %s\n", result);
-	    } else if ((error) &&(!checkTestFile(error)) && !update_results) {
-	        fprintf(stderr, "Missing error file %s\n", error);
-	    } else {
-		mem = xmlMemUsed();
-		extraMemoryFromResolver = 0;
-		testErrorsSize = 0;
-		testErrors[0] = 0;
-		res = tst->func(globbuf.gl_pathv[i], result, error,
-		                tst->options | XML_PARSE_COMPACT);
-		xmlResetLastError();
-		if (res != 0) {
-		    fprintf(stderr, "File %s generated an error\n",
-		            globbuf.gl_pathv[i]);
-		    nb_errors++;
-		    err++;
-		}
-		else if (xmlMemUsed() != mem) {
-		    if ((xmlMemUsed() != mem) &&
-		        (extraMemoryFromResolver == 0)) {
-			fprintf(stderr, "File %s leaked %d bytes\n",
-				globbuf.gl_pathv[i], xmlMemUsed() - mem);
-			nb_leaks++;
-			err++;
-		    }
-		}
-		testErrorsSize = 0;
-	    }
+            mem = xmlMemUsed();
+            extraMemoryFromResolver = 0;
+            testErrorsSize = 0;
+            testErrors[0] = 0;
+            res = tst->func(globbuf.gl_pathv[i], result, error,
+                            tst->options | XML_PARSE_COMPACT);
+            xmlResetLastError();
+            if (res != 0) {
+                fprintf(stderr, "File %s generated an error\n",
+                        globbuf.gl_pathv[i]);
+                nb_errors++;
+                err++;
+            }
+            else if (xmlMemUsed() != mem) {
+                if ((xmlMemUsed() != mem) &&
+                    (extraMemoryFromResolver == 0)) {
+                    fprintf(stderr, "File %s leaked %d bytes\n",
+                            globbuf.gl_pathv[i], xmlMemUsed() - mem);
+                    nb_leaks++;
+                    err++;
+                }
+            }
+            testErrorsSize = 0;
 	    if (result)
 		free(result);
 	    if (error)
diff --git a/src/testAutomata.c b/src/testAutomata.c
index b89611c..8d3cb27 100644
--- a/src/testAutomata.c
+++ b/src/testAutomata.c
@@ -216,7 +216,7 @@
 
 int main(int argc, char **argv) {
 
-    xmlInitMemory();
+    xmlInitParser();
 
     if (argc == 1) {
 	int ret;
diff --git a/src/testC14N.c b/src/testC14N.c
deleted file mode 100644
index ebd9fe0..0000000
--- a/src/testC14N.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Canonical XML implementation test program
- * (http://www.w3.org/TR/2001/REC-xml-c14n-20010315)
- *
- * See Copyright for the status of this software.
- *
- * Author: Aleksey Sanin <aleksey@aleksey.com>
- */
-#include "libxml.h"
-#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef STDOUT_FILENO
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#else
-#define STDOUT_FILENO fileno(stdout)
-#endif /* HAVE_UNISTD_H */
-#endif
-#ifdef _WIN32
-#include <io.h>
-#endif
-
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-#include <libxml/c14n.h>
-
-
-static void usage(const char *name) {
-    fprintf(stderr,
-	"Usage: %s <mode> <xml-file> [<xpath-expr>] [<inclusive-ns-list>]\n",
-	    name);
-    fprintf(stderr, "where <mode> is one of following:\n");
-    fprintf(stderr,
-	"--with-comments       \t XML file canonicalization v1.0 w comments \n");
-    fprintf(stderr,
-	"--without-comments    \t XML file canonicalization v1.0 w/o comments\n");
-    fprintf(stderr,
-	"--1-1-with-comments       \t XML file canonicalization v1.1 w comments\n");
-    fprintf(stderr,
-	"--1-1-without-comments    \t XML file canonicalization v1.1 w/o comments\n");
-    fprintf(stderr,
-    "--exc-with-comments   \t Exclusive XML file canonicalization v1.0 w comments\n");
-    fprintf(stderr,
-    "--exc-without-comments\t Exclusive XML file canonicalization v1.0 w/o comments\n");
-}
-
-static xmlXPathObjectPtr
-load_xpath_expr (xmlDocPtr parent_doc, const char* filename);
-
-static xmlChar **parse_list(xmlChar *str);
-
-/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */
-
-static int
-test_c14n(const char* xml_filename, int with_comments, int mode,
-	const char* xpath_filename, xmlChar **inclusive_namespaces) {
-    xmlDocPtr doc;
-    xmlXPathObjectPtr xpath = NULL;
-    xmlChar *result = NULL;
-    int ret;
-
-    /*
-     * build an XML tree from a the file; we need to add default
-     * attributes and resolve all character and entities references
-     */
-    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-    xmlSubstituteEntitiesDefault(1);
-
-    doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
-    if (doc == NULL) {
-	fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
-	return(-1);
-    }
-
-    /*
-     * Check the document is of the right kind
-     */
-    if(xmlDocGetRootElement(doc) == NULL) {
-        fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
-	xmlFreeDoc(doc);
-	return(-1);
-    }
-
-    /*
-     * load xpath file if specified
-     */
-    if(xpath_filename) {
-	xpath = load_xpath_expr(doc, xpath_filename);
-	if(xpath == NULL) {
-	    fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-	    xmlFreeDoc(doc);
-	    return(-1);
-	}
-    }
-
-    /*
-     * Canonical form
-     */
-    /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
-    ret = xmlC14NDocDumpMemory(doc,
-	    (xpath) ? xpath->nodesetval : NULL,
-	    mode, inclusive_namespaces,
-	    with_comments, &result);
-    if(ret >= 0) {
-	if(result != NULL) {
-	    if (write(STDOUT_FILENO, result, ret) == -1) {
-		fprintf(stderr, "Can't write data\n");
-	    }
-	    xmlFree(result);
-	}
-    } else {
-	fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
-	if(result != NULL) xmlFree(result);
-	xmlFreeDoc(doc);
-	return(-1);
-    }
-
-    /*
-     * Cleanup
-     */
-    if(xpath != NULL) xmlXPathFreeObject(xpath);
-    xmlFreeDoc(doc);
-
-    return(ret);
-}
-
-int main(int argc, char **argv) {
-    int ret = -1;
-
-    /*
-     * Init libxml
-     */
-    xmlInitParser();
-    LIBXML_TEST_VERSION
-
-    /*
-     * Parse command line and process file
-     */
-    if( argc < 3 ) {
-	fprintf(stderr, "Error: wrong number of arguments.\n");
-	usage(argv[0]);
-    } else if(strcmp(argv[1], "--with-comments") == 0) {
-	ret = test_c14n(argv[2], 1, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
-    } else if(strcmp(argv[1], "--without-comments") == 0) {
-	ret = test_c14n(argv[2], 0, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
-    } else if(strcmp(argv[1], "--1-1-with-comments") == 0) {
-	ret = test_c14n(argv[2], 1, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
-    } else if(strcmp(argv[1], "--1-1-without-comments") == 0) {
-	ret = test_c14n(argv[2], 0, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
-    } else if(strcmp(argv[1], "--exc-with-comments") == 0) {
-	xmlChar **list;
-
-	/* load exclusive namespace from command line */
-	list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
-	ret = test_c14n(argv[2], 1, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
-	if(list != NULL) xmlFree(list);
-    } else if(strcmp(argv[1], "--exc-without-comments") == 0) {
-	xmlChar **list;
-
-	/* load exclusive namespace from command line */
-	list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
-	ret = test_c14n(argv[2], 0, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
-	if(list != NULL) xmlFree(list);
-    } else {
-	fprintf(stderr, "Error: bad option.\n");
-	usage(argv[0]);
-    }
-
-    /*
-     * Shutdown libxml
-     */
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return((ret >= 0) ? 0 : 1);
-}
-
-/*
- * Macro used to grow the current buffer.
- */
-#define growBufferReentrant() {						\
-    buffer_size *= 2;							\
-    buffer = (xmlChar **)						\
-		xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
-    if (buffer == NULL) {						\
-	perror("realloc failed");					\
-	return(NULL);							\
-    }									\
-}
-
-static xmlChar **
-parse_list(xmlChar *str) {
-    xmlChar **buffer;
-    xmlChar **out = NULL;
-    int buffer_size = 0;
-    int len;
-
-    if(str == NULL) {
-	return(NULL);
-    }
-
-    len = xmlStrlen(str);
-    if((str[0] == '\'') && (str[len - 1] == '\'')) {
-	str[len - 1] = '\0';
-	str++;
-    }
-    /*
-     * allocate an translation buffer.
-     */
-    buffer_size = 1000;
-    buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*));
-    if (buffer == NULL) {
-	perror("malloc failed");
-	return(NULL);
-    }
-    out = buffer;
-
-    while(*str != '\0') {
-	if (out - buffer > buffer_size - 10) {
-	    int indx = out - buffer;
-
-	    growBufferReentrant();
-	    out = &buffer[indx];
-	}
-	(*out++) = str;
-	while(*str != ',' && *str != '\0') ++str;
-	if(*str == ',') *(str++) = '\0';
-    }
-    (*out) = NULL;
-    return buffer;
-}
-
-static xmlXPathObjectPtr
-load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
-    xmlXPathObjectPtr xpath;
-    xmlDocPtr doc;
-    xmlChar *expr;
-    xmlXPathContextPtr ctx;
-    xmlNodePtr node;
-    xmlNsPtr ns;
-
-    /*
-     * load XPath expr as a file
-     */
-    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-    xmlSubstituteEntitiesDefault(1);
-
-    doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
-    if (doc == NULL) {
-	fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
-	return(NULL);
-    }
-
-    /*
-     * Check the document is of the right kind
-     */
-    if(xmlDocGetRootElement(doc) == NULL) {
-        fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
-	xmlFreeDoc(doc);
-	return(NULL);
-    }
-
-    node = doc->children;
-    while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
-	node = node->next;
-    }
-
-    if(node == NULL) {
-        fprintf(stderr,"Error: XPath element expected in the file  \"%s\"\n", filename);
-	xmlFreeDoc(doc);
-	return(NULL);
-    }
-
-    expr = xmlNodeGetContent(node);
-    if(expr == NULL) {
-        fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename);
-	xmlFreeDoc(doc);
-	return(NULL);
-    }
-
-    ctx = xmlXPathNewContext(parent_doc);
-    if(ctx == NULL) {
-        fprintf(stderr,"Error: unable to create new context\n");
-        xmlFree(expr);
-        xmlFreeDoc(doc);
-        return(NULL);
-    }
-
-    /*
-     * Register namespaces
-     */
-    ns = node->nsDef;
-    while(ns != NULL) {
-	if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
-	    fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
-	    xmlFree(expr);
-	    xmlXPathFreeContext(ctx);
-	    xmlFreeDoc(doc);
-	    return(NULL);
-	}
-	ns = ns->next;
-    }
-
-    /*
-     * Evaluate xpath
-     */
-    xpath = xmlXPathEvalExpression(expr, ctx);
-    if(xpath == NULL) {
-        fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-	xmlFree(expr);
-        xmlXPathFreeContext(ctx);
-        xmlFreeDoc(doc);
-        return(NULL);
-    }
-
-    /* print_xpath_nodes(xpath->nodesetval); */
-
-    xmlFree(expr);
-    xmlXPathFreeContext(ctx);
-    xmlFreeDoc(doc);
-    return(xpath);
-}
-
-/*
-static void
-print_xpath_nodes(xmlNodeSetPtr nodes) {
-    xmlNodePtr cur;
-    int i;
-
-    if(nodes == NULL ){
-	fprintf(stderr, "Error: no nodes set defined\n");
-	return;
-    }
-
-    fprintf(stderr, "Nodes Set:\n-----\n");
-    for(i = 0; i < nodes->nodeNr; ++i) {
-	if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
-	    xmlNsPtr ns;
-
-	    ns = (xmlNsPtr)nodes->nodeTab[i];
-	    cur = (xmlNodePtr)ns->next;
-	    fprintf(stderr, "namespace \"%s\"=\"%s\" for node %s:%s\n",
-		    ns->prefix, ns->href,
-		    (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name);
-	} else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
-	    cur = nodes->nodeTab[i];
-	    fprintf(stderr, "element node \"%s:%s\"\n",
-		    (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name);
-	} else {
-	    cur = nodes->nodeTab[i];
-	    fprintf(stderr, "node \"%s\": type %d\n", cur->name, cur->type);
-	}
-    }
-}
-*/
-
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : XPath/Canonicalization and output support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_C14N_ENABLED */
-
-
diff --git a/src/testHTML.c b/src/testHTML.c
deleted file mode 100644
index 5d17590..0000000
--- a/src/testHTML.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * testHTML.c : a small tester program for HTML input.
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include "libxml.h"
-
-#ifdef LIBXML_HTML_ENABLED
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <libxml/xmlmemory.h>
-#include <libxml/HTMLparser.h>
-#include <libxml/HTMLtree.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlerror.h>
-#include <libxml/globals.h>
-
-#ifdef LIBXML_DEBUG_ENABLED
-static int debug = 0;
-#endif
-static int copy = 0;
-static int sax = 0;
-static int repeat = 0;
-static int noout = 0;
-#ifdef LIBXML_PUSH_ENABLED
-static int push = 0;
-#endif /* LIBXML_PUSH_ENABLED */
-static char *encoding = NULL;
-static int options = 0;
-
-static xmlSAXHandler emptySAXHandlerStruct = {
-    NULL, /* internalSubset */
-    NULL, /* isStandalone */
-    NULL, /* hasInternalSubset */
-    NULL, /* hasExternalSubset */
-    NULL, /* resolveEntity */
-    NULL, /* getEntity */
-    NULL, /* entityDecl */
-    NULL, /* notationDecl */
-    NULL, /* attributeDecl */
-    NULL, /* elementDecl */
-    NULL, /* unparsedEntityDecl */
-    NULL, /* setDocumentLocator */
-    NULL, /* startDocument */
-    NULL, /* endDocument */
-    NULL, /* startElement */
-    NULL, /* endElement */
-    NULL, /* reference */
-    NULL, /* characters */
-    NULL, /* ignorableWhitespace */
-    NULL, /* processingInstruction */
-    NULL, /* comment */
-    NULL, /* xmlParserWarning */
-    NULL, /* xmlParserError */
-    NULL, /* xmlParserError */
-    NULL, /* getParameterEntity */
-    NULL, /* cdataBlock */
-    NULL, /* externalSubset */
-    1,    /* initialized */
-    NULL, /* private */
-    NULL, /* startElementNsSAX2Func */
-    NULL, /* endElementNsSAX2Func */
-    NULL  /* xmlStructuredErrorFunc */
-};
-
-static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
-extern xmlSAXHandlerPtr debugSAXHandler;
-
-/************************************************************************
- *									*
- *				Debug Handlers				*
- *									*
- ************************************************************************/
-
-/**
- * isStandaloneDebug:
- * @ctxt:  An XML parser context
- *
- * Is this document tagged standalone ?
- *
- * Returns 1 if true
- */
-static int
-isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.isStandalone()\n");
-    return(0);
-}
-
-/**
- * hasInternalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an internal subset
- *
- * Returns 1 if true
- */
-static int
-hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.hasInternalSubset()\n");
-    return(0);
-}
-
-/**
- * hasExternalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an external subset
- *
- * Returns 1 if true
- */
-static int
-hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.hasExternalSubset()\n");
-    return(0);
-}
-
-/**
- * hasInternalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an internal subset
- */
-static void
-internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-	       const xmlChar *ExternalID, const xmlChar *SystemID)
-{
-    fprintf(stdout, "SAX.internalSubset(%s,", name);
-    if (ExternalID == NULL)
-	fprintf(stdout, " ,");
-    else
-	fprintf(stdout, " %s,", ExternalID);
-    if (SystemID == NULL)
-	fprintf(stdout, " )\n");
-    else
-	fprintf(stdout, " %s)\n", SystemID);
-}
-
-/**
- * resolveEntityDebug:
- * @ctxt:  An XML parser context
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- *
- * Special entity resolver, better left to the parser, it has
- * more context than the application layer.
- * The default behaviour is to NOT resolve the entities, in that case
- * the ENTITY_REF nodes are built in the structure (and the parameter
- * values).
- *
- * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
- */
-static xmlParserInputPtr
-resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId)
-{
-    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
-
-
-    fprintf(stdout, "SAX.resolveEntity(");
-    if (publicId != NULL)
-	fprintf(stdout, "%s", (char *)publicId);
-    else
-	fprintf(stdout, " ");
-    if (systemId != NULL)
-	fprintf(stdout, ", %s)\n", (char *)systemId);
-    else
-	fprintf(stdout, ", )\n");
-/*********
-    if (systemId != NULL) {
-        return(xmlNewInputFromFile(ctxt, (char *) systemId));
-    }
- *********/
-    return(NULL);
-}
-
-/**
- * getEntityDebug:
- * @ctxt:  An XML parser context
- * @name: The entity name
- *
- * Get an entity by name
- *
- * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
- */
-static xmlEntityPtr
-getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    fprintf(stdout, "SAX.getEntity(%s)\n", name);
-    return(NULL);
-}
-
-/**
- * getParameterEntityDebug:
- * @ctxt:  An XML parser context
- * @name: The entity name
- *
- * Get a parameter entity by name
- *
- * Returns the xmlParserInputPtr
- */
-static xmlEntityPtr
-getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
-    return(NULL);
-}
-
-
-/**
- * entityDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the entity name
- * @type:  the entity type
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- * @content: the entity value (without processing).
- *
- * An entity definition has been parsed
- */
-static void
-entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
-          const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
-{
-    fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
-            name, type, publicId, systemId, content);
-}
-
-/**
- * attributeDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the attribute name
- * @type:  the attribute type
- *
- * An attribute definition has been parsed
- */
-static void
-attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name,
-              int type, int def, const xmlChar *defaultValue,
-	      xmlEnumerationPtr tree ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
-            elem, name, type, def, defaultValue);
-}
-
-/**
- * elementDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the element name
- * @type:  the element type
- * @content: the element value (without processing).
- *
- * An element definition has been parsed
- */
-static void
-elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
-	    xmlElementContentPtr content ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
-            name, type);
-}
-
-/**
- * notationDeclDebug:
- * @ctxt:  An XML parser context
- * @name: The name of the notation
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- *
- * What to do when a notation declaration has been parsed.
- */
-static void
-notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-	     const xmlChar *publicId, const xmlChar *systemId)
-{
-    fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
-            (char *) name, (char *) publicId, (char *) systemId);
-}
-
-/**
- * unparsedEntityDeclDebug:
- * @ctxt:  An XML parser context
- * @name: The name of the entity
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- * @notationName: the name of the notation
- *
- * What to do when an unparsed entity declaration is parsed
- */
-static void
-unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-		   const xmlChar *publicId, const xmlChar *systemId,
-		   const xmlChar *notationName)
-{
-    fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
-            (char *) name, (char *) publicId, (char *) systemId,
-	    (char *) notationName);
-}
-
-/**
- * setDocumentLocatorDebug:
- * @ctxt:  An XML parser context
- * @loc: A SAX Locator
- *
- * Receive the document locator at startup, actually xmlDefaultSAXLocator
- * Everything is available on the context, so this is useless in our case.
- */
-static void
-setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.setDocumentLocator()\n");
-}
-
-/**
- * startDocumentDebug:
- * @ctxt:  An XML parser context
- *
- * called when the document start being processed.
- */
-static void
-startDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.startDocument()\n");
-}
-
-/**
- * endDocumentDebug:
- * @ctxt:  An XML parser context
- *
- * called when the document end has been detected.
- */
-static void
-endDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    fprintf(stdout, "SAX.endDocument()\n");
-}
-
-/**
- * startElementDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when an opening tag has been processed.
- */
-static void
-startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts)
-{
-    int i;
-
-    fprintf(stdout, "SAX.startElement(%s", (char *) name);
-    if (atts != NULL) {
-        for (i = 0;(atts[i] != NULL);i++) {
-	    fprintf(stdout, ", %s", atts[i++]);
-	    if (atts[i] != NULL) {
-		unsigned char output[40];
-		const unsigned char *att = atts[i];
-		int outlen, attlen;
-	        fprintf(stdout, "='");
-		while ((attlen = strlen((char*)att)) > 0) {
-		    outlen = sizeof output - 1;
-		    htmlEncodeEntities(output, &outlen, att, &attlen, '\'');
-		    output[outlen] = 0;
-		    fprintf(stdout, "%s", (char *) output);
-		    att += attlen;
-		}
-		fprintf(stdout, "'");
-	    }
-	}
-    }
-    fprintf(stdout, ")\n");
-}
-
-/**
- * endElementDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when the end of an element has been detected.
- */
-static void
-endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
-}
-
-/**
- * charactersDebug:
- * @ctxt:  An XML parser context
- * @ch:  a xmlChar string
- * @len: the number of xmlChar
- *
- * receiving some chars from the parser.
- * Question: how much at a time ???
- */
-static void
-charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
-{
-    unsigned char output[40];
-    int inlen = len, outlen = 30;
-
-    htmlEncodeEntities(output, &outlen, ch, &inlen, 0);
-    output[outlen] = 0;
-
-    fprintf(stdout, "SAX.characters(%s, %d)\n", output, len);
-}
-
-/**
- * cdataDebug:
- * @ctxt:  An XML parser context
- * @ch:  a xmlChar string
- * @len: the number of xmlChar
- *
- * receiving some cdata chars from the parser.
- * Question: how much at a time ???
- */
-static void
-cdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
-{
-    unsigned char output[40];
-    int inlen = len, outlen = 30;
-
-    htmlEncodeEntities(output, &outlen, ch, &inlen, 0);
-    output[outlen] = 0;
-
-    fprintf(stdout, "SAX.cdata(%s, %d)\n", output, len);
-}
-
-/**
- * referenceDebug:
- * @ctxt:  An XML parser context
- * @name:  The entity name
- *
- * called when an entity reference is detected.
- */
-static void
-referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    fprintf(stdout, "SAX.reference(%s)\n", name);
-}
-
-/**
- * ignorableWhitespaceDebug:
- * @ctxt:  An XML parser context
- * @ch:  a xmlChar string
- * @start: the first char in the string
- * @len: the number of xmlChar
- *
- * receiving some ignorable whitespaces from the parser.
- * Question: how much at a time ???
- */
-static void
-ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
-{
-    char output[40];
-    int i;
-
-    for (i = 0;(i<len) && (i < 30);i++)
-	output[i] = ch[i];
-    output[i] = 0;
-
-    fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len);
-}
-
-/**
- * processingInstructionDebug:
- * @ctxt:  An XML parser context
- * @target:  the target name
- * @data: the PI data's
- * @len: the number of xmlChar
- *
- * A processing instruction has been parsed.
- */
-static void
-processingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target,
-                      const xmlChar *data)
-{
-    fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
-            (char *) target, (char *) data);
-}
-
-/**
- * commentDebug:
- * @ctxt:  An XML parser context
- * @value:  the comment content
- *
- * A comment has been parsed.
- */
-static void
-commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
-{
-    fprintf(stdout, "SAX.comment(%s)\n", value);
-}
-
-/**
- * warningDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a warning messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    va_start(args, msg);
-    fprintf(stdout, "SAX.warning: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-/**
- * errorDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a error messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    va_start(args, msg);
-    fprintf(stdout, "SAX.error: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-/**
- * fatalErrorDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a fatalError messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    va_start(args, msg);
-    fprintf(stdout, "SAX.fatalError: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-static xmlSAXHandler debugSAXHandlerStruct = {
-    internalSubsetDebug,
-    isStandaloneDebug,
-    hasInternalSubsetDebug,
-    hasExternalSubsetDebug,
-    resolveEntityDebug,
-    getEntityDebug,
-    entityDeclDebug,
-    notationDeclDebug,
-    attributeDeclDebug,
-    elementDeclDebug,
-    unparsedEntityDeclDebug,
-    setDocumentLocatorDebug,
-    startDocumentDebug,
-    endDocumentDebug,
-    startElementDebug,
-    endElementDebug,
-    referenceDebug,
-    charactersDebug,
-    ignorableWhitespaceDebug,
-    processingInstructionDebug,
-    commentDebug,
-    warningDebug,
-    errorDebug,
-    fatalErrorDebug,
-    getParameterEntityDebug,
-    cdataDebug,
-    NULL,
-    1,
-    NULL,
-    NULL,
-    NULL,
-    NULL
-};
-
-xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
-/************************************************************************
- *									*
- *				Debug					*
- *									*
- ************************************************************************/
-
-static void
-parseSAXFile(char *filename) {
-    htmlDocPtr doc = NULL;
-
-    /*
-     * Empty callbacks for checking
-     */
-#ifdef LIBXML_PUSH_ENABLED
-    if (push) {
-	FILE *f;
-
-	f = fopen(filename, "rb");
-	if (f != NULL) {
-	    int res, size = 3;
-	    char chars[4096];
-	    htmlParserCtxtPtr ctxt;
-
-	    /* if (repeat) */
-		size = 4096;
-	    res = fread(chars, 1, 4, f);
-	    if (res > 0) {
-		ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL,
-			    chars, res, filename, XML_CHAR_ENCODING_NONE);
-		while ((res = fread(chars, 1, size, f)) > 0) {
-		    htmlParseChunk(ctxt, chars, res, 0);
-		}
-		htmlParseChunk(ctxt, chars, 0, 1);
-		doc = ctxt->myDoc;
-		htmlFreeParserCtxt(ctxt);
-	    }
-	    if (doc != NULL) {
-		fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
-		xmlFreeDoc(doc);
-	    }
-	    fclose(f);
-	}
-	if (!noout) {
-	    f = fopen(filename, "rb");
-	    if (f != NULL) {
-		int res, size = 3;
-		char chars[4096];
-		htmlParserCtxtPtr ctxt;
-
-		/* if (repeat) */
-		    size = 4096;
-		res = fread(chars, 1, 4, f);
-		if (res > 0) {
-		    ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL,
-				chars, res, filename, XML_CHAR_ENCODING_NONE);
-		    while ((res = fread(chars, 1, size, f)) > 0) {
-			htmlParseChunk(ctxt, chars, res, 0);
-		    }
-		    htmlParseChunk(ctxt, chars, 0, 1);
-		    doc = ctxt->myDoc;
-		    htmlFreeParserCtxt(ctxt);
-		}
-		if (doc != NULL) {
-		    fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
-		    xmlFreeDoc(doc);
-		}
-		fclose(f);
-	    }
-	}
-    } else {
-#endif /* LIBXML_PUSH_ENABLED */
-	doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL);
-	if (doc != NULL) {
-	    fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
-	    xmlFreeDoc(doc);
-	}
-
-	if (!noout) {
-	    /*
-	     * Debug callback
-	     */
-	    doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL);
-	    if (doc != NULL) {
-		fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
-		xmlFreeDoc(doc);
-	    }
-	}
-#ifdef LIBXML_PUSH_ENABLED
-    }
-#endif /* LIBXML_PUSH_ENABLED */
-}
-
-static void
-parseAndPrintFile(char *filename) {
-    htmlDocPtr doc = NULL;
-
-    /*
-     * build an HTML tree from a string;
-     */
-#ifdef LIBXML_PUSH_ENABLED
-    if (push) {
-	FILE *f;
-
-	f = fopen(filename, "rb");
-	if (f != NULL) {
-	    int res, size = 3;
-	    char chars[4096];
-	    htmlParserCtxtPtr ctxt;
-
-	    /* if (repeat) */
-		size = 4096;
-	    res = fread(chars, 1, 4, f);
-	    if (res > 0) {
-		ctxt = htmlCreatePushParserCtxt(NULL, NULL,
-			    chars, res, filename, XML_CHAR_ENCODING_NONE);
-		while ((res = fread(chars, 1, size, f)) > 0) {
-		    htmlParseChunk(ctxt, chars, res, 0);
-		}
-		htmlParseChunk(ctxt, chars, 0, 1);
-		doc = ctxt->myDoc;
-		htmlFreeParserCtxt(ctxt);
-	    }
-	    fclose(f);
-	}
-    } else {
-	doc = htmlReadFile(filename, NULL, options);
-    }
-#else
-	doc = htmlReadFile(filename,NULL,options);
-#endif
-    if (doc == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-		"Could not parse %s\n", filename);
-    }
-
-#ifdef LIBXML_TREE_ENABLED
-    /*
-     * test intermediate copy if needed.
-     */
-    if (copy) {
-        htmlDocPtr tmp;
-
-        tmp = doc;
-	doc = xmlCopyDoc(doc, 1);
-	xmlFreeDoc(tmp);
-    }
-#endif
-
-#ifdef LIBXML_OUTPUT_ENABLED
-    /*
-     * print it.
-     */
-    if (!noout) {
-#ifdef LIBXML_DEBUG_ENABLED
-	if (!debug) {
-	    if (encoding)
-		htmlSaveFileEnc("-", doc, encoding);
-	    else
-		htmlDocDump(stdout, doc);
-	} else
-	    xmlDebugDumpDocument(stdout, doc);
-#else
-	if (encoding)
-	    htmlSaveFileEnc("-", doc, encoding);
-	else
-	    htmlDocDump(stdout, doc);
-#endif
-    }
-#endif /* LIBXML_OUTPUT_ENABLED */
-
-    /*
-     * free it.
-     */
-    xmlFreeDoc(doc);
-}
-
-int main(int argc, char **argv) {
-    int i, count;
-    int files = 0;
-
-    for (i = 1; i < argc ; i++) {
-#ifdef LIBXML_DEBUG_ENABLED
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else
-#endif
-	    if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
-	    copy++;
-#ifdef LIBXML_PUSH_ENABLED
-	else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push")))
-	    push++;
-#endif /* LIBXML_PUSH_ENABLED */
-	else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax")))
-	    sax++;
-	else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout")))
-	    noout++;
-	else if ((!strcmp(argv[i], "-repeat")) ||
-	         (!strcmp(argv[i], "--repeat")))
-	    repeat++;
-	else if ((!strcmp(argv[i], "-encode")) ||
-	         (!strcmp(argv[i], "--encode"))) {
-	    i++;
-	    encoding = argv[i];
-        }
-    }
-    for (i = 1; i < argc ; i++) {
-	if ((!strcmp(argv[i], "-encode")) ||
-	         (!strcmp(argv[i], "--encode"))) {
-	    i++;
-	    continue;
-        }
-	if (argv[i][0] != '-') {
-	    if (repeat) {
-		for (count = 0;count < 100 * repeat;count++) {
-		    if (sax)
-			parseSAXFile(argv[i]);
-		    else
-			parseAndPrintFile(argv[i]);
-		}
-	    } else {
-		if (sax)
-		    parseSAXFile(argv[i]);
-		else
-		    parseAndPrintFile(argv[i]);
-	    }
-	    files ++;
-	}
-    }
-    if (files == 0) {
-	printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
-	       argv[0]);
-	printf("\tParse the HTML files and output the result of the parsing\n");
-#ifdef LIBXML_DEBUG_ENABLED
-	printf("\t--debug : dump a debug tree of the in-memory document\n");
-#endif
-	printf("\t--copy : used to test the internal copy implementation\n");
-	printf("\t--sax : debug the sequence of SAX callbacks\n");
-	printf("\t--repeat : parse the file 100 times, for timing\n");
-	printf("\t--noout : do not print the result\n");
-#ifdef LIBXML_PUSH_ENABLED
-	printf("\t--push : use the push mode parser\n");
-#endif /* LIBXML_PUSH_ENABLED */
-	printf("\t--encode encoding : output in the given encoding\n");
-    }
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-#else /* !LIBXML_HTML_ENABLED */
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : HTML support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif
diff --git a/src/testReader.c b/src/testReader.c
deleted file mode 100644
index 70d5ee7..0000000
--- a/src/testReader.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * testReader.c : a small tester program for parsing using the xmlReader
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include "libxml.h"
-
-#ifdef LIBXML_READER_ENABLED
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <libxml/xmlreader.h>
-
-static int debug = 0;
-static int dump = 0;
-static int noent = 0;
-static int count = 0;
-static int valid = 0;
-static int consumed = 0;
-
-static void usage(const char *progname) {
-    printf("Usage : %s [options] XMLfiles ...\n", progname);
-    printf("\tParse the XML files using the xmlTextReader API\n");
-    printf("\t --count: count the number of attribute and elements\n");
-    printf("\t --valid: validate the document\n");
-    printf("\t --consumed: count the number of bytes consumed\n");
-    exit(1);
-}
-static int elem, attrs;
-
-static void processNode(xmlTextReaderPtr reader) {
-    int type;
-
-    type = xmlTextReaderNodeType(reader);
-    if (count) {
-	if (type == 1) {
-	    elem++;
-	    attrs += xmlTextReaderAttributeCount(reader);
-	}
-    }
-}
-
-static void handleFile(const char *filename) {
-    xmlTextReaderPtr reader;
-    int ret;
-
-    if (count) {
-	elem = 0;
-	attrs = 0;
-    }
-
-    reader = xmlNewTextReaderFilename(filename);
-    if (reader != NULL) {
-	if (valid)
-	    xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1);
-
-	/*
-	 * Process all nodes in sequence
-	 */
-	ret = xmlTextReaderRead(reader);
-	while (ret == 1) {
-	    processNode(reader);
-	    ret = xmlTextReaderRead(reader);
-	}
-
-	/*
-	 * Done, cleanup and status
-	 */
-	if (consumed)
-		printf("%ld bytes consumed by parser\n", xmlTextReaderByteConsumed(reader));
-	xmlFreeTextReader(reader);
-	if (ret != 0) {
-	    printf("%s : failed to parse\n", filename);
-	} else if (count)
-	    printf("%s : %d elements, %d attributes\n", filename, elem, attrs);
-    } else {
-	fprintf(stderr, "Unable to open %s\n", filename);
-    }
-}
-
-int main(int argc, char **argv) {
-    int i;
-    int files = 0;
-
-    if (argc <= 1) {
-	usage(argv[0]);
-	return(1);
-    }
-    LIBXML_TEST_VERSION
-    for (i = 1; i < argc ; i++) {
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else if ((!strcmp(argv[i], "-dump")) || (!strcmp(argv[i], "--dump")))
-	    dump++;
-	else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count")))
-	    count++;
-	else if ((!strcmp(argv[i], "-consumed")) || (!strcmp(argv[i], "--consumed")))
-	    consumed++;
-	else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
-	    valid++;
-	else if ((!strcmp(argv[i], "-noent")) ||
-	         (!strcmp(argv[i], "--noent")))
-	    noent++;
-    }
-    if (noent != 0) xmlSubstituteEntitiesDefault(1);
-    for (i = 1; i < argc ; i++) {
-	if (argv[i][0] != '-') {
-	    handleFile(argv[i]);
-	    files ++;
-	}
-    }
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-#else
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : xmlReader parser support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_READER_ENABLED */
diff --git a/src/testRegexp.c b/src/testRegexp.c
deleted file mode 100644
index 2511b21..0000000
--- a/src/testRegexp.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * testRegexp.c: simple module for testing regular expressions
- *
- * See Copyright for the status of this software.
- *
- * Daniel Veillard <veillard@redhat.com>
- */
-
-#include "libxml.h"
-#ifdef LIBXML_REGEXP_ENABLED
-#include <string.h>
-
-#include <libxml/tree.h>
-#include <libxml/xmlregexp.h>
-
-static int repeat = 0;
-static int debug = 0;
-
-static void testRegexp(xmlRegexpPtr comp, const char *value) {
-    int ret;
-
-    ret = xmlRegexpExec(comp, (const xmlChar *) value);
-    if (ret == 1)
-	printf("%s: Ok\n", value);
-    else if (ret == 0)
-	printf("%s: Fail\n", value);
-    else
-	printf("%s: Error: %d\n", value, ret);
-    if (repeat) {
-	int j;
-	for (j = 0;j < 999999;j++)
-	    xmlRegexpExec(comp, (const xmlChar *) value);
-    }
-}
-
-static void
-testRegexpFile(const char *filename) {
-    xmlRegexpPtr comp = NULL;
-    FILE *input;
-    char expression[5000];
-    int len;
-
-    input = fopen(filename, "rb");
-    if (input == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-		"Cannot open %s for reading\n", filename);
-	return;
-    }
-    while (fgets(expression, 4500, input) != NULL) {
-	len = strlen(expression);
-	len--;
-	while ((len >= 0) &&
-	       ((expression[len] == '\n') || (expression[len] == '\t') ||
-		(expression[len] == '\r') || (expression[len] == ' '))) len--;
-	expression[len + 1] = 0;
-	if (len >= 0) {
-	    if (expression[0] == '#')
-		continue;
-	    if ((expression[0] == '=') && (expression[1] == '>')) {
-		char *pattern = &expression[2];
-
-		if (comp != NULL) {
-		    xmlRegFreeRegexp(comp);
-		    comp = NULL;
-		}
-		printf("Regexp: %s\n", pattern) ;
-		comp = xmlRegexpCompile((const xmlChar *) pattern);
-		if (comp == NULL) {
-		    printf("   failed to compile\n");
-		    break;
-		}
-	    } else if (comp == NULL) {
-		printf("Regexp: %s\n", expression) ;
-		comp = xmlRegexpCompile((const xmlChar *) expression);
-		if (comp == NULL) {
-		    printf("   failed to compile\n");
-		    break;
-		}
-	    } else if (comp != NULL) {
-		testRegexp(comp, expression);
-	    }
-	}
-    }
-    fclose(input);
-    if (comp != NULL)
-	xmlRegFreeRegexp(comp);
-}
-
-#ifdef LIBXML_EXPR_ENABLED
-static void
-runFileTest(xmlExpCtxtPtr ctxt, const char *filename) {
-    xmlExpNodePtr expr = NULL, sub;
-    FILE *input;
-    char expression[5000];
-    int len;
-
-    input = fopen(filename, "rb");
-    if (input == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-		"Cannot open %s for reading\n", filename);
-	return;
-    }
-    while (fgets(expression, 4500, input) != NULL) {
-	len = strlen(expression);
-	len--;
-	while ((len >= 0) &&
-	       ((expression[len] == '\n') || (expression[len] == '\t') ||
-		(expression[len] == '\r') || (expression[len] == ' '))) len--;
-	expression[len + 1] = 0;
-	if (len >= 0) {
-	    if (expression[0] == '#')
-		continue;
-	    if ((expression[0] == '=') && (expression[1] == '>')) {
-		char *str = &expression[2];
-
-		if (expr != NULL) {
-		    xmlExpFree(ctxt, expr);
-		    if (xmlExpCtxtNbNodes(ctxt) != 0)
-		        printf(" Parse/free of Expression leaked %d\n",
-			       xmlExpCtxtNbNodes(ctxt));
-		    expr = NULL;
-		}
-		printf("Expression: %s\n", str) ;
-		expr = xmlExpParse(ctxt, str);
-		if (expr == NULL) {
-		    printf("   parsing Failed\n");
-		    break;
-		}
-	    } else if (expr != NULL) {
-	        int expect = -1;
-		int nodes1, nodes2;
-
-		if (expression[0] == '0')
-		    expect = 0;
-		if (expression[0] == '1')
-		    expect = 1;
-		printf("Subexp: %s", expression + 2) ;
-		nodes1 = xmlExpCtxtNbNodes(ctxt);
-		sub = xmlExpParse(ctxt, expression + 2);
-		if (sub == NULL) {
-		    printf("   parsing Failed\n");
-		    break;
-		} else {
-		    int ret;
-
-		    nodes2 = xmlExpCtxtNbNodes(ctxt);
-		    ret = xmlExpSubsume(ctxt, expr, sub);
-
-		    if ((expect == 1) && (ret == 1)) {
-			printf(" => accept, Ok\n");
-		    } else if ((expect == 0) && (ret == 0)) {
-		        printf(" => reject, Ok\n");
-		    } else if ((expect == 1) && (ret == 0)) {
-			printf(" => reject, Failed\n");
-		    } else if ((expect == 0) && (ret == 1)) {
-			printf(" => accept, Failed\n");
-		    } else {
-		        printf(" => fail internally\n");
-		    }
-		    if (xmlExpCtxtNbNodes(ctxt) > nodes2) {
-		        printf(" Subsume leaked %d\n",
-			       xmlExpCtxtNbNodes(ctxt) - nodes2);
-			nodes1 += xmlExpCtxtNbNodes(ctxt) - nodes2;
-		    }
-		    xmlExpFree(ctxt, sub);
-		    if (xmlExpCtxtNbNodes(ctxt) > nodes1) {
-		        printf(" Parse/free leaked %d\n",
-			       xmlExpCtxtNbNodes(ctxt) - nodes1);
-		    }
-		}
-
-	    }
-	}
-    }
-    if (expr != NULL) {
-	xmlExpFree(ctxt, expr);
-	if (xmlExpCtxtNbNodes(ctxt) != 0)
-	    printf(" Parse/free of Expression leaked %d\n",
-		   xmlExpCtxtNbNodes(ctxt));
-    }
-    fclose(input);
-}
-
-static void
-testReduce(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, const char *tst) {
-    xmlBufferPtr xmlExpBuf;
-    xmlExpNodePtr sub, deriv;
-
-    sub = xmlExpParse(ctxt, tst);
-    if (sub == NULL) {
-        printf("Subset %s failed to parse\n", tst);
-	return;
-    }
-    xmlExpBuf = xmlBufferCreate();
-    xmlExpDump(xmlExpBuf, sub);
-    printf("Subset parsed as: %s\n",
-           (const char *) xmlBufferContent(xmlExpBuf));
-    deriv = xmlExpExpDerive(ctxt, expr, sub);
-    if (deriv == NULL) {
-        printf("Derivation led to an internal error, report this !\n");
-    } else {
-        xmlBufferEmpty(xmlExpBuf);
-	xmlExpDump(xmlExpBuf, deriv);
-	if (xmlExpIsNillable(deriv))
-	    printf("Resulting nillable derivation: %s\n",
-	           (const char *) xmlBufferContent(xmlExpBuf));
-	else
-	    printf("Resulting derivation: %s\n",
-	           (const char *) xmlBufferContent(xmlExpBuf));
-	xmlExpFree(ctxt, deriv);
-    }
-    xmlBufferFree(xmlExpBuf);
-    xmlExpFree(ctxt, sub);
-}
-
-static void
-exprDebug(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr) {
-    xmlBufferPtr xmlExpBuf;
-    xmlExpNodePtr deriv;
-    const char *list[40];
-    int ret;
-
-    xmlExpBuf = xmlBufferCreate();
-
-    if (expr == NULL) {
-        printf("Failed to parse\n");
-	return;
-    }
-    xmlExpDump(xmlExpBuf, expr);
-    printf("Parsed as: %s\n", (const char *) xmlBufferContent(xmlExpBuf));
-    printf("Max token input = %d\n", xmlExpMaxToken(expr));
-    if (xmlExpIsNillable(expr) == 1)
-	printf("Is nillable\n");
-    ret = xmlExpGetLanguage(ctxt, expr, (const xmlChar **) &list[0], 40);
-    if (ret < 0)
-	printf("Failed to get list: %d\n", ret);
-    else {
-	int i;
-
-	printf("Language has %d strings, testing string derivations\n", ret);
-	for (i = 0;i < ret;i++) {
-	    deriv = xmlExpStringDerive(ctxt, expr, BAD_CAST list[i], -1);
-	    if (deriv == NULL) {
-		printf("  %s -> derivation failed\n", list[i]);
-	    } else {
-		xmlBufferEmpty(xmlExpBuf);
-		xmlExpDump(xmlExpBuf, deriv);
-		printf("  %s -> %s\n", list[i],
-		       (const char *) xmlBufferContent(xmlExpBuf));
-	    }
-	    xmlExpFree(ctxt, deriv);
-	}
-    }
-    xmlBufferFree(xmlExpBuf);
-}
-#endif
-
-static void usage(const char *name) {
-    fprintf(stderr, "Usage: %s [flags]\n", name);
-    fprintf(stderr, "Testing tool for libxml2 string and pattern regexps\n");
-    fprintf(stderr, "   --debug: switch on debugging\n");
-    fprintf(stderr, "   --repeat: loop on the operation\n");
-#ifdef LIBXML_EXPR_ENABLED
-    fprintf(stderr, "   --expr: test xmlExp and not xmlRegexp\n");
-#endif
-    fprintf(stderr, "   --input filename: use the given filename for regexp\n");
-    fprintf(stderr, "   --input filename: use the given filename for exp\n");
-}
-
-int main(int argc, char **argv) {
-    xmlRegexpPtr comp = NULL;
-#ifdef LIBXML_EXPR_ENABLED
-    xmlExpNodePtr expr = NULL;
-    int use_exp = 0;
-    xmlExpCtxtPtr ctxt = NULL;
-#endif
-    const char *pattern = NULL;
-    char *filename = NULL;
-    int i;
-
-    xmlInitMemory();
-
-    if (argc <= 1) {
-	usage(argv[0]);
-	return(1);
-    }
-    for (i = 1; i < argc ; i++) {
-	if (!strcmp(argv[i], "-"))
-	    break;
-
-	if (argv[i][0] != '-')
-	    continue;
-	if (!strcmp(argv[i], "--"))
-	    break;
-
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) {
-	    debug++;
-	} else if ((!strcmp(argv[i], "-repeat")) ||
-	         (!strcmp(argv[i], "--repeat"))) {
-	    repeat++;
-#ifdef LIBXML_EXPR_ENABLED
-	} else if ((!strcmp(argv[i], "-expr")) ||
-	         (!strcmp(argv[i], "--expr"))) {
-	    use_exp++;
-#endif
-	} else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "-f")) ||
-		   (!strcmp(argv[i], "--input")))
-	    filename = argv[++i];
-        else {
-	    fprintf(stderr, "Unknown option %s\n", argv[i]);
-	    usage(argv[0]);
-	}
-    }
-
-#ifdef LIBXML_EXPR_ENABLED
-    if (use_exp)
-	ctxt = xmlExpNewCtxt(0, NULL);
-#endif
-
-    if (filename != NULL) {
-#ifdef LIBXML_EXPR_ENABLED
-        if (use_exp)
-	    runFileTest(ctxt, filename);
-	else
-#endif
-	    testRegexpFile(filename);
-    } else {
-        int  data = 0;
-#ifdef LIBXML_EXPR_ENABLED
-
-        if (use_exp) {
-	    for (i = 1; i < argc ; i++) {
-	        if (strcmp(argv[i], "--") == 0)
-		    data = 1;
-		else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) ||
-		    (data == 1)) {
-		    if (pattern == NULL) {
-			pattern = argv[i];
-			printf("Testing expr %s:\n", pattern);
-			expr = xmlExpParse(ctxt, pattern);
-			if (expr == NULL) {
-			    printf("   failed to compile\n");
-			    break;
-			}
-			if (debug) {
-			    exprDebug(ctxt, expr);
-			}
-		    } else {
-			testReduce(ctxt, expr, argv[i]);
-		    }
-		}
-	    }
-	    if (expr != NULL) {
-		xmlExpFree(ctxt, expr);
-		expr = NULL;
-	    }
-	} else
-#endif
-        {
-	    for (i = 1; i < argc ; i++) {
-	        if (strcmp(argv[i], "--") == 0)
-		    data = 1;
-		else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) ||
-		         (data == 1)) {
-		    if (pattern == NULL) {
-			pattern = argv[i];
-			printf("Testing %s:\n", pattern);
-			comp = xmlRegexpCompile((const xmlChar *) pattern);
-			if (comp == NULL) {
-			    printf("   failed to compile\n");
-			    break;
-			}
-			if (debug)
-			    xmlRegexpPrint(stdout, comp);
-		    } else {
-			testRegexp(comp, argv[i]);
-		    }
-		}
-	    }
-	    if (comp != NULL)
-		xmlRegFreeRegexp(comp);
-        }
-    }
-#ifdef LIBXML_EXPR_ENABLED
-    if (ctxt != NULL) {
-	printf("Ops: %d nodes, %d cons\n",
-	       xmlExpCtxtNbNodes(ctxt), xmlExpCtxtNbCons(ctxt));
-	xmlExpFreeCtxt(ctxt);
-    }
-#endif
-    xmlCleanupParser();
-    xmlMemoryDump();
-    return(0);
-}
-
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : Regexp support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_REGEXP_ENABLED */
diff --git a/src/testRelax.c b/src/testRelax.c
deleted file mode 100644
index ad801b1..0000000
--- a/src/testRelax.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * testRelax.c : a small tester program for RelaxNG validation
- *
- * See Copyright for the status of this software.
- *
- * Daniel.Veillard@w3.org
- */
-
-#include "libxml.h"
-#ifdef LIBXML_SCHEMAS_ENABLED
-
-#include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-/* seems needed for Solaris */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *) -1)
-#endif
-#endif
-
-#include <libxml/xmlmemory.h>
-#include <libxml/debugXML.h>
-#include <libxml/relaxng.h>
-
-#ifdef LIBXML_DEBUG_ENABLED
-static int debug = 0;
-#endif
-static int noout = 0;
-static int tree = 0;
-#ifdef HAVE_MMAP
-static int memory = 0;
-#endif
-
-
-int main(int argc, char **argv) {
-    int i;
-    int files = 0;
-    xmlRelaxNGPtr schema = NULL;
-
-    for (i = 1; i < argc ; i++) {
-#ifdef LIBXML_DEBUG_ENABLED
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else
-#endif
-#ifdef HAVE_MMAP
-	if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
-	    memory++;
-        } else
-#endif
-	if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) {
-	    noout++;
-        } else
-	if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) {
-	    tree++;
-        }
-    }
-    xmlLineNumbersDefault(1);
-    xmlSubstituteEntitiesDefault(1);
-    for (i = 1; i < argc ; i++) {
-	if (argv[i][0] != '-') {
-	    if (schema == NULL) {
-		xmlRelaxNGParserCtxtPtr ctxt;
-
-#ifdef HAVE_MMAP
-		if (memory) {
-		    int fd;
-		    struct stat info;
-		    const char *base;
-		    if (stat(argv[i], &info) < 0)
-			break;
-		    if ((fd = open(argv[i], O_RDONLY)) < 0)
-			break;
-		    base = mmap(NULL, info.st_size, PROT_READ,
-			        MAP_SHARED, fd, 0) ;
-		    if (base == (void *) MAP_FAILED)
-			break;
-
-		    ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size);
-
-		    xmlRelaxNGSetParserErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    schema = xmlRelaxNGParse(ctxt);
-		    xmlRelaxNGFreeParserCtxt(ctxt);
-		    munmap((char *) base, info.st_size);
-		} else
-#endif
-		{
-		    ctxt = xmlRelaxNGNewParserCtxt(argv[i]);
-		    xmlRelaxNGSetParserErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    schema = xmlRelaxNGParse(ctxt);
-		    xmlRelaxNGFreeParserCtxt(ctxt);
-		}
-		if (schema == NULL) {
-		    printf("Relax-NG schema %s failed to compile\n", argv[i]);
-		    files = -1;
-		    break;
-		}
-#ifdef LIBXML_OUTPUT_ENABLED
-#ifdef LIBXML_DEBUG_ENABLED
-		if (debug)
-		    xmlRelaxNGDump(stdout, schema);
-#endif
-		if (tree)
-		    xmlRelaxNGDumpTree(stdout, schema);
-#endif /* LIBXML_OUTPUT_ENABLED */
-	    } else {
-		xmlDocPtr doc;
-
-		doc = xmlReadFile(argv[i],NULL,0);
-
-		if (doc == NULL) {
-		    fprintf(stderr, "Could not parse %s\n", argv[i]);
-		} else {
-		    xmlRelaxNGValidCtxtPtr ctxt;
-		    int ret;
-
-		    ctxt = xmlRelaxNGNewValidCtxt(schema);
-		    xmlRelaxNGSetValidErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    ret = xmlRelaxNGValidateDoc(ctxt, doc);
-		    if (ret == 0) {
-			printf("%s validates\n", argv[i]);
-		    } else if (ret > 0) {
-			printf("%s fails to validate\n", argv[i]);
-		    } else {
-			printf("%s validation generated an internal error\n",
-			       argv[i]);
-		    }
-		    xmlRelaxNGFreeValidCtxt(ctxt);
-		    xmlFreeDoc(doc);
-		}
-	    }
-	    files ++;
-	}
-    }
-    if (schema != NULL)
-	xmlRelaxNGFree(schema);
-    if (files == 0) {
-	printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n",
-	       argv[0]);
-	printf("\tParse the HTML files and output the result of the parsing\n");
-#ifdef LIBXML_DEBUG_ENABLED
-	printf("\t--debug : dump a debug tree of the in-memory document\n");
-#endif
-	printf("\t--noout : do not print the result\n");
-	printf("\t--tree : print the intermediate Relax-NG document tree\n");
-#ifdef HAVE_MMAP
-	printf("\t--memory : test the schemas in memory parsing\n");
-#endif
-    }
-    xmlRelaxNGCleanupTypes();
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : RelaxNG support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_SCHEMAS_ENABLED */
diff --git a/src/testSAX.c b/src/testSAX.c
deleted file mode 100644
index 9cc72f2..0000000
--- a/src/testSAX.c
+++ /dev/null
@@ -1,1148 +0,0 @@
-/*
- * testSAX.c : a small tester program for parsing using the SAX API.
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include "libxml.h"
-
-#ifdef LIBXML_SAX1_ENABLED
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TIMEB_H
-#include <sys/timeb.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <libxml/globals.h>
-#include <libxml/xmlerror.h>
-#include <libxml/parser.h>
-#include <libxml/parserInternals.h> /* only for xmlNewInputFromFile() */
-#include <libxml/tree.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlmemory.h>
-
-static int debug = 0;
-static int copy = 0;
-static int recovery = 0;
-static int push = 0;
-static int speed = 0;
-static int noent = 0;
-static int quiet = 0;
-static int nonull = 0;
-static int sax2 = 0;
-static int repeat = 0;
-static int callbacks = 0;
-static int timing = 0;
-
-/*
- * Timing routines.
- */
-/*
- * Internal timing routines to remove the necessity to have unix-specific
- * function calls
- */
-
-#ifndef HAVE_GETTIMEOFDAY
-#ifdef HAVE_SYS_TIMEB_H
-#ifdef HAVE_SYS_TIME_H
-#ifdef HAVE_FTIME
-
-static int
-my_gettimeofday(struct timeval *tvp, void *tzp)
-{
-	struct timeb timebuffer;
-
-	ftime(&timebuffer);
-	if (tvp) {
-		tvp->tv_sec = timebuffer.time;
-		tvp->tv_usec = timebuffer.millitm * 1000L;
-	}
-	return (0);
-}
-#define HAVE_GETTIMEOFDAY 1
-#define gettimeofday my_gettimeofday
-
-#endif /* HAVE_FTIME */
-#endif /* HAVE_SYS_TIME_H */
-#endif /* HAVE_SYS_TIMEB_H */
-#endif /* !HAVE_GETTIMEOFDAY */
-
-#if defined(HAVE_GETTIMEOFDAY)
-static struct timeval begin, end;
-
-/*
- * startTimer: call where you want to start timing
- */
-static void
-startTimer(void)
-{
-    gettimeofday(&begin, NULL);
-}
-
-/*
- * endTimer: call where you want to stop timing and to print out a
- *           message about the timing performed; format is a printf
- *           type argument
- */
-static void XMLCDECL
-endTimer(const char *fmt, ...)
-{
-    long msec;
-    va_list ap;
-
-    gettimeofday(&end, NULL);
-    msec = end.tv_sec - begin.tv_sec;
-    msec *= 1000;
-    msec += (end.tv_usec - begin.tv_usec) / 1000;
-
-    va_start(ap, fmt);
-    vfprintf(stderr, fmt, ap);
-    va_end(ap);
-
-    fprintf(stderr, " took %ld ms\n", msec);
-}
-#else
-/*
- * No gettimeofday function, so we have to make do with calling clock.
- * This is obviously less accurate, but there's little we can do about
- * that.
- */
-#ifndef CLOCKS_PER_SEC
-#define CLOCKS_PER_SEC 100
-#endif
-
-static clock_t begin, end;
-static void
-startTimer(void)
-{
-    begin = clock();
-}
-static void XMLCDECL
-endTimer(const char *fmt, ...)
-{
-    long msec;
-    va_list ap;
-
-    end = clock();
-    msec = ((end - begin) * 1000) / CLOCKS_PER_SEC;
-
-    va_start(ap, fmt);
-    vfprintf(stderr, fmt, ap);
-    va_end(ap);
-    fprintf(stderr, " took %ld ms\n", msec);
-}
-#endif
-
-/*
- * empty SAX block
- */
-static xmlSAXHandler emptySAXHandlerStruct = {
-    NULL, /* internalSubset */
-    NULL, /* isStandalone */
-    NULL, /* hasInternalSubset */
-    NULL, /* hasExternalSubset */
-    NULL, /* resolveEntity */
-    NULL, /* getEntity */
-    NULL, /* entityDecl */
-    NULL, /* notationDecl */
-    NULL, /* attributeDecl */
-    NULL, /* elementDecl */
-    NULL, /* unparsedEntityDecl */
-    NULL, /* setDocumentLocator */
-    NULL, /* startDocument */
-    NULL, /* endDocument */
-    NULL, /* startElement */
-    NULL, /* endElement */
-    NULL, /* reference */
-    NULL, /* characters */
-    NULL, /* ignorableWhitespace */
-    NULL, /* processingInstruction */
-    NULL, /* comment */
-    NULL, /* xmlParserWarning */
-    NULL, /* xmlParserError */
-    NULL, /* xmlParserError */
-    NULL, /* getParameterEntity */
-    NULL, /* cdataBlock; */
-    NULL, /* externalSubset; */
-    1,
-    NULL,
-    NULL, /* startElementNs */
-    NULL, /* endElementNs */
-    NULL  /* xmlStructuredErrorFunc */
-};
-
-static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
-extern xmlSAXHandlerPtr debugSAXHandler;
-
-/************************************************************************
- *									*
- *				Debug Handlers				*
- *									*
- ************************************************************************/
-
-/**
- * isStandaloneDebug:
- * @ctxt:  An XML parser context
- *
- * Is this document tagged standalone ?
- *
- * Returns 1 if true
- */
-static int
-isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return(0);
-    fprintf(stdout, "SAX.isStandalone()\n");
-    return(0);
-}
-
-/**
- * hasInternalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an internal subset
- *
- * Returns 1 if true
- */
-static int
-hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return(0);
-    fprintf(stdout, "SAX.hasInternalSubset()\n");
-    return(0);
-}
-
-/**
- * hasExternalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an external subset
- *
- * Returns 1 if true
- */
-static int
-hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return(0);
-    fprintf(stdout, "SAX.hasExternalSubset()\n");
-    return(0);
-}
-
-/**
- * internalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an internal subset
- */
-static void
-internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-	       const xmlChar *ExternalID, const xmlChar *SystemID)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.internalSubset(%s,", name);
-    if (ExternalID == NULL)
-	fprintf(stdout, " ,");
-    else
-	fprintf(stdout, " %s,", ExternalID);
-    if (SystemID == NULL)
-	fprintf(stdout, " )\n");
-    else
-	fprintf(stdout, " %s)\n", SystemID);
-}
-
-/**
- * externalSubsetDebug:
- * @ctxt:  An XML parser context
- *
- * Does this document has an external subset
- */
-static void
-externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-	       const xmlChar *ExternalID, const xmlChar *SystemID)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.externalSubset(%s,", name);
-    if (ExternalID == NULL)
-	fprintf(stdout, " ,");
-    else
-	fprintf(stdout, " %s,", ExternalID);
-    if (SystemID == NULL)
-	fprintf(stdout, " )\n");
-    else
-	fprintf(stdout, " %s)\n", SystemID);
-}
-
-/**
- * resolveEntityDebug:
- * @ctxt:  An XML parser context
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- *
- * Special entity resolver, better left to the parser, it has
- * more context than the application layer.
- * The default behaviour is to NOT resolve the entities, in that case
- * the ENTITY_REF nodes are built in the structure (and the parameter
- * values).
- *
- * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
- */
-static xmlParserInputPtr
-resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId)
-{
-    callbacks++;
-    if (quiet)
-	return(NULL);
-    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
-
-
-    fprintf(stdout, "SAX.resolveEntity(");
-    if (publicId != NULL)
-	fprintf(stdout, "%s", (char *)publicId);
-    else
-	fprintf(stdout, " ");
-    if (systemId != NULL)
-	fprintf(stdout, ", %s)\n", (char *)systemId);
-    else
-	fprintf(stdout, ", )\n");
-/*********
-    if (systemId != NULL) {
-        return(xmlNewInputFromFile(ctxt, (char *) systemId));
-    }
- *********/
-    return(NULL);
-}
-
-/**
- * getEntityDebug:
- * @ctxt:  An XML parser context
- * @name: The entity name
- *
- * Get an entity by name
- *
- * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
- */
-static xmlEntityPtr
-getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    callbacks++;
-    if (quiet)
-	return(NULL);
-    fprintf(stdout, "SAX.getEntity(%s)\n", name);
-    return(NULL);
-}
-
-/**
- * getParameterEntityDebug:
- * @ctxt:  An XML parser context
- * @name: The entity name
- *
- * Get a parameter entity by name
- *
- * Returns the xmlParserInputPtr
- */
-static xmlEntityPtr
-getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    callbacks++;
-    if (quiet)
-	return(NULL);
-    fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
-    return(NULL);
-}
-
-
-/**
- * entityDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the entity name
- * @type:  the entity type
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- * @content: the entity value (without processing).
- *
- * An entity definition has been parsed
- */
-static void
-entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
-          const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
-{
-const xmlChar *nullstr = BAD_CAST "(null)";
-    /* not all libraries handle printing null pointers nicely */
-    if (publicId == NULL)
-        publicId = nullstr;
-    if (systemId == NULL)
-        systemId = nullstr;
-    if (content == NULL)
-        content = (xmlChar *)nullstr;
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
-            name, type, publicId, systemId, content);
-}
-
-/**
- * attributeDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the attribute name
- * @type:  the attribute type
- *
- * An attribute definition has been parsed
- */
-static void
-attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
-                   const xmlChar * name, int type, int def,
-                   const xmlChar * defaultValue, xmlEnumerationPtr tree)
-{
-    callbacks++;
-    if (quiet)
-        return;
-    if (defaultValue == NULL)
-        fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
-                elem, name, type, def);
-    else
-        fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
-                elem, name, type, def, defaultValue);
-    xmlFreeEnumeration(tree);
-}
-
-/**
- * elementDeclDebug:
- * @ctxt:  An XML parser context
- * @name:  the element name
- * @type:  the element type
- * @content: the element value (without processing).
- *
- * An element definition has been parsed
- */
-static void
-elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
-	    xmlElementContentPtr content ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
-            name, type);
-}
-
-/**
- * notationDeclDebug:
- * @ctxt:  An XML parser context
- * @name: The name of the notation
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- *
- * What to do when a notation declaration has been parsed.
- */
-static void
-notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-	     const xmlChar *publicId, const xmlChar *systemId)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
-            (char *) name, (char *) publicId, (char *) systemId);
-}
-
-/**
- * unparsedEntityDeclDebug:
- * @ctxt:  An XML parser context
- * @name: The name of the entity
- * @publicId: The public ID of the entity
- * @systemId: The system ID of the entity
- * @notationName: the name of the notation
- *
- * What to do when an unparsed entity declaration is parsed
- */
-static void
-unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
-		   const xmlChar *publicId, const xmlChar *systemId,
-		   const xmlChar *notationName)
-{
-const xmlChar *nullstr = BAD_CAST "(null)";
-
-    if (publicId == NULL)
-        publicId = nullstr;
-    if (systemId == NULL)
-        systemId = nullstr;
-    if (notationName == NULL)
-        notationName = nullstr;
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
-            (char *) name, (char *) publicId, (char *) systemId,
-	    (char *) notationName);
-}
-
-/**
- * setDocumentLocatorDebug:
- * @ctxt:  An XML parser context
- * @loc: A SAX Locator
- *
- * Receive the document locator at startup, actually xmlDefaultSAXLocator
- * Everything is available on the context, so this is useless in our case.
- */
-static void
-setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.setDocumentLocator()\n");
-}
-
-/**
- * startDocumentDebug:
- * @ctxt:  An XML parser context
- *
- * called when the document start being processed.
- */
-static void
-startDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.startDocument()\n");
-}
-
-/**
- * endDocumentDebug:
- * @ctxt:  An XML parser context
- *
- * called when the document end has been detected.
- */
-static void
-endDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.endDocument()\n");
-}
-
-/**
- * startElementDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when an opening tag has been processed.
- */
-static void
-startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts)
-{
-    int i;
-
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.startElement(%s", (char *) name);
-    if (atts != NULL) {
-        for (i = 0;(atts[i] != NULL);i++) {
-	    fprintf(stdout, ", %s='", atts[i++]);
-	    if (atts[i] != NULL)
-	        fprintf(stdout, "%s'", atts[i]);
-	}
-    }
-    fprintf(stdout, ")\n");
-}
-
-/**
- * endElementDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when the end of an element has been detected.
- */
-static void
-endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
-}
-
-/**
- * charactersDebug:
- * @ctxt:  An XML parser context
- * @ch:  a xmlChar string
- * @len: the number of xmlChar
- *
- * receiving some chars from the parser.
- * Question: how much at a time ???
- */
-static void
-charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
-{
-    char output[40];
-    int i;
-
-    callbacks++;
-    if (quiet)
-	return;
-    for (i = 0;(i<len) && (i < 30);i++)
-	output[i] = ch[i];
-    output[i] = 0;
-
-    fprintf(stdout, "SAX.characters(%s, %d)\n", output, len);
-}
-
-/**
- * referenceDebug:
- * @ctxt:  An XML parser context
- * @name:  The entity name
- *
- * called when an entity reference is detected.
- */
-static void
-referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.reference(%s)\n", name);
-}
-
-/**
- * ignorableWhitespaceDebug:
- * @ctxt:  An XML parser context
- * @ch:  a xmlChar string
- * @start: the first char in the string
- * @len: the number of xmlChar
- *
- * receiving some ignorable whitespaces from the parser.
- * Question: how much at a time ???
- */
-static void
-ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
-{
-    char output[40];
-    int i;
-
-    callbacks++;
-    if (quiet)
-	return;
-    for (i = 0;(i<len) && (i < 30);i++)
-	output[i] = ch[i];
-    output[i] = 0;
-    fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len);
-}
-
-/**
- * processingInstructionDebug:
- * @ctxt:  An XML parser context
- * @target:  the target name
- * @data: the PI data's
- * @len: the number of xmlChar
- *
- * A processing instruction has been parsed.
- */
-static void
-processingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target,
-                      const xmlChar *data)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    if (data != NULL)
-	fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
-		(char *) target, (char *) data);
-    else
-	fprintf(stdout, "SAX.processingInstruction(%s, NULL)\n",
-		(char *) target);
-}
-
-/**
- * cdataBlockDebug:
- * @ctx: the user data (XML parser context)
- * @value:  The pcdata content
- * @len:  the block length
- *
- * called when a pcdata block has been parsed
- */
-static void
-cdataBlockDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value, int len)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.pcdata(%.20s, %d)\n",
-	    (char *) value, len);
-}
-
-/**
- * commentDebug:
- * @ctxt:  An XML parser context
- * @value:  the comment content
- *
- * A comment has been parsed.
- */
-static void
-commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.comment(%s)\n", value);
-}
-
-/**
- * warningDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a warning messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    callbacks++;
-    if (quiet)
-	return;
-    va_start(args, msg);
-    fprintf(stdout, "SAX.warning: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-/**
- * errorDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a error messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    callbacks++;
-    if (quiet)
-	return;
-    va_start(args, msg);
-    fprintf(stdout, "SAX.error: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-/**
- * fatalErrorDebug:
- * @ctxt:  An XML parser context
- * @msg:  the message to display/transmit
- * @...:  extra parameters for the message display
- *
- * Display and format a fatalError messages, gives file, line, position and
- * extra parameters.
- */
-static void XMLCDECL
-fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
-{
-    va_list args;
-
-    callbacks++;
-    if (quiet)
-	return;
-    va_start(args, msg);
-    fprintf(stdout, "SAX.fatalError: ");
-    vfprintf(stdout, msg, args);
-    va_end(args);
-}
-
-static xmlSAXHandler debugSAXHandlerStruct = {
-    internalSubsetDebug,
-    isStandaloneDebug,
-    hasInternalSubsetDebug,
-    hasExternalSubsetDebug,
-    resolveEntityDebug,
-    getEntityDebug,
-    entityDeclDebug,
-    notationDeclDebug,
-    attributeDeclDebug,
-    elementDeclDebug,
-    unparsedEntityDeclDebug,
-    setDocumentLocatorDebug,
-    startDocumentDebug,
-    endDocumentDebug,
-    startElementDebug,
-    endElementDebug,
-    referenceDebug,
-    charactersDebug,
-    ignorableWhitespaceDebug,
-    processingInstructionDebug,
-    commentDebug,
-    warningDebug,
-    errorDebug,
-    fatalErrorDebug,
-    getParameterEntityDebug,
-    cdataBlockDebug,
-    externalSubsetDebug,
-    1,
-    NULL,
-    NULL,
-    NULL,
-    NULL
-};
-
-xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
-
-/*
- * SAX2 specific callbacks
- */
-/**
- * startElementNsDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when an opening tag has been processed.
- */
-static void
-startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
-                    const xmlChar *localname,
-                    const xmlChar *prefix,
-                    const xmlChar *URI,
-		    int nb_namespaces,
-		    const xmlChar **namespaces,
-		    int nb_attributes,
-		    int nb_defaulted,
-		    const xmlChar **attributes)
-{
-    int i;
-
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.startElementNs(%s", (char *) localname);
-    if (prefix == NULL)
-	fprintf(stdout, ", NULL");
-    else
-	fprintf(stdout, ", %s", (char *) prefix);
-    if (URI == NULL)
-	fprintf(stdout, ", NULL");
-    else
-	fprintf(stdout, ", '%s'", (char *) URI);
-    fprintf(stdout, ", %d", nb_namespaces);
-
-    if (namespaces != NULL) {
-        for (i = 0;i < nb_namespaces * 2;i++) {
-	    fprintf(stdout, ", xmlns");
-	    if (namespaces[i] != NULL)
-	        fprintf(stdout, ":%s", namespaces[i]);
-	    i++;
-	    fprintf(stdout, "='%s'", namespaces[i]);
-	}
-    }
-    fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted);
-    if (attributes != NULL) {
-        for (i = 0;i < nb_attributes * 5;i += 5) {
-	    if (attributes[i + 1] != NULL)
-		fprintf(stdout, ", %s:%s='", attributes[i + 1], attributes[i]);
-	    else
-		fprintf(stdout, ", %s='", attributes[i]);
-	    fprintf(stdout, "%.4s...', %d", attributes[i + 3],
-		    (int)(attributes[i + 4] - attributes[i + 3]));
-	}
-    }
-    fprintf(stdout, ")\n");
-}
-
-/**
- * endElementDebug:
- * @ctxt:  An XML parser context
- * @name:  The element name
- *
- * called when the end of an element has been detected.
- */
-static void
-endElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
-                  const xmlChar *localname,
-                  const xmlChar *prefix,
-                  const xmlChar *URI)
-{
-    callbacks++;
-    if (quiet)
-	return;
-    fprintf(stdout, "SAX.endElementNs(%s", (char *) localname);
-    if (prefix == NULL)
-	fprintf(stdout, ", NULL");
-    else
-	fprintf(stdout, ", %s", (char *) prefix);
-    if (URI == NULL)
-	fprintf(stdout, ", NULL)\n");
-    else
-	fprintf(stdout, ", '%s')\n", (char *) URI);
-}
-
-static xmlSAXHandler debugSAX2HandlerStruct = {
-    internalSubsetDebug,
-    isStandaloneDebug,
-    hasInternalSubsetDebug,
-    hasExternalSubsetDebug,
-    resolveEntityDebug,
-    getEntityDebug,
-    entityDeclDebug,
-    notationDeclDebug,
-    attributeDeclDebug,
-    elementDeclDebug,
-    unparsedEntityDeclDebug,
-    setDocumentLocatorDebug,
-    startDocumentDebug,
-    endDocumentDebug,
-    NULL,
-    NULL,
-    referenceDebug,
-    charactersDebug,
-    ignorableWhitespaceDebug,
-    processingInstructionDebug,
-    commentDebug,
-    warningDebug,
-    errorDebug,
-    fatalErrorDebug,
-    getParameterEntityDebug,
-    cdataBlockDebug,
-    externalSubsetDebug,
-    XML_SAX2_MAGIC,
-    NULL,
-    startElementNsDebug,
-    endElementNsDebug,
-    NULL
-};
-
-static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct;
-
-/************************************************************************
- *									*
- *				Debug					*
- *									*
- ************************************************************************/
-
-static void
-parseAndPrintFile(char *filename) {
-    int res;
-
-#ifdef LIBXML_PUSH_ENABLED
-    if (push) {
-	FILE *f;
-
-        if ((!quiet) && (!nonull)) {
-	    /*
-	     * Empty callbacks for checking
-	     */
-	    f = fopen(filename, "rb");
-	    if (f != NULL) {
-		int ret;
-		char chars[10];
-		xmlParserCtxtPtr ctxt;
-
-		ret = fread(chars, 1, 4, f);
-		if (ret > 0) {
-		    ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL,
-				chars, ret, filename);
-		    while ((ret = fread(chars, 1, 3, f)) > 0) {
-			xmlParseChunk(ctxt, chars, ret, 0);
-		    }
-		    xmlParseChunk(ctxt, chars, 0, 1);
-		    xmlFreeParserCtxt(ctxt);
-		}
-		fclose(f);
-	    } else {
-		xmlGenericError(xmlGenericErrorContext,
-			"Cannot read file %s\n", filename);
-	    }
-	}
-	/*
-	 * Debug callback
-	 */
-	f = fopen(filename, "rb");
-	if (f != NULL) {
-	    int ret;
-	    char chars[10];
-	    xmlParserCtxtPtr ctxt;
-
-	    ret = fread(chars, 1, 4, f);
-	    if (ret > 0) {
-	        if (sax2)
-		    ctxt = xmlCreatePushParserCtxt(debugSAX2Handler, NULL,
-				chars, ret, filename);
-		else
-		    ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL,
-				chars, ret, filename);
-		while ((ret = fread(chars, 1, 3, f)) > 0) {
-		    xmlParseChunk(ctxt, chars, ret, 0);
-		}
-		ret = xmlParseChunk(ctxt, chars, 0, 1);
-		xmlFreeParserCtxt(ctxt);
-		if (ret != 0) {
-		    fprintf(stdout,
-		            "xmlSAXUserParseFile returned error %d\n", ret);
-		}
-	    }
-	    fclose(f);
-	}
-    } else {
-#endif /* LIBXML_PUSH_ENABLED */
-	if (!speed) {
-	    /*
-	     * Empty callbacks for checking
-	     */
-	    if ((!quiet) && (!nonull)) {
-		res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
-		if (res != 0) {
-		    fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
-		}
-	    }
-
-	    /*
-	     * Debug callback
-	     */
-	    callbacks = 0;
-	    if (repeat) {
-	        int i;
-		for (i = 0;i < 99;i++) {
-		    if (sax2)
-			res = xmlSAXUserParseFile(debugSAX2Handler, NULL,
-			                          filename);
-		    else
-			res = xmlSAXUserParseFile(debugSAXHandler, NULL,
-			                          filename);
-		}
-	    }
-	    if (sax2)
-	        res = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename);
-	    else
-		res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename);
-	    if (res != 0) {
-		fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
-	    }
-	    if (quiet)
-		fprintf(stdout, "%d callbacks generated\n", callbacks);
-	} else {
-	    /*
-	     * test 100x the SAX parse
-	     */
-	    int i;
-
-	    for (i = 0; i<100;i++)
-		res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
-	    if (res != 0) {
-		fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
-	    }
-	}
-#ifdef LIBXML_PUSH_ENABLED
-    }
-#endif
-}
-
-
-int main(int argc, char **argv) {
-    int i;
-    int files = 0;
-
-    LIBXML_TEST_VERSION	/* be safe, plus calls xmlInitParser */
-
-    for (i = 1; i < argc ; i++) {
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
-	    copy++;
-	else if ((!strcmp(argv[i], "-recover")) ||
-	         (!strcmp(argv[i], "--recover")))
-	    recovery++;
-	else if ((!strcmp(argv[i], "-push")) ||
-	         (!strcmp(argv[i], "--push")))
-#ifdef LIBXML_PUSH_ENABLED
-	    push++;
-#else
-	    fprintf(stderr,"'push' not enabled in library - ignoring\n");
-#endif /* LIBXML_PUSH_ENABLED */
-	else if ((!strcmp(argv[i], "-speed")) ||
-	         (!strcmp(argv[i], "--speed")))
-	    speed++;
-	else if ((!strcmp(argv[i], "-timing")) ||
-	         (!strcmp(argv[i], "--timing"))) {
-	    nonull++;
-	    timing++;
-	    quiet++;
-	} else if ((!strcmp(argv[i], "-repeat")) ||
-	         (!strcmp(argv[i], "--repeat"))) {
-	    repeat++;
-	    quiet++;
-	} else if ((!strcmp(argv[i], "-noent")) ||
-	         (!strcmp(argv[i], "--noent")))
-	    noent++;
-	else if ((!strcmp(argv[i], "-quiet")) ||
-	         (!strcmp(argv[i], "--quiet")))
-	    quiet++;
-	else if ((!strcmp(argv[i], "-sax2")) ||
-	         (!strcmp(argv[i], "--sax2")))
-	    sax2++;
-	else if ((!strcmp(argv[i], "-nonull")) ||
-	         (!strcmp(argv[i], "--nonull")))
-	    nonull++;
-    }
-    if (noent != 0) xmlSubstituteEntitiesDefault(1);
-    for (i = 1; i < argc ; i++) {
-	if (argv[i][0] != '-') {
-	    if (timing) {
-		startTimer();
-	    }
-	    parseAndPrintFile(argv[i]);
-	    if (timing) {
-		endTimer("Parsing");
-	    }
-	    files ++;
-	}
-    }
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-#else
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : SAX1 parsing support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_SAX1_ENABLED */
diff --git a/src/testSchemas.c b/src/testSchemas.c
deleted file mode 100644
index f79adf0..0000000
--- a/src/testSchemas.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * testSchemas.c : a small tester program for Schema validation
- *
- * See Copyright for the status of this software.
- *
- * Daniel.Veillard@w3.org
- */
-
-#include "libxml.h"
-#ifdef LIBXML_SCHEMAS_ENABLED
-
-#include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-/* seems needed for Solaris */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *) -1)
-#endif
-#endif
-
-#include <libxml/xmlmemory.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlschemas.h>
-#include <libxml/xmlschemastypes.h>
-
-#ifdef LIBXML_DEBUG_ENABLED
-static int debug = 0;
-#endif
-static int noout = 0;
-#ifdef HAVE_MMAP
-static int memory = 0;
-#endif
-
-
-int main(int argc, char **argv) {
-    int i;
-    int files = 0;
-    xmlSchemaPtr schema = NULL;
-
-    for (i = 1; i < argc ; i++) {
-#ifdef LIBXML_DEBUG_ENABLED
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else
-#endif
-#ifdef HAVE_MMAP
-	if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
-	    memory++;
-        } else
-#endif
-	if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) {
-	    noout++;
-        }
-    }
-    xmlLineNumbersDefault(1);
-    for (i = 1; i < argc ; i++) {
-	if (argv[i][0] != '-') {
-	    if (schema == NULL) {
-		xmlSchemaParserCtxtPtr ctxt;
-
-#ifdef HAVE_MMAP
-		if (memory) {
-		    int fd;
-		    struct stat info;
-		    const char *base;
-		    if (stat(argv[i], &info) < 0)
-			break;
-		    if ((fd = open(argv[i], O_RDONLY)) < 0)
-			break;
-		    base = mmap(NULL, info.st_size, PROT_READ,
-			        MAP_SHARED, fd, 0) ;
-		    if (base == (void *) MAP_FAILED)
-			break;
-
-		    ctxt = xmlSchemaNewMemParserCtxt((char *)base,info.st_size);
-
-		    xmlSchemaSetParserErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    schema = xmlSchemaParse(ctxt);
-		    xmlSchemaFreeParserCtxt(ctxt);
-		    munmap((char *) base, info.st_size);
-		} else
-#endif
-		{
-		    ctxt = xmlSchemaNewParserCtxt(argv[i]);
-		    xmlSchemaSetParserErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    schema = xmlSchemaParse(ctxt);
-		    xmlSchemaFreeParserCtxt(ctxt);
-		}
-#ifdef LIBXML_OUTPUT_ENABLED
-#ifdef LIBXML_DEBUG_ENABLED
-		if (debug)
-		    xmlSchemaDump(stdout, schema);
-#endif
-#endif /* LIBXML_OUTPUT_ENABLED */
-		if (schema == NULL)
-		    goto failed_schemas;
-	    } else {
-		xmlDocPtr doc;
-
-		doc = xmlReadFile(argv[i],NULL,0);
-
-		if (doc == NULL) {
-		    fprintf(stderr, "Could not parse %s\n", argv[i]);
-		} else {
-		    xmlSchemaValidCtxtPtr ctxt;
-		    int ret;
-
-		    ctxt = xmlSchemaNewValidCtxt(schema);
-		    xmlSchemaSetValidErrors(ctxt,
-                            xmlGenericError, xmlGenericError, NULL);
-		    ret = xmlSchemaValidateDoc(ctxt, doc);
-		    if (ret == 0) {
-			printf("%s validates\n", argv[i]);
-		    } else if (ret > 0) {
-			printf("%s fails to validate\n", argv[i]);
-		    } else {
-			printf("%s validation generated an internal error\n",
-			       argv[i]);
-		    }
-		    xmlSchemaFreeValidCtxt(ctxt);
-		    xmlFreeDoc(doc);
-		}
-	    }
-	    files ++;
-	}
-    }
-    if (schema != NULL)
-	xmlSchemaFree(schema);
-    if (files == 0) {
-	printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n",
-	       argv[0]);
-	printf("\tParse the HTML files and output the result of the parsing\n");
-#ifdef LIBXML_DEBUG_ENABLED
-	printf("\t--debug : dump a debug tree of the in-memory document\n");
-#endif
-	printf("\t--noout : do not print the result\n");
-#ifdef HAVE_MMAP
-	printf("\t--memory : test the schemas in memory parsing\n");
-#endif
-    }
-failed_schemas:
-    xmlSchemaCleanupTypes();
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : Schemas support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_SCHEMAS_ENABLED */
diff --git a/src/testURI.c b/src/testURI.c
deleted file mode 100644
index 0043b20..0000000
--- a/src/testURI.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * testURI.c : a small tester program for XML input.
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include "libxml.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/uri.h>
-#include <libxml/globals.h>
-
-static const char *base = NULL;
-static int escape = 0;
-static int debug = 0;
-static int relative = 0;
-
-static void handleURI(const char *str) {
-    int ret;
-    xmlURIPtr uri;
-    xmlChar *res = NULL, *parsed = NULL;
-
-    uri = xmlCreateURI();
-
-    if (base == NULL) {
-	ret = xmlParseURIReference(uri, str);
-	if (ret != 0)
-	    printf("%s : error %d\n", str, ret);
-	else {
-	    if (debug) {
-	        if (uri->scheme) printf("scheme: %s\n", uri->scheme);
-	        if (uri->opaque) printf("opaque: %s\n", uri->opaque);
-	        if (uri->authority) printf("authority: %s\n", uri->authority);
-	        if (uri->server) printf("server: %s\n", uri->server);
-	        if (uri->user) printf("user: %s\n", uri->user);
-	        if (uri->port != 0) printf("port: %d\n", uri->port);
-	        if (uri->path) printf("path: %s\n", uri->path);
-	        if (uri->query) printf("query: %s\n", uri->query);
-	        if (uri->fragment) printf("fragment: %s\n", uri->fragment);
-	        if (uri->query_raw) printf("query_raw: %s\n", uri->query_raw);
-	        if (uri->cleanup != 0) printf("cleanup\n");
-	    }
-	    xmlNormalizeURIPath(uri->path);
-	    if (escape != 0) {
-		parsed = xmlSaveUri(uri);
-		res = xmlURIEscape(parsed);
-		printf("%s\n", (char *) res);
-
-	    } else {
-		xmlPrintURI(stdout, uri);
-		printf("\n");
-	    }
-	}
-    } else {
-	if (relative) {
-	    res = xmlBuildRelativeURI((xmlChar *)str, (xmlChar *) base);
-	} else {
-	    res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
-	}
-
-	if (res != NULL) {
-	    printf("%s\n", (char *) res);
-	}
-	else
-	    printf("::ERROR::\n");
-    }
-    if (res != NULL)
-	xmlFree(res);
-    if (parsed != NULL)
-	xmlFree(parsed);
-    xmlFreeURI(uri);
-}
-
-int main(int argc, char **argv) {
-    int i, arg = 1;
-
-    if ((argc > arg) && (argv[arg] != NULL) &&
-	(!strcmp(argv[arg], "--relative"))) {
-	arg++;
-	relative++;
-    }
-    if ((argc > arg) && (argv[arg] != NULL) &&
-	((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
-	arg++;
-	base = argv[arg];
-	if (base != NULL)
-	    arg++;
-    }
-    if ((argc > arg) && (argv[arg] != NULL) &&
-	((!strcmp(argv[arg], "-escape")) || (!strcmp(argv[arg], "--escape")))) {
-	arg++;
-	escape++;
-    }
-    if ((argc > arg) && (argv[arg] != NULL) &&
-	((!strcmp(argv[arg], "-debug")) || (!strcmp(argv[arg], "--debug")))) {
-	arg++;
-	debug++;
-    }
-    if (argv[arg] == NULL) {
-	char str[1024];
-
-        while (1) {
-	    /*
-	     * read one line in string buffer.
-	     */
-	    if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL)
-	       break;
-
-	    /*
-	     * remove the ending spaces
-	     */
-	    i = strlen(str);
-	    while ((i > 0) &&
-		   ((str[i - 1] == '\n') || (str[i - 1] == '\r') ||
-		    (str[i - 1] == ' ') || (str[i - 1] == '\t'))) {
-		i--;
-		str[i] = 0;
-	    }
-	    handleURI(str);
-        }
-    } else {
-	while (argv[arg] != NULL) {
-	    handleURI(argv[arg]);
-	    arg++;
-	}
-    }
-    xmlMemoryDump();
-    return(0);
-}
diff --git a/src/testXPath.c b/src/testXPath.c
deleted file mode 100644
index 0e37723..0000000
--- a/src/testXPath.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * testXPath.c : a small tester program for XPath.
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include "libxml.h"
-#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <libxml/xpath.h>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/parserInternals.h>
-#include <libxml/xpathInternals.h>
-#include <libxml/xmlerror.h>
-#include <libxml/globals.h>
-#if defined(LIBXML_XPTR_ENABLED)
-#include <libxml/xpointer.h>
-static int xptr = 0;
-#endif
-static int debug = 0;
-static int valid = 0;
-static int expr = 0;
-static int tree = 0;
-static int nocdata = 0;
-static xmlDocPtr document = NULL;
-
-/*
- * Default document
- */
-static xmlChar buffer[] =
-"<?xml version=\"1.0\"?>\n\
-<EXAMPLE prop1=\"gnome is great\" prop2=\"&amp; linux too\">\n\
-  <head>\n\
-   <title>Welcome to Gnome</title>\n\
-  </head>\n\
-  <chapter>\n\
-   <title>The Linux adventure</title>\n\
-   <p>bla bla bla ...</p>\n\
-   <image href=\"linus.gif\"/>\n\
-   <p>...</p>\n\
-  </chapter>\n\
-  <chapter>\n\
-   <title>Chapter 2</title>\n\
-   <p>this is chapter 2 ...</p>\n\
-  </chapter>\n\
-  <chapter>\n\
-   <title>Chapter 3</title>\n\
-   <p>this is chapter 3 ...</p>\n\
-  </chapter>\n\
-</EXAMPLE>\n\
-";
-
-
-static void
-testXPath(const char *str) {
-    xmlXPathObjectPtr res;
-    xmlXPathContextPtr ctxt;
-
-#if defined(LIBXML_XPTR_ENABLED)
-    if (xptr) {
-	ctxt = xmlXPtrNewContext(document, NULL, NULL);
-	res = xmlXPtrEval(BAD_CAST str, ctxt);
-    } else {
-#endif
-	ctxt = xmlXPathNewContext(document);
-	ctxt->node = xmlDocGetRootElement(document);
-	if (expr)
-	    res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
-	else {
-	    /* res = xmlXPathEval(BAD_CAST str, ctxt); */
-	    xmlXPathCompExprPtr comp;
-
-	    comp = xmlXPathCompile(BAD_CAST str);
-	    if (comp != NULL) {
-		if (tree)
-		    xmlXPathDebugDumpCompExpr(stdout, comp, 0);
-
-		res = xmlXPathCompiledEval(comp, ctxt);
-		xmlXPathFreeCompExpr(comp);
-	    } else
-		res = NULL;
-	}
-#if defined(LIBXML_XPTR_ENABLED)
-    }
-#endif
-    xmlXPathDebugDumpObject(stdout, res, 0);
-    xmlXPathFreeObject(res);
-    xmlXPathFreeContext(ctxt);
-}
-
-static void
-testXPathFile(const char *filename) {
-    FILE *input;
-    char expression[5000];
-    int len;
-
-    input = fopen(filename, "rb");
-    if (input == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-		"Cannot open %s for reading\n", filename);
-	return;
-    }
-    while (fgets(expression, 4500, input) != NULL) {
-	len = strlen(expression);
-	len--;
-	while ((len >= 0) &&
-	       ((expression[len] == '\n') || (expression[len] == '\t') ||
-		(expression[len] == '\r') || (expression[len] == ' '))) len--;
-	expression[len + 1] = 0;
-	if (len >= 0) {
-	    printf("\n========================\nExpression: %s\n", expression) ;
-	    testXPath(expression);
-	}
-    }
-
-    fclose(input);
-}
-
-int main(int argc, char **argv) {
-    int i;
-    int strings = 0;
-    int usefile = 0;
-    char *filename = NULL;
-
-    for (i = 1; i < argc ; i++) {
-#if defined(LIBXML_XPTR_ENABLED)
-	if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr")))
-	    xptr++;
-	else
-#endif
-	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
-	    debug++;
-	else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
-	    valid++;
-	else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
-	    expr++;
-	else if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree")))
-	    tree++;
-	else if ((!strcmp(argv[i], "-nocdata")) ||
-		 (!strcmp(argv[i], "--nocdata")))
-	    nocdata++;
-	else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input")))
-	    filename = argv[++i];
-	else if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
-	    usefile++;
-    }
-    if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
-    xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
-    xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
-    xmlSubstituteEntitiesDefaultValue = 1;
-#ifdef LIBXML_SAX1_ENABLED
-    if (nocdata != 0) {
-	xmlDefaultSAXHandlerInit();
-	xmlDefaultSAXHandler.cdataBlock = NULL;
-    }
-#endif
-    if (document == NULL) {
-        if (filename == NULL)
-	    document = xmlReadDoc(buffer,NULL,NULL,XML_PARSE_COMPACT);
-	else
-	    document = xmlReadFile(filename,NULL,XML_PARSE_COMPACT);
-    }
-    for (i = 1; i < argc ; i++) {
-	if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) {
-	    i++; continue;
-	}
-	if (argv[i][0] != '-') {
-	    if (usefile)
-	        testXPathFile(argv[i]);
-	    else
-		testXPath(argv[i]);
-	    strings ++;
-	}
-    }
-    if (strings == 0) {
-	printf("Usage : %s [--debug] [--copy] stringsorfiles ...\n",
-	       argv[0]);
-	printf("\tParse the XPath strings and output the result of the parsing\n");
-	printf("\t--debug : dump a debug version of the result\n");
-	printf("\t--valid : switch on DTD support in the parser\n");
-#if defined(LIBXML_XPTR_ENABLED)
-	printf("\t--xptr : expressions are XPointer expressions\n");
-#endif
-	printf("\t--expr : debug XPath expressions only\n");
-	printf("\t--tree : show the compiled XPath tree\n");
-	printf("\t--nocdata : do not generate CDATA nodes\n");
-	printf("\t--input filename : or\n");
-	printf("\t-i filename      : read the document from filename\n");
-	printf("\t--file : or\n");
-	printf("\t-f     : read queries from files, args\n");
-    }
-    if (document != NULL)
-	xmlFreeDoc(document);
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return(0);
-}
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : XPath/Debug support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_XPATH_ENABLED */
diff --git a/src/testchar.c b/src/testchar.c
index 51e4acf..bd1a8d6 100644
--- a/src/testchar.c
+++ b/src/testchar.c
@@ -23,7 +23,7 @@
 char document1[100] = "<doc>XXXX</doc>";
 char document2[100] = "<doc foo='XXXX'/>";
 
-static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document,
+static int testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document,
                   int len,  char *data, int forbid1, int forbid2) {
     int i;
     xmlDocPtr res;
@@ -37,33 +37,41 @@
 	res = xmlReadMemory(document, len, "test", NULL, 0);
 
 	if ((i == forbid1) || (i == forbid2)) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 	        fprintf(stderr,
 		    "Failed to detect invalid char for Byte 0x%02X: %c\n",
 		        i, i);
+		return(1);
+	    }
 	}
 
 	else if ((i == '<') || (i == '&')) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 	        fprintf(stderr,
 		    "Failed to detect illegal char %c for Byte 0x%02X\n", i, i);
+		return(1);
+	    }
 	}
 	else if (((i < 0x20) || (i >= 0x80)) &&
 	    (i != 0x9) && (i != 0xA) && (i != 0xD)) {
-	    if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL))
+	    if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) {
 	        fprintf(stderr,
 		    "Failed to detect invalid char for Byte 0x%02X\n", i);
+		return(1);
+	    }
 	}
 	else if (res == NULL) {
 	    fprintf(stderr,
 		"Failed to parse valid char for Byte 0x%02X : %c\n", i, i);
+		return(1);
 	}
 	if (res != NULL)
 	    xmlFreeDoc(res);
     }
+    return(0);
 }
 
-static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document,
+static int testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document,
                   int len,  char *data) {
     int i, j;
     xmlDocPtr res;
@@ -80,10 +88,12 @@
 
 	/* if first bit of first char is set, then second bit must too */
 	if ((i & 0x80) && ((i & 0x40) == 0)) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 		fprintf(stderr,
 		"Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
 			i, j);
+		return(1);
+	    }
 	}
 
 	/*
@@ -91,10 +101,12 @@
 	 * bits must be 10
 	 */
 	else if ((i & 0x80) && ((j & 0xC0) != 0x80)) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 		fprintf(stderr,
 	    "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
 			i, j);
+		return(1);
+	    }
 	}
 
 	/*
@@ -102,10 +114,12 @@
 	 * than 0x80, i.e. one of bits 5 to 1 of i must be set
 	 */
 	else if ((i & 0x80) && ((i & 0x1E) == 0)) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 		fprintf(stderr,
 	    "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
 			i, j);
+		return(1);
+	    }
 	}
 
 	/*
@@ -113,10 +127,12 @@
 	 * at least 3 bytes, but we give only 2 !
 	 */
 	else if ((i & 0xE0) == 0xE0) {
-	    if ((lastError == 0) || (res != NULL))
+	    if ((lastError == 0) || (res != NULL)) {
 		fprintf(stderr,
 	    "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n",
 			i, j);
+		return(1);
+	    }
 	}
 
 	/*
@@ -125,11 +141,13 @@
 	else if ((lastError != 0) || (res == NULL)) {
 	    fprintf(stderr,
 		"Failed to parse document for Bytes 0x%02X 0x%02X\n", i, j);
+	    return(1);
 	}
 	if (res != NULL)
 	    xmlFreeDoc(res);
     }
     }
+    return(0);
 }
 
 /**
@@ -141,9 +159,10 @@
  * CDATA in text or in attribute values.
  */
 
-static void testDocumentRanges(void) {
+static int testDocumentRanges(void) {
     xmlParserCtxtPtr ctxt;
     char *data;
+    int test_ret = 0;
 
     /*
      * Set up a parsing context using the first document as
@@ -152,7 +171,7 @@
     ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {
         fprintf(stderr, "Failed to allocate parser context\n");
-	return;
+	return(1);
     }
 
     printf("testing 1 byte char in document: 1");
@@ -163,7 +182,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 1 byte injection at beginning of area */
-    testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
+    test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
                            data, -1, -1);
     printf(" 2");
     fflush(stdout);
@@ -172,7 +191,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 1 byte injection at end of area */
-    testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
+    test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
                            data + 3, -1, -1);
 
     printf(" 3");
@@ -183,7 +202,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 1 byte injection at beginning of area */
-    testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
+    test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
                            data, '\'', -1);
     printf(" 4");
     fflush(stdout);
@@ -192,7 +211,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 1 byte injection at end of area */
-    testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
+    test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
                            data + 3, '\'', -1);
     printf(" done\n");
 
@@ -204,7 +223,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 2 byte injection at beginning of area */
-    testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
+    test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
                            data);
     printf(" 2");
     fflush(stdout);
@@ -213,7 +232,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 2 byte injection at end of area */
-    testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
+    test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
                            data + 2);
 
     printf(" 3");
@@ -224,7 +243,7 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 2 byte injection at beginning of area */
-    testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
+    test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
                            data);
     printf(" 4");
     fflush(stdout);
@@ -233,14 +252,15 @@
     data[2] = ' ';
     data[3] = ' ';
     /* test 2 byte injection at end of area */
-    testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
+    test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
                            data + 2);
     printf(" done\n");
 
     xmlFreeParserCtxt(ctxt);
+    return(test_ret);
 }
 
-static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
     int i = 0;
     int len, c;
 
@@ -255,19 +275,25 @@
         c = xmlCurrentChar(ctxt, &len);
 	if ((i == 0) || (i >= 0x80)) {
 	    /* we must see an error there */
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 	        fprintf(stderr,
 		    "Failed to detect invalid char for Byte 0x%02X\n", i);
+		return(1);
+	    }
 	} else if (i == 0xD) {
-	    if ((c != 0xA) || (len != 1))
+	    if ((c != 0xA) || (len != 1)) {
 		fprintf(stderr, "Failed to convert char for Byte 0x%02X\n", i);
+		return(1);
+	    }
 	} else if ((c != i) || (len != 1)) {
 	    fprintf(stderr, "Failed to parse char for Byte 0x%02X\n", i);
+	    return(1);
 	}
     }
+    return(0);
 }
 
-static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
     int i, j;
     int len, c;
 
@@ -284,10 +310,12 @@
 
 	    /* if first bit of first char is set, then second bit must too */
 	    if ((i & 0x80) && ((i & 0x40) == 0)) {
-		if (lastError != XML_ERR_INVALID_CHAR)
+		if (lastError != XML_ERR_INVALID_CHAR) {
 		    fprintf(stderr,
 		    "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
 		            i, j);
+		    return(1);
+		}
 	    }
 
 	    /*
@@ -295,10 +323,12 @@
 	     * bits must be 10
 	     */
 	    else if ((i & 0x80) && ((j & 0xC0) != 0x80)) {
-		if (lastError != XML_ERR_INVALID_CHAR)
+		if (lastError != XML_ERR_INVALID_CHAR) {
 		    fprintf(stderr,
 		"Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n",
 		            i, j, c);
+		    return(1);
+		}
 	    }
 
 	    /*
@@ -306,10 +336,12 @@
 	     * than 0x80, i.e. one of bits 5 to 1 of i must be set
 	     */
 	    else if ((i & 0x80) && ((i & 0x1E) == 0)) {
-		if (lastError != XML_ERR_INVALID_CHAR)
+		if (lastError != XML_ERR_INVALID_CHAR) {
 		    fprintf(stderr,
 		"Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n",
 		            i, j, c);
+		    return(1);
+		}
 	    }
 
 	    /*
@@ -317,10 +349,12 @@
 	     * at least 3 bytes, but we give only 2 !
 	     */
 	    else if ((i & 0xE0) == 0xE0) {
-		if (lastError != XML_ERR_INVALID_CHAR)
+		if (lastError != XML_ERR_INVALID_CHAR) {
 		    fprintf(stderr,
 		"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n",
 		            i, j);
+		    return(1);
+		}
 	    }
 
             /*
@@ -329,6 +363,7 @@
 	    else if ((lastError != 0) || (len != 2)) {
 		fprintf(stderr,
 		    "Failed to parse char for Bytes 0x%02X 0x%02X\n", i, j);
+		return(1);
 	    }
 
             /*
@@ -338,12 +373,14 @@
 		fprintf(stderr,
 	"Failed to parse char for Bytes 0x%02X 0x%02X: expect %d got %d\n",
 	                i, j, ((j & 0x3F) + ((i & 0x1F) << 6)), c);
+		return(1);
 	    }
         }
     }
+    return(0);
 }
 
-static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
     int i, j, k, K;
     int len, c;
     unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
@@ -368,20 +405,24 @@
 	 * at least 4 bytes, but we give only 3 !
 	 */
 	if ((i & 0xF0) == 0xF0) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			i, j, K, data[3]);
+		return(1);
+	    }
 	}
 
         /*
 	 * The second and the third bytes must start with 10
 	 */
 	else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80)) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n",
 			i, j, K);
+		return(1);
+	    }
 	}
 
 	/*
@@ -390,10 +431,12 @@
 	 * the 6th byte of data[1] must be set
 	 */
 	else if (((i & 0xF) == 0) && ((j & 0x20) == 0)) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	    "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n",
 			i, j, K);
+		return(1);
+	    }
 	}
 
         /*
@@ -401,10 +444,12 @@
 	 */
 	else if (((value > 0xD7FF) && (value <0xE000)) ||
 	         ((value > 0xFFFD) && (value <0x10000))) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	"Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n",
 			value, i, j, K);
+		return(1);
+	    }
 	}
 
 	/*
@@ -414,6 +459,7 @@
 	    fprintf(stderr,
 		"Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
 		    i, j, K);
+	    return(1);
 	}
 
 	/*
@@ -423,13 +469,15 @@
 	    fprintf(stderr,
     "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
 		i, j, data[2], value, c);
+	    return(1);
 	}
     }
     }
     }
+    return(0);
 }
 
-static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
     int i, j, k, K, l, L;
     int len, c;
     unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
@@ -458,10 +506,12 @@
 	 * at least 5 bytes, but we give only 4 !
 	 */
 	if ((i & 0xF8) == 0xF8) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
   "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			i, j, K, data[3]);
+		return(1);
+	    }
 	}
 
         /*
@@ -469,10 +519,12 @@
 	 */
 	else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) ||
 	         ((L & 0xC0) != 0x80)) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			i, j, K, L);
+		return(1);
+	    }
 	}
 
 	/*
@@ -481,10 +533,12 @@
 	 * the 6 or 5th byte of j must be set
 	 */
 	else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 	"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			i, j, K, L);
+		return(1);
+	    }
 	}
 
         /*
@@ -493,10 +547,12 @@
 	else if (((value > 0xD7FF) && (value <0xE000)) ||
 	         ((value > 0xFFFD) && (value <0x10000)) ||
 		 (value > 0x10FFFF)) {
-	    if (lastError != XML_ERR_INVALID_CHAR)
+	    if (lastError != XML_ERR_INVALID_CHAR) {
 		fprintf(stderr,
 "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			value, i, j, K, L);
+		return(1);
+	    }
 	}
 
 	/*
@@ -506,6 +562,7 @@
 	    fprintf(stderr,
 		"Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
 		    i, j, K);
+	    return(1);
 	}
 
 	/*
@@ -515,11 +572,13 @@
 	    fprintf(stderr,
     "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
 		i, j, data[2], value, c);
+	    return(1);
 	}
     }
     }
     }
     }
+    return(0);
 }
 
 /**
@@ -530,11 +589,12 @@
  * cover the full range of UTF-8 chars accepted by XML-1.0
  */
 
-static void testCharRanges(void) {
+static int testCharRanges(void) {
     char data[5];
     xmlParserCtxtPtr ctxt;
     xmlParserInputBufferPtr buf;
     xmlParserInputPtr input;
+    int test_ret = 0;
 
     memset(data, 0, 5);
 
@@ -545,17 +605,19 @@
     ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {
         fprintf(stderr, "Failed to allocate parser context\n");
-	return;
+	return(1);
     }
     buf = xmlParserInputBufferCreateStatic(data, sizeof(data),
                                            XML_CHAR_ENCODING_NONE);
     if (buf == NULL) {
         fprintf(stderr, "Failed to allocate input buffer\n");
+	test_ret = 1;
 	goto error;
     }
     input = xmlNewInputStream(ctxt);
     if (input == NULL) {
         xmlFreeParserInputBuffer(buf);
+	test_ret = 1;
 	goto error;
     }
     input->filename = NULL;
@@ -567,25 +629,28 @@
 
     printf("testing char range: 1");
     fflush(stdout);
-    testCharRangeByte1(ctxt, data);
+    test_ret += testCharRangeByte1(ctxt, data);
     printf(" 2");
     fflush(stdout);
-    testCharRangeByte2(ctxt, data);
+    test_ret += testCharRangeByte2(ctxt, data);
     printf(" 3");
     fflush(stdout);
-    testCharRangeByte3(ctxt, data);
+    test_ret += testCharRangeByte3(ctxt, data);
     printf(" 4");
     fflush(stdout);
-    testCharRangeByte4(ctxt, data);
+    test_ret += testCharRangeByte4(ctxt, data);
     printf(" done\n");
     fflush(stdout);
 
 error:
     xmlFreeParserCtxt(ctxt);
+    return(test_ret);
 }
 
 int main(void) {
 
+    int ret = 0;
+
     /*
      * this initialize the library and check potential ABI mismatches
      * between the version it was compiled for and the actual shared
@@ -602,8 +667,8 @@
     /*
      * Run the tests
      */
-    testCharRanges();
-    testDocumentRanges();
+    ret += testCharRanges();
+    ret += testDocumentRanges();
 
     /*
      * Cleanup function for the XML library.
@@ -613,5 +678,5 @@
      * this is to debug memory for regression tests
      */
     xmlMemoryDump();
-    return(0);
+    return(ret ? 1 : 0);
 }
diff --git a/src/threads.c b/src/threads.c
index 5e4db16..c33150e 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -16,12 +16,6 @@
 #include <libxml/threads.h>
 #include <libxml/globals.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #elif defined HAVE_WIN32_THREADS
@@ -91,7 +85,7 @@
 #ifdef HAVE_PTHREAD_H
     pthread_mutex_t lock;
 #elif defined HAVE_WIN32_THREADS
-    HANDLE mutex;
+    CRITICAL_SECTION cs;
 #elif defined HAVE_BEOS_THREADS
     sem_id sem;
     thread_id tid;
@@ -112,7 +106,6 @@
     pthread_cond_t cv;
 #elif defined HAVE_WIN32_THREADS
     CRITICAL_SECTION cs;
-    unsigned int count;
 #elif defined HAVE_BEOS_THREADS
     xmlMutexPtr lock;
     thread_id tid;
@@ -182,7 +175,7 @@
     if (libxml_is_threaded != 0)
         pthread_mutex_init(&tok->lock, NULL);
 #elif defined HAVE_WIN32_THREADS
-    tok->mutex = CreateMutex(NULL, FALSE, NULL);
+    InitializeCriticalSection(&tok->cs);
 #elif defined HAVE_BEOS_THREADS
     if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
         free(tok);
@@ -210,7 +203,7 @@
     if (libxml_is_threaded != 0)
         pthread_mutex_destroy(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
-    CloseHandle(tok->mutex);
+    DeleteCriticalSection(&tok->cs);
 #elif defined HAVE_BEOS_THREADS
     delete_sem(tok->sem);
 #endif
@@ -232,7 +225,7 @@
     if (libxml_is_threaded != 0)
         pthread_mutex_lock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
-    WaitForSingleObject(tok->mutex, INFINITE);
+    EnterCriticalSection(&tok->cs);
 #elif defined HAVE_BEOS_THREADS
     if (acquire_sem(tok->sem) != B_NO_ERROR) {
 #ifdef DEBUG_THREADS
@@ -260,7 +253,7 @@
     if (libxml_is_threaded != 0)
         pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
-    ReleaseMutex(tok->mutex);
+    LeaveCriticalSection(&tok->cs);
 #elif defined HAVE_BEOS_THREADS
     if (tok->tid == find_thread(NULL)) {
         tok->tid = -1;
@@ -295,7 +288,6 @@
     }
 #elif defined HAVE_WIN32_THREADS
     InitializeCriticalSection(&tok->cs);
-    tok->count = 0;
 #elif defined HAVE_BEOS_THREADS
     if ((tok->lock = xmlNewMutex()) == NULL) {
         free(tok);
@@ -364,7 +356,6 @@
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-    tok->count++;
 #elif defined HAVE_BEOS_THREADS
     if (tok->lock->tid == find_thread(NULL)) {
         tok->count++;
@@ -400,10 +391,7 @@
     }
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
-    if (tok->count > 0) {
-	tok->count--;
-        LeaveCriticalSection(&tok->cs);
-    }
+    LeaveCriticalSection(&tok->cs);
 #elif defined HAVE_BEOS_THREADS
     if (tok->lock->tid == find_thread(NULL)) {
         tok->count--;
@@ -849,6 +837,9 @@
 /**
  * xmlInitThreads:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * xmlInitThreads() is used to to initialize all the thread related
  * data of the libxml2 library.
  */
@@ -889,6 +880,11 @@
 /**
  * xmlCleanupThreads:
  *
+ * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ *
  * xmlCleanupThreads() is used to to cleanup all the thread related
  * data of the libxml2 library once processing has ended.
  *
diff --git a/src/tree.c b/src/tree.c
index 1253274..8077348 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -355,7 +355,7 @@
 
 #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 /**
  * xmlValidateNCName:
  * @value: the value to check
@@ -1284,7 +1284,7 @@
 
     buf = xmlBufCreateSize(0);
     if (buf == NULL) return(NULL);
-    xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
+    xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 
     q = cur;
     while ((cur < end) && (*cur != 0)) {
@@ -1505,7 +1505,7 @@
 
     buf = xmlBufCreateSize(0);
     if (buf == NULL) return(NULL);
-    xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
+    xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 
     q = cur;
     while (*cur != 0) {
@@ -3703,9 +3703,6 @@
     while (1) {
         while ((cur->children != NULL) &&
                (cur->type != XML_DOCUMENT_NODE) &&
-#ifdef LIBXML_DOCB_ENABLED
-               (cur->type != XML_DOCB_DOCUMENT_NODE) &&
-#endif
                (cur->type != XML_HTML_DOCUMENT_NODE) &&
                (cur->type != XML_DTD_NODE) &&
                (cur->type != XML_ENTITY_REF_NODE)) {
@@ -3716,9 +3713,6 @@
         next = cur->next;
         parent = cur->parent;
 	if ((cur->type == XML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-            (cur->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
             (cur->type == XML_HTML_DOCUMENT_NODE)) {
             xmlFreeDoc((xmlDocPtr) cur);
         } else if (cur->type != XML_DTD_NODE) {
@@ -4235,9 +4229,6 @@
 
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
 #ifdef LIBXML_TREE_ENABLED
 	    return((xmlNodePtr) xmlCopyDoc((xmlDocPtr) node, extended));
 #endif /* LIBXML_TREE_ENABLED */
@@ -4351,8 +4342,45 @@
 	}
 	ret->last = ret->children;
     } else if ((node->children != NULL) && (extended != 2)) {
-        ret->children = xmlStaticCopyNodeList(node->children, doc, ret);
-	UPDATE_LAST_CHILD_AND_PARENT(ret)
+        xmlNodePtr cur, insert;
+
+        cur = node->children;
+        insert = ret;
+        while (cur != NULL) {
+            xmlNodePtr copy = xmlStaticCopyNode(cur, doc, insert, 2);
+            if (copy == NULL) {
+                xmlFreeNode(ret);
+                return(NULL);
+            }
+
+            if (insert->last == NULL) {
+                insert->children = copy;
+            } else {
+                copy->prev = insert->last;
+                insert->last->next = copy;
+            }
+            insert->last = copy;
+
+            if (cur->children != NULL) {
+                cur = cur->children;
+                insert = copy;
+                continue;
+            }
+
+            while (1) {
+                if (cur->next != NULL) {
+                    cur = cur->next;
+                    break;
+                }
+
+                cur = cur->parent;
+                insert = insert->parent;
+                if (cur == node) {
+                    cur = NULL;
+                    break;
+                }
+            }
+        }
     }
 
 out:
@@ -5037,9 +5065,6 @@
         case XML_ENTITY_REF_NODE:
         case XML_ENTITY_NODE:
 	case XML_NAMESPACE_DECL:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
 	    return;
@@ -5113,9 +5138,6 @@
 	case XML_NAMESPACE_DECL:
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return;
         case XML_ELEMENT_NODE:
         case XML_ATTRIBUTE_NODE:
@@ -5196,9 +5218,6 @@
 	case XML_NAMESPACE_DECL:
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return;
         case XML_ELEMENT_NODE:
         case XML_ATTRIBUTE_NODE:
@@ -5269,9 +5288,6 @@
         case XML_ATTRIBUTE_NODE:
 	    break;
         case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
         case XML_HTML_DOCUMENT_NODE: {
 	    xmlDocPtr doc = (xmlDocPtr) cur;
 
@@ -5533,9 +5549,6 @@
         case XML_XINCLUDE_END:
             break;
         case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
         case XML_HTML_DOCUMENT_NODE:
 	    cur = cur->children;
 	    while (cur!= NULL) {
@@ -5583,6 +5596,7 @@
                 buf = xmlBufCreateSize(64);
                 if (buf == NULL)
                     return (NULL);
+                xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 		xmlBufGetNodeContent(buf, cur);
                 ret = xmlBufDetach(buf);
                 xmlBufFree(buf);
@@ -5608,6 +5622,7 @@
                 buf = xmlBufCreate();
                 if (buf == NULL)
                     return (NULL);
+                xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 
                 xmlBufGetNodeContent(buf, cur);
 
@@ -5623,9 +5638,6 @@
         case XML_XINCLUDE_END:
             return (NULL);
         case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
         case XML_HTML_DOCUMENT_NODE: {
 	    xmlBufPtr buf;
 	    xmlChar *ret;
@@ -5633,6 +5645,7 @@
 	    buf = xmlBufCreate();
 	    if (buf == NULL)
 		return (NULL);
+            xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
 
 	    xmlBufGetNodeContent(buf, (xmlNodePtr) cur);
 
@@ -5717,9 +5730,6 @@
         case XML_DOCUMENT_TYPE_NODE:
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    break;
         case XML_NOTATION_NODE:
 	    break;
@@ -5797,9 +5807,6 @@
 	case XML_NAMESPACE_DECL:
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    break;
         case XML_ELEMENT_DECL:
 	    /* TODO !!! */
@@ -5879,9 +5886,6 @@
 	case XML_NAMESPACE_DECL:
 	case XML_XINCLUDE_START:
 	case XML_XINCLUDE_END:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    break;
         case XML_ELEMENT_DECL:
         case XML_ATTRIBUTE_DECL:
diff --git a/src/valid.c b/src/valid.c
index 16fa923..825a3cf 100644
--- a/src/valid.c
+++ b/src/valid.c
@@ -518,11 +518,6 @@
 	case XML_HTML_DOCUMENT_NODE:
 	    xmlGenericError(xmlGenericErrorContext, "?html? ");
 	    break;
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-	    xmlGenericError(xmlGenericErrorContext, "?docb? ");
-	    break;
-#endif
 	case XML_DTD_NODE:
 	    xmlGenericError(xmlGenericErrorContext, "?dtd? ");
 	    break;
@@ -5283,9 +5278,6 @@
 		break;
             case XML_ATTRIBUTE_NODE:
             case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    case XML_HTML_DOCUMENT_NODE:
             case XML_DOCUMENT_TYPE_NODE:
             case XML_DOCUMENT_FRAG_NODE:
diff --git a/src/win32/Makefile.bcb b/src/win32/Makefile.bcb
index d326fb9..c4b5125 100644
--- a/src/win32/Makefile.bcb
+++ b/src/win32/Makefile.bcb
@@ -119,7 +119,6 @@
 	$(XML_INTDIR)\chvalid.obj\
 	$(XML_INTDIR)\debugXML.obj\
 	$(XML_INTDIR)\dict.obj\
-	$(XML_INTDIR)\DOCBparser.obj\
 	$(XML_INTDIR)\encoding.obj\
 	$(XML_INTDIR)\entities.obj\
 	$(XML_INTDIR)\error.obj\
@@ -165,7 +164,6 @@
 	$(XML_INTDIR_A)\chvalid.obj\
 	$(XML_INTDIR_A)\debugXML.obj\
 	$(XML_INTDIR_A)\dict.obj\
-	$(XML_INTDIR_A)\DOCBparser.obj\
 	$(XML_INTDIR_A)\encoding.obj\
 	$(XML_INTDIR_A)\entities.obj\
 	$(XML_INTDIR_A)\error.obj\
@@ -208,17 +206,7 @@
 UTILS = $(BINDIR)\xmllint.exe\
 	$(BINDIR)\xmlcatalog.exe\
 	$(BINDIR)\testAutomata.exe\
-	$(BINDIR)\testC14N.exe\
-	$(BINDIR)\testDocbook.exe\
-	$(BINDIR)\testHTML.exe\
-	$(BINDIR)\testReader.exe\
-	$(BINDIR)\testRelax.exe\
-	$(BINDIR)\testRegexp.exe\
 	$(BINDIR)\testModule.exe\
-	$(BINDIR)\testSAX.exe\
-	$(BINDIR)\testSchemas.exe\
-	$(BINDIR)\testURI.exe\
-	$(BINDIR)\testXPath.exe\
 	$(BINDIR)\runtest.exe\
 	$(BINDIR)\runsuite.exe\
 	$(BINDIR)\testapi.exe\
diff --git a/src/win32/Makefile.mingw b/src/win32/Makefile.mingw
index 9dfa4ab..13f2d96 100644
--- a/src/win32/Makefile.mingw
+++ b/src/win32/Makefile.mingw
@@ -111,7 +111,6 @@
 	$(XML_INTDIR)/chvalid.o\
 	$(XML_INTDIR)/debugXML.o\
 	$(XML_INTDIR)/dict.o\
-	$(XML_INTDIR)/DOCBparser.o\
 	$(XML_INTDIR)/encoding.o\
 	$(XML_INTDIR)/entities.o\
 	$(XML_INTDIR)/error.o\
@@ -159,7 +158,6 @@
 	$(XML_INTDIR_A)/chvalid.o\
 	$(XML_INTDIR_A)/debugXML.o\
 	$(XML_INTDIR_A)/dict.o\
-	$(XML_INTDIR_A)/DOCBparser.o\
 	$(XML_INTDIR_A)/encoding.o\
 	$(XML_INTDIR_A)/entities.o\
 	$(XML_INTDIR_A)/error.o\
@@ -204,17 +202,7 @@
 UTILS = $(BINDIR)/xmllint.exe\
 	$(BINDIR)/xmlcatalog.exe\
 	$(BINDIR)/testAutomata.exe\
-	$(BINDIR)/testC14N.exe\
-	$(BINDIR)/testDocbook.exe\
-	$(BINDIR)/testHTML.exe\
-	$(BINDIR)/testReader.exe\
-	$(BINDIR)/testRegexp.exe\
 	$(BINDIR)/testModule.exe\
-	$(BINDIR)/testRelax.exe\
-	$(BINDIR)/testSAX.exe\
-	$(BINDIR)/testSchemas.exe\
-	$(BINDIR)/testURI.exe\
-	$(BINDIR)/testXPath.exe\
 	$(BINDIR)/runtest.exe\
 	$(BINDIR)/runsuite.exe\
 	$(BINDIR)/testapi.exe\
diff --git a/src/win32/Makefile.msvc b/src/win32/Makefile.msvc
index 725b0ca..80e64e2 100644
--- a/src/win32/Makefile.msvc
+++ b/src/win32/Makefile.msvc
@@ -118,7 +118,6 @@
 	$(XML_INTDIR)\chvalid.obj\
 	$(XML_INTDIR)\debugXML.obj\
 	$(XML_INTDIR)\dict.obj\
-	$(XML_INTDIR)\DOCBparser.obj\
 	$(XML_INTDIR)\encoding.obj\
 	$(XML_INTDIR)\entities.obj\
 	$(XML_INTDIR)\error.obj\
@@ -164,7 +163,6 @@
 	$(XML_INTDIR_A)\chvalid.obj\
 	$(XML_INTDIR_A)\debugXML.obj\
 	$(XML_INTDIR_A)\dict.obj\
-	$(XML_INTDIR_A)\DOCBparser.obj\
 	$(XML_INTDIR_A)\encoding.obj\
 	$(XML_INTDIR_A)\entities.obj\
 	$(XML_INTDIR_A)\error.obj\
@@ -210,7 +208,6 @@
 	$(XML_INTDIR_A_DLL)\chvalid.obj\
 	$(XML_INTDIR_A_DLL)\debugXML.obj\
 	$(XML_INTDIR_A_DLL)\dict.obj\
-	$(XML_INTDIR_A_DLL)\DOCBparser.obj\
 	$(XML_INTDIR_A_DLL)\encoding.obj\
 	$(XML_INTDIR_A_DLL)\entities.obj\
 	$(XML_INTDIR_A_DLL)\error.obj\
@@ -259,17 +256,7 @@
 UTILS = $(BINDIR)\xmllint.exe\
 	$(BINDIR)\xmlcatalog.exe\
 	$(BINDIR)\testAutomata.exe\
-	$(BINDIR)\testC14N.exe\
-	$(BINDIR)\testDocbook.exe\
-	$(BINDIR)\testHTML.exe\
-	$(BINDIR)\testReader.exe\
-	$(BINDIR)\testRelax.exe\
-	$(BINDIR)\testRegexp.exe\
 	$(BINDIR)\testModule.exe\
-	$(BINDIR)\testSAX.exe\
-	$(BINDIR)\testSchemas.exe\
-	$(BINDIR)\testURI.exe\
-	$(BINDIR)\testXPath.exe\
 	$(BINDIR)\runtest.exe\
 	$(BINDIR)\runsuite.exe\
 	$(BINDIR)\runxmlconf.exe\
@@ -440,63 +427,3 @@
 	cd .. && win32\$(BINDIR)\testdict.exe
 	cd .. && win32\$(BINDIR)\runxmlconf.exe
 
-XPathtests : $(BINDIR)\testXPath.exe
-	@echo. 2> .memdump
-	@echo ## XPath regression tests
-	@-$(BINDIR)\testXPath.exe | find /C "support not compiled in" 1>nul
-	@if %ERRORLEVEL% NEQ 0 @( \
-		echo Skipping debug not compiled in\
-		@exit 0 \
-	)
-	@for %%I in ($(XML_SRCDIR)\test\XPath\expr\*.*) do @( \
-		@IF NOT EXIST $(XML_SRCDIR)\result\XPath\expr\%%~nxI ( \
-			@echo New test %%~nxI &&\
-			@echo %%~nxI &&\
-			$(BINDIR)\testXPath.exe -f --expr %%I > $(XML_SRCDIR)/result/XPath/expr/%%~nxI &&\
-			findstr /C:"MEMORY ALLOCATED : 0" \
-		) ELSE ( \
-			$(BINDIR)\testXPath.exe -f --expr %%I 2>&1 > result.%%~nxI &&\
-			fc $(XML_SRCDIR)\result\XPath\expr\%%~nxI result.%%~nxI >nul &\
-			iF ERRORLEVEL 1 exit 1 & \
-			findstr "MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" >nul &&\
-			del result.%%~nxI \
-		) \
-	)
-	@for %%I in ($(XML_SRCDIR)\test\XPath\docs\*.*) do @( \
-		for %%J in ($(XML_SRCDIR)\test\XPath\tests\%%~nxI*.*) do @( \
-			if not exist $(XML_SRCDIR)\result\XPath\tests\%%~nxJ ( \
-				$(BINDIR)\testXPath.exe -f -i %%I %%J > $(XML_SRCDIR)\result\XPath\tests\%%~nxJ &&\
-				findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > nul \
-			) ELSE ( \
-				$(BINDIR)\testXPAth.exe -f -i %%I %%J 2>&1 > result.%%~nxJ &&\
-				findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0">null &&\
-				fc $(XML_SRCDIR)\result\XPath\tests\%%~nxJ result.%%~nxJ >null & \
-				IF ERRORLEVEL 1 (echo Error: %%I %%J & exit 1) & \
-				del result.%%~nxJ \
-			)\
-		)\
-	)
-
-XMLtests : $(BINDIR)\xmllint.exe
-	@echo. 2> .memdump
-	@echo ## XML regression tests
-	-@for %%I in ($(XML_SRCDIR)\test\*) do @( \
-		if not exist $(XML_SRCDIR)\result\%%~nxI ( \
-			echo New test file %%~nxI &\
-			$(BINDIR)\xmllint.exe  %%I > $(XML_SRCDIR)\result\%%~nxI && \
-			findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null \
-		) ELSE ( \
-			$(BINDIR)\xmllint.exe %%I 2>&1 > result.%%~nxI && \
-			findstr /C:"MEMORY ALLOC" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null && \
-			fc $(XML_SRCDIR)\result\%%~nxI result.%%~nxI > null && \
-			$(BINDIR)\xmllint.exe result.%%~nxI 2>&1 > result2.%%~nxI | findstr /V /C:"failed to load external entity" && \
-			fc result.%%~nxI result2.%%~nxI & \
-			del result.%%~nxI result2.%%~nxI\
-		) \
-	)	
-
-				
-
-
-
-	
diff --git a/src/win32/configure.js b/src/win32/configure.js
index d784f3b..e98df08 100644
--- a/src/win32/configure.js
+++ b/src/win32/configure.js
@@ -35,7 +35,6 @@
 var withHtml = true;
 var withC14n = true;
 var withCatalog = true;
-var withDocb = true;
 var withXpath = true;
 var withXptr = true;
 var withXinclude = true;
@@ -121,7 +120,6 @@
 	txt += "  html:       Enable HTML processor (" + (withHtml? "yes" : "no")  + ")\n";
 	txt += "  c14n:       Enable C14N support (" + (withC14n? "yes" : "no")  + ")\n";
 	txt += "  catalog:    Enable catalog support (" + (withCatalog? "yes" : "no")  + ")\n";
-	txt += "  docb:       Enable DocBook support (" + (withDocb? "yes" : "no")  + ")\n";
 	txt += "  xpath:      Enable XPath support (" + (withXpath? "yes" : "no")  + ")\n";
 	txt += "  xptr:       Enable XPointer support (" + (withXptr? "yes" : "no")  + ")\n";
 	txt += "  xinclude:   Enable XInclude support (" + (withXinclude? "yes" : "no")  + ")\n";
@@ -218,7 +216,6 @@
 	vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
 	vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
 	vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
-	vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
 	vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
 	vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
 	vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
@@ -315,8 +312,6 @@
 			of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
 		} else if (s.search(/\@WITH_CATALOG\@/) != -1) {
 			of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
-		} else if (s.search(/\@WITH_DOCB\@/) != -1) {
-			of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
 		} else if (s.search(/\@WITH_XPATH\@/) != -1) {
 			of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
 		} else if (s.search(/\@WITH_XPTR\@/) != -1) {
@@ -470,8 +465,6 @@
 			withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "catalog")
 			withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
-		else if (opt == "docb")
-			withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "xpath")
 			withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "xptr")
@@ -661,7 +654,6 @@
 txtOut += "    HTML processor: " + boolToStr(withHtml) + "\n";
 txtOut += "      C14N support: " + boolToStr(withC14n) + "\n";
 txtOut += "   Catalog support: " + boolToStr(withCatalog) + "\n";
-txtOut += "   DocBook support: " + boolToStr(withDocb) + "\n";
 txtOut += "     XPath support: " + boolToStr(withXpath) + "\n";
 txtOut += "  XPointer support: " + boolToStr(withXptr) + "\n";
 txtOut += "  XInclude support: " + boolToStr(withXinclude) + "\n";
diff --git a/src/win32/defgen.xsl b/src/win32/defgen.xsl
index a598ff1..423a231 100644
--- a/src/win32/defgen.xsl
+++ b/src/win32/defgen.xsl
@@ -34,9 +34,6 @@
 			<xsl:if test="@file = 'debugXML'">
 				<xsl:text>#ifdef LIBXML_DEBUG_ENABLED&nl;</xsl:text>
 			</xsl:if>
-			<xsl:if test="@file = 'DOCBparser'">
-				<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
-			</xsl:if>
 			<xsl:if test="(@file = 'HTMLparser') 
 					or (@file = 'HTMLtree')">
 				<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
@@ -86,10 +83,6 @@
 					or (@name = 'xmlIOHTTPClose')">
 				<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
 			</xsl:if>
-			<xsl:if test="(@name = 'docbDefaultSAXHandlerInit') 
-					or (@name = 'initdocbDefaultSAXHandler')">
-				<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
-			</xsl:if>
 			<xsl:if test="@name = 'xmlValidBuildContentModel'">
 				<xsl:text>#ifdef LIBXML_REGEXP_ENABLED&nl;</xsl:text>
 			</xsl:if>
@@ -129,8 +122,7 @@
 					<xsl:text> DATA&nl;</xsl:text>
 					<xsl:text>#endif&nl;</xsl:text>
 				</xsl:when>
-				<xsl:when test="(@name = 'docbDefaultSAXHandler') 
-						or (@name = 'htmlDefaultSAXHandler') 
+				<xsl:when test="(@name = 'htmlDefaultSAXHandler') 
 						or (@name = 'oldXMLWDcompatibility') 
 						or (@name = 'xmlBufferAllocScheme') 
 						or (@name = 'xmlDefaultBufferSize') 
@@ -153,33 +145,21 @@
 						or (@name = 'xmlRegisterNodeDefaultValue') 
 						or (@name = 'xmlDeregisterNodeDefaultValue')">
 					<xsl:text>#ifdef LIBXML_THREAD_ENABLED&nl;</xsl:text>
-					<xsl:if test="@name = 'docbDefaultSAXHandler'">
-						<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
-					</xsl:if>
 					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
 						<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
 					</xsl:if>
 					<xsl:text>__</xsl:text>
 					<xsl:value-of select="@name"/>
 					<xsl:text>&nl;</xsl:text>
-					<xsl:if test="@name = 'docbDefaultSAXHandler'">
-						<xsl:text>#endif&nl;</xsl:text>
-					</xsl:if>
 					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
 						<xsl:text>#endif&nl;</xsl:text>
 					</xsl:if>
 					<xsl:text>#else&nl;</xsl:text>
-					<xsl:if test="@name = 'docbDefaultSAXHandler'">
-						<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
-					</xsl:if>
 					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
 						<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
 					</xsl:if>
 					<xsl:value-of select="@name"/>
 					<xsl:text> DATA&nl;</xsl:text>
-					<xsl:if test="@name = 'docbDefaultSAXHandler'">
-						<xsl:text>#endif&nl;</xsl:text>
-					</xsl:if>
 					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
 						<xsl:text>#endif&nl;</xsl:text>
 					</xsl:if>
@@ -203,9 +183,6 @@
 			<xsl:if test="@file = 'debugXML'">
 				<xsl:text>#endif&nl;</xsl:text>
 			</xsl:if>
-			<xsl:if test="@file = 'DOCBparser'">
-				<xsl:text>#endif&nl;</xsl:text>
-			</xsl:if>
 			<xsl:if test="(@file = 'HTMLparser') 
 					or (@file = 'HTMLtree')">
 				<xsl:text>#endif&nl;</xsl:text>
@@ -255,10 +232,6 @@
 					or (@name = 'xmlIOHTTPClose')">
 				<xsl:text>#endif&nl;</xsl:text>
 			</xsl:if>
-			<xsl:if test="(@name = 'docbDefaultSAXHandlerInit') 
-					or (@name = 'initdocbDefaultSAXHandler')">
-				<xsl:text>#endif&nl;</xsl:text>
-			</xsl:if>
 			<xsl:if test="@name = 'xmlValidBuildContentModel'">
 				<xsl:text>#endif&nl;</xsl:text>
 			</xsl:if>
diff --git a/src/win32/libxml2.def.src b/src/win32/libxml2.def.src
index c50d649..d83dbf4 100644
--- a/src/win32/libxml2.def.src
+++ b/src/win32/libxml2.def.src
@@ -2,15 +2,6 @@
 #include "../include/libxml/xmlversion.h"
 LIBRARY libxml2
 EXPORTS
-#ifdef LIBXML_THREAD_ENABLED
-#ifdef LIBXML_DOCB_ENABLED
-__docbDefaultSAXHandler
-#endif
-#else
-#ifdef LIBXML_DOCB_ENABLED
-docbDefaultSAXHandler DATA
-#endif
-#endif
 #ifdef LIBXML_REGEXP_ENABLED
 emptyExp DATA
 #endif
@@ -191,39 +182,6 @@
 characters
 checkNamespace
 comment
-#ifdef LIBXML_DOCB_ENABLED
-docbCreateFileParserCtxt
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbCreatePushParserCtxt
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbDefaultSAXHandlerInit
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbEncodeEntities
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbFreeParserCtxt
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbParseChunk
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbParseDoc
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbParseDocument
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbParseFile
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbSAXParseDoc
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-docbSAXParseFile
-#endif
 elementDecl
 endDocument
 endElement
@@ -415,9 +373,6 @@
 #endif
 ignorableWhitespace
 initGenericErrorDefaultFunc
-#ifdef LIBXML_DOCB_ENABLED
-initdocbDefaultSAXHandler
-#endif
 #ifdef LIBXML_HTML_ENABLED
 inithtmlDefaultSAXHandler
 #endif
@@ -1580,7 +1535,6 @@
 xmlSAX2HasInternalSubset
 xmlSAX2IgnorableWhitespace
 xmlSAX2InitDefaultSAXHandler
-xmlSAX2InitDocbDefaultSAXHandler
 xmlSAX2InitHtmlDefaultSAXHandler
 xmlSAX2InternalSubset
 xmlSAX2IsStandalone
diff --git a/src/xml2-config.1 b/src/xml2-config.1
deleted file mode 100644
index 4dec38f..0000000
--- a/src/xml2-config.1
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH GNOME-XML 1 "3 July 1999" Version 1.1.0
-.SH NAME
-xml-config - script to get information about the installed version of GNOME-XML
-.SH SYNOPSIS
-.B xml-config
-[\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help]
-.SH DESCRIPTION
-\fIxml-config\fP is a tool that is used to determine the compile and
-linker flags that should be used to compile and link programs that use
-\fIGNOME-XML\fP.
-.SH OPTIONS
-\fIxml-config\fP accepts the following options:
-.TP 8
-.B  \-\-version
-Print the currently installed version of \fIGNOME-XML\fP on the standard output.
-.TP 8
-.B  \-\-libs
-Print the linker flags that are necessary to link a \fIGNOME-XML\fP program.
-Add \-\-dynamic after --libs to print only shared library linking information.
-.TP 8
-.B  \-\-cflags
-Print the compiler flags that are necessary to compile a \fIGNOME-XML\fP program.
-.TP 8
-.B  \-\-prefix=PREFIX
-If specified, use PREFIX instead of the installation prefix that
-\fIGNOME-XML\fP was built with when computing the output for the
-\-\-cflags and \-\-libs options. This option must be specified before
-any \-\-libs or \-\-cflags options.
-.SH AUTHOR
-This manual page was written by Fredrik Hallenberg <hallon@lysator.liu.se>,
-for the Debian GNU/linux system (but may be used by others).
diff --git a/src/xml2Conf.sh.in b/src/xml2Conf.sh.in
deleted file mode 100644
index 31228c0..0000000
--- a/src/xml2Conf.sh.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Configuration file for using the XML library in GNOME applications
-#
-XML2_LIBDIR="@XML_LIBDIR@"
-XML2_LIBS="@XML_LIBS@ @XML_PRIVATE_LIBS@"
-XML2_INCLUDEDIR="@XML_INCLUDEDIR@"
-MODULE_VERSION="xml2-@VERSION@"
-
diff --git a/src/xmlIO.c b/src/xmlIO.c
index a80ef11..4d75473 100644
--- a/src/xmlIO.c
+++ b/src/xmlIO.c
@@ -37,6 +37,8 @@
 #if defined(_WIN32)
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+#include <io.h>
+#include <direct.h>
 #endif
 
 #ifndef S_ISDIR
@@ -2389,10 +2391,7 @@
         xmlFree(ret);
 	return(NULL);
     }
-
-    /* try to avoid a performance problem with Windows realloc() */
-    if (xmlBufGetAllocationScheme(ret->buffer) == XML_BUFFER_ALLOC_EXACT)
-        xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
+    xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
 
     ret->encoder = encoder;
     if (encoder != NULL) {
diff --git a/src/xmlmemory.c b/src/xmlmemory.c
index eeb76c3..892d50c 100644
--- a/src/xmlmemory.c
+++ b/src/xmlmemory.c
@@ -12,10 +12,6 @@
 #include <ctype.h>
 #include <time.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 /* #define DEBUG_MEMORY */
 
 /**
@@ -939,6 +935,9 @@
 /**
  * xmlInitMemory:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Initialize the memory layer.
  *
  * Returns 0 on success
@@ -978,6 +977,11 @@
 /**
  * xmlCleanupMemory:
  *
+ * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ *
  * Free up all the memory allocated by the library for its own
  * use. This should not be called by user level code.
  */
diff --git a/src/xmlreader.c b/src/xmlreader.c
index 45062a4..ba95813 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1180,6 +1180,7 @@
     buffer = xmlBufferCreate();
     if (buffer == NULL)
        return NULL;
+    xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
 
     for ( ; node != NULL; node = node->next) {
        switch (node->type) {
@@ -1384,9 +1385,6 @@
     reader->node = reader->node->parent;
     if ((reader->node == NULL) ||
 	(reader->node->type == XML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-	(reader->node->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
 	(reader->node->type == XML_HTML_DOCUMENT_NODE)) {
 	if (reader->mode != XML_TEXTREADER_MODE_EOF) {
 	    val = xmlParseChunk(reader->ctxt, "", 0, 1);
@@ -1636,11 +1634,14 @@
     buff = xmlBufferCreate();
     if (buff == NULL)
         return NULL;
+    xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
     for (cur_node = reader->node->children; cur_node != NULL;
          cur_node = cur_node->next) {
         /* XXX: Why is the node copied? */
         node = xmlDocCopyNode(cur_node, doc, 1);
+        /* XXX: Why do we need a second buffer? */
         buff2 = xmlBufferCreate();
+        xmlBufferSetAllocationScheme(buff2, XML_BUFFER_ALLOC_DOUBLEIT);
         if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) {
             xmlFreeNode(node);
             xmlBufferFree(buff2);
@@ -1690,6 +1691,7 @@
 		node = xmlDocCopyNode(node, doc, 1);
 	}
     buff = xmlBufferCreate();
+    xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
     if (xmlNodeDump(buff, doc, node, 0, 0) == -1) {
         xmlFreeNode(node);
         xmlBufferFree(buff);
@@ -2020,7 +2022,7 @@
     }
     /* no operation on a reader should require a huge buffer */
     xmlBufSetAllocationScheme(ret->buffer,
-			      XML_BUFFER_ALLOC_BOUNDED);
+			      XML_BUFFER_ALLOC_DOUBLEIT);
     ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
     if (ret->sax == NULL) {
 	xmlBufFree(ret->buffer);
@@ -2978,9 +2980,6 @@
 	    return(XML_READER_TYPE_COMMENT);
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return(XML_READER_TYPE_DOCUMENT);
         case XML_DOCUMENT_FRAG_NODE:
 	    return(XML_READER_TYPE_DOCUMENT_FRAGMENT);
@@ -3135,9 +3134,6 @@
 	    return(xmlStrdup(BAD_CAST "#comment"));
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return(xmlStrdup(BAD_CAST "#document"));
         case XML_DOCUMENT_FRAG_NODE:
 	    return(xmlStrdup(BAD_CAST "#document-fragment"));
@@ -3206,9 +3202,6 @@
 	    return(CONSTSTR(BAD_CAST "#comment"));
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-        case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return(CONSTSTR(BAD_CAST "#document"));
         case XML_DOCUMENT_FRAG_NODE:
 	    return(CONSTSTR(BAD_CAST "#document-fragment"));
@@ -3567,7 +3560,7 @@
                         return (NULL);
                     }
 		    xmlBufSetAllocationScheme(reader->buffer,
-		                              XML_BUFFER_ALLOC_BOUNDED);
+		                              XML_BUFFER_ALLOC_DOUBLEIT);
                 } else
                     xmlBufEmpty(reader->buffer);
 	        xmlBufGetNodeContent(reader->buffer, node);
@@ -3577,7 +3570,7 @@
 		    xmlBufFree(reader->buffer);
 		    reader->buffer = xmlBufCreateSize(100);
 		    xmlBufSetAllocationScheme(reader->buffer,
-		                              XML_BUFFER_ALLOC_BOUNDED);
+		                              XML_BUFFER_ALLOC_DOUBLEIT);
 		    ret = BAD_CAST "";
 		}
 		return(ret);
@@ -5091,7 +5084,7 @@
     }
     /* no operation on a reader should require a huge buffer */
     xmlBufSetAllocationScheme(reader->buffer,
-			      XML_BUFFER_ALLOC_BOUNDED);
+			      XML_BUFFER_ALLOC_DOUBLEIT);
     if (reader->sax == NULL)
 	reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
     if (reader->sax == NULL) {
diff --git a/src/xmlsave.c b/src/xmlsave.c
index 3addd65..7b55749 100644
--- a/src/xmlsave.c
+++ b/src/xmlsave.c
@@ -474,6 +474,7 @@
          */
         return;
     }
+    xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlDumpNotationTable(buffer, table);
     xmlBufMergeBuffer(buf, buffer);
 }
@@ -497,6 +498,7 @@
          */
         return;
     }
+    xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlDumpElementDecl(buffer, elem);
     xmlBufMergeBuffer(buf, buffer);
 }
@@ -520,6 +522,7 @@
          */
         return;
     }
+    xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlDumpAttributeDecl(buffer, attr);
     xmlBufMergeBuffer(buf, buffer);
 }
@@ -542,6 +545,7 @@
          */
         return;
     }
+    xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
     xmlDumpEntityDecl(buffer, ent);
     xmlBufMergeBuffer(buf, buffer);
 }
diff --git a/src/xpath.c b/src/xpath.c
index 982fc83..78606b7 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -29,10 +29,6 @@
 #include <float.h>
 #include <ctype.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/valid.h>
@@ -479,13 +475,16 @@
  *									*
  ************************************************************************/
 
-double xmlXPathNAN;
-double xmlXPathPINF;
-double xmlXPathNINF;
+double xmlXPathNAN = 0.0;
+double xmlXPathPINF = 0.0;
+double xmlXPathNINF = 0.0;
 
 /**
  * xmlXPathInit:
  *
+ * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * initialize the library.
+ *
  * Initialize the XPath environment
  */
 ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
@@ -7642,9 +7641,6 @@
             case XML_DOCUMENT_TYPE_NODE:
             case XML_DOCUMENT_FRAG_NODE:
             case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
 		return(((xmlDocPtr) ctxt->context->node)->children);
 	    case XML_ELEMENT_DECL:
 	    case XML_ATTRIBUTE_DECL:
@@ -7700,9 +7696,6 @@
 		return(NULL);
             case XML_DOCUMENT_NODE:
             case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
 		return(xmlDocGetRootElement((xmlDocPtr) cur));
 	    default:
 		return(NULL);
@@ -7763,9 +7756,6 @@
 	    case XML_XINCLUDE_START:
 	    case XML_DOCUMENT_FRAG_NODE:
 	    case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    case XML_HTML_DOCUMENT_NODE:
 		return(contextNode);
 	    default:
@@ -7790,9 +7780,6 @@
 		    break;
 		/* Not sure if we need those here. */
 		case XML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-		case XML_DOCB_DOCUMENT_NODE:
-#endif
 		case XML_HTML_DOCUMENT_NODE:
 		    if (cur != start)
 			return(cur);
@@ -7959,9 +7946,6 @@
             case XML_DOCUMENT_TYPE_NODE:
             case XML_DOCUMENT_FRAG_NODE:
             case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
                 return(NULL);
 	    case XML_NAMESPACE_DECL: {
 		xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
@@ -8032,9 +8016,6 @@
             case XML_DOCUMENT_TYPE_NODE:
             case XML_DOCUMENT_FRAG_NODE:
             case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	    case XML_DOCB_DOCUMENT_NODE:
-#endif
                 return(NULL);
 	    case XML_NAMESPACE_DECL: {
 		xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
@@ -8093,9 +8074,6 @@
 	case XML_DOCUMENT_TYPE_NODE:
 	case XML_DOCUMENT_FRAG_NODE:
 	case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-	case XML_DOCB_DOCUMENT_NODE:
-#endif
 	    return(NULL);
     }
     return(NULL);
@@ -9251,52 +9229,45 @@
  */
 void
 xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
-  xmlXPathObjectPtr obj = NULL;
-  xmlChar *source = NULL;
-  xmlBufPtr target;
-  xmlChar blank;
+    xmlChar *source, *target;
+    int blank;
 
-  if (ctxt == NULL) return;
-  if (nargs == 0) {
-    /* Use current context node */
-      valuePush(ctxt,
-	  xmlXPathCacheWrapString(ctxt->context,
-	    xmlXPathCastNodeToString(ctxt->context->node)));
-    nargs = 1;
-  }
+    if (ctxt == NULL) return;
+    if (nargs == 0) {
+        /* Use current context node */
+        valuePush(ctxt,
+            xmlXPathCacheWrapString(ctxt->context,
+                xmlXPathCastNodeToString(ctxt->context->node)));
+        nargs = 1;
+    }
 
-  CHECK_ARITY(1);
-  CAST_TO_STRING;
-  CHECK_TYPE(XPATH_STRING);
-  obj = valuePop(ctxt);
-  source = obj->stringval;
-
-  target = xmlBufCreate();
-  if (target && source) {
+    CHECK_ARITY(1);
+    CAST_TO_STRING;
+    CHECK_TYPE(XPATH_STRING);
+    source = ctxt->value->stringval;
+    if (source == NULL)
+        return;
+    target = source;
 
     /* Skip leading whitespaces */
     while (IS_BLANK_CH(*source))
-      source++;
+        source++;
 
     /* Collapse intermediate whitespaces, and skip trailing whitespaces */
     blank = 0;
     while (*source) {
-      if (IS_BLANK_CH(*source)) {
-	blank = 0x20;
-      } else {
-	if (blank) {
-	  xmlBufAdd(target, &blank, 1);
-	  blank = 0;
-	}
-	xmlBufAdd(target, source, 1);
-      }
-      source++;
+        if (IS_BLANK_CH(*source)) {
+	    blank = 1;
+        } else {
+            if (blank) {
+                *target++ = 0x20;
+                blank = 0;
+            }
+            *target++ = *source;
+        }
+        source++;
     }
-    valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
-	xmlBufContent(target)));
-    xmlBufFree(target);
-  }
-  xmlXPathReleaseObject(ctxt->context, obj);
+    *target = 0;
 }
 
 /**
@@ -12266,9 +12237,6 @@
 			switch (cur->type) {
 			    case XML_DOCUMENT_NODE:
 			    case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-			    case XML_DOCB_DOCUMENT_NODE:
-#endif
 			    case XML_ELEMENT_NODE:
 			    case XML_ATTRIBUTE_NODE:
 			    case XML_PI_NODE:
@@ -13698,9 +13666,6 @@
             case XML_DOCUMENT_NODE:
             case XML_DOCUMENT_FRAG_NODE:
             case XML_HTML_DOCUMENT_NODE:
-#ifdef LIBXML_DOCB_ENABLED
-            case XML_DOCB_DOCUMENT_NODE:
-#endif
 	        cur = ctxt->node;
 		break;
             case XML_ATTRIBUTE_NODE:
@@ -13893,7 +13858,7 @@
 			 xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
 	if (ctxt->valueTab == NULL) {
 	    xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
-	    xmlFree(ctxt);
+	    return(-1);
 	}
 	ctxt->valueNr = 0;
 	ctxt->valueMax = 10;
diff --git a/win32/config.h b/win32/config.h
index d804404..4f99ae0 100644
--- a/win32/config.h
+++ b/win32/config.h
@@ -7,104 +7,14 @@
 #define HAVE_SYS_STAT_H
 #define HAVE_STAT
 #define HAVE_FCNTL_H
-#include <io.h>
-#include <direct.h>
 
-#include <libxml/xmlversion.h>
-
-#ifndef ICONV_CONST
-#define ICONV_CONST const
+#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
+#define HAVE_STDINT_H
 #endif
 
-/*
- * Windows platforms may define except 
- */
-#undef except
-
-#define HAVE_ISINF
-#define HAVE_ISNAN
-#include <math.h>
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-/* MS C-runtime has functions which can be used in order to determine if
-   a given floating-point variable contains NaN, (+-)INF. These are 
-   preferred, because floating-point technology is considered proprietary
-   by MS and we can assume that their functions know more about their 
-   oddities than we do. */
-#include <float.h>
-/* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass
-   function. */
-#ifndef isinf
-#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
-	: ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
-#endif
-/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
-#ifndef isnan
-#define isnan(d) (_isnan(d))
-#endif
-#else /* _MSC_VER */
-#ifndef isinf
-static int isinf (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 1;
-        } else if (val == -0.5) {
-            return -1;
-        } else {
-            return 0;
-        }
-    } else {
-        return 0;
-    }
-}
-#endif
-#ifndef isnan
-static int isnan (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 0;
-        } else if (val == -0.5) {
-            return 0;
-        } else {
-            return 1;
-        }
-    } else {
-        return 0;
-    }
-}
-#endif
-#endif /* _MSC_VER */
-
-#if defined(_MSC_VER)
-#define mkdir(p,m) _mkdir(p)
-#if _MSC_VER < 1900
+#if defined(_MSC_VER) && _MSC_VER < 1900
 #define snprintf _snprintf
-#endif
-#if _MSC_VER < 1500
-#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
-#endif
-#elif defined(__MINGW32__)
-#define mkdir(p,m) _mkdir(p)
-#endif
-
-/* Threading API to use should be specified here for compatibility reasons.
-   This is however best specified on the compiler's command-line. */
-#if defined(LIBXML_THREAD_ENABLED)
-#if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE)
-#define HAVE_WIN32_THREADS
-#endif
-#endif
-
-/* Some third-party libraries far from our control assume the following
-   is defined, which it is not if we don't include windows.h. */
-#if !defined(FALSE)
-#define FALSE 0
-#endif
-#if !defined(TRUE)
-#define TRUE (!(FALSE))
+#define vsnprintf _vsnprintf
 #endif
 
 #endif /* __LIBXML_WIN32_CONFIG__ */
diff --git a/win32/include/libxml/xmlversion.h b/win32/include/libxml/xmlversion.h
index 72883c8..5eef779 100644
--- a/win32/include/libxml/xmlversion.h
+++ b/win32/include/libxml/xmlversion.h
@@ -230,15 +230,6 @@
 #endif
 
 /**
- * LIBXML_DOCB_ENABLED:
- *
- * Whether the SGML Docbook support is configured in
- */
-#if 0
-#define LIBXML_DOCB_ENABLED
-#endif
-
-/**
  * LIBXML_XPATH_ENABLED:
  *
  * Whether XPath is configured in