RESTRICT AUTOMERGE: Update libxml2 to 2.9.8

Merge to pi-dev, restore Android.mk and revert 440b0b3d89db029dc2b8c86130461d292a8e11dc

Bug: 79662501
Bug: 36809766
Bug: 36810305
Bug: 62151041

Test: manually verify functionality for regression

Change-Id: Ib8859fc31de847c252a8705437fa67476ba6f5ad
(cherry picked from commit f921fa5d53b3ab966ba41c298ccd6b3d88574451)
diff --git a/.gitignore b/.gitignore
index 84cf80f..680a7e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.exe
 *.o
 *.lo
 *.log
@@ -76,6 +77,7 @@
 python/libxml2class.py
 python/libxml2class.txt
 python/libxml2mod.la
+python/setup.py
 python/tests/Makefile
 python/tests/Makefile.in
 python/tests/tmp.xml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6720289
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,22 @@
+language: c
+sudo: false
+addons:
+  apt:
+    packages:
+      # Some tests require the DTDs.
+      w3c-sgml-lib
+matrix:
+  include:
+    # Try to emulate a C89 compiler on a POSIX system by disabling as many
+    # GNU extensions as possible.
+    - compiler: gcc
+      env: CFLAGS="-O2 -std=c89 -D_POSIX_C_SOURCE=200809L"
+    # clang with AddressSanitizer and UndefinedBehaviorSanitizer.
+    - compiler: clang
+      dist: trusty
+      env: CONFIG="--without-python"
+           CFLAGS="-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all"
+           UBSAN_OPTIONS=print_stacktrace=1
+script: sh autogen.sh $CONFIG && make -j2 V=1 && make check
+git:
+  depth: 10
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..260edf1
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,119 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// To update:
+//
+
+//  git merge aosp/upstream-master
+//  mma -j
+//  # (Make any necessary Android.bp changes and test the new libxml2.)
+//  git push aosp HEAD:master  # Push directly, avoiding gerrit.
+//  git push aosp HEAD:refs/for/master  # Push to gerrit.
+//
+//  # Now commit any necessary Android.bp changes like normal:
+//  repo start post-sync .
+//  git commit -a
+//
+
+// This comes from the automake-generated Makefile.
+// We deliberately exclude nanoftp.c and nanohttp.c, the trio library, and zlib.
+cc_library {
+    name: "libxml2",
+    vendor_available: true,
+    vndk: {
+        enabled: true,
+    },
+    host_supported: true,
+    srcs: [
+        "SAX.c",
+        "entities.c",
+        "encoding.c",
+        "error.c",
+        "parserInternals.c",
+        "parser.c",
+        "tree.c",
+        "hash.c",
+        "list.c",
+        "xmlIO.c",
+        "xmlmemory.c",
+        "uri.c",
+        "valid.c",
+        "xlink.c",
+        "debugXML.c",
+        "xpath.c",
+        "xpointer.c",
+        "xinclude.c",
+        "DOCBparser.c",
+        "catalog.c",
+        "globals.c",
+        "threads.c",
+        "c14n.c",
+        "xmlstring.c",
+        "buf.c",
+        "xmlregexp.c",
+        "xmlschemas.c",
+        "xmlschemastypes.c",
+        "xmlunicode.c",
+        "xmlreader.c",
+        "relaxng.c",
+        "dict.c",
+        "SAX2.c",
+        "xmlwriter.c",
+        "legacy.c",
+        "chvalid.c",
+        "pattern.c",
+        "xmlsave.c",
+        "xmlmodule.c",
+        "schematron.c",
+    ],
+    export_include_dirs: ["include"],
+    cflags: [
+        "-DLIBXML_THREAD_ENABLED=1",
+
+        "-Wall",
+        "-Werror",
+        "-Wno-error=ignored-attributes",
+        "-Wno-missing-field-initializers",
+        "-Wno-self-assign",
+        "-Wno-sign-compare",
+        "-Wno-tautological-pointer-compare",
+        "-Wno-unused-function",
+        "-Wno-unused-parameter",
+    ],
+    static: {
+        cflags: ["-fvisibility=hidden"],
+    },
+    target: {
+        vendor: {
+            exclude_shared_libs: ["libicuuc"],
+        },
+    },
+    shared_libs: ["libicuuc"],
+    export_shared_lib_headers: ["libicuuc"],
+}
+
+cc_binary_host {
+    name: "xmllint",
+    srcs: ["xmllint.c"],
+    cflags: [
+        "-DLIBXML_THREAD_ENABLED=1",
+
+        "-Wall",
+        "-Werror",
+    ],
+    shared_libs: ["libxml2"],
+}
diff --git a/ChangeLog b/ChangeLog
index ef6cb8e..896fbbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1929,7 +1929,7 @@
 
 	* tree.c: Fixed xmlGetNodePath() to generate the node test "*"
 	  for elements in the default namespace, rather than generating
-	  an unprefixed named node test and loosing the namespace
+	  an unprefixed named node test and losing the namespace
 	  information.
 
 Fri Jun  9 21:45:02 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
@@ -2305,7 +2305,7 @@
 	* tree.c: Simplified usage of the internal xmlNsMap. Added a
 	  "strict" lookup for namespaces based on a prefix. Fixed a
 	  namespace processing issue in the clone-node function, which
-	  occured if a @ctxt argument was given.
+	  occurred if a @ctxt argument was given.
 	  
 Fri Mar  3 17:44:10 CET 2006 Rob Richards <rrichards@ctindustries.net>
 
@@ -3951,7 +3951,7 @@
 	* README: updated 
 	* debugXML.c: fix a bug raised by bill on IRC
 	* relaxng.c: fix a leak in weird circumstances
-	* runsuite.c Makefile.am: standalone test tool agaisnt
+	* runsuite.c Makefile.am: standalone test tool against
 	  the regression suites, work in progress
 
 Tue Jun 28 08:30:26 CEST 2005 Daniel Veillard <daniel@veillard.com>
@@ -4356,7 +4356,7 @@
 	* xmlschemas.c: Added substitution group constraints; changed
 	  the build of the pre-computed substitution groups. Channeled
 	  errors during xsi assembling of schemas to the validation
-	  context. Fixed a big memory leak, which occured when using
+	  context. Fixed a big memory leak, which occurred when using
 	  IDCs: the precomputed value of attributes was not freed if
 	  the attribute did not resolve to an IDC field (discovered
 	  with the help of Randy J. Ray's schema, posted to the
@@ -4551,7 +4551,7 @@
 
 Mon Mar 21 21:09:07 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
 
-	* xmlschemas.c: Fixed a segfault, which occured during bubbling
+	* xmlschemas.c: Fixed a segfault, which occurred during bubbling
 	  of IDC nodes (bug #170779 and #170778, reported by GUY Fabrice):
 	  a variable was missed to be reset in a loop. Deactivated bubbling,
 	  if not referenced by a keyref.
@@ -11220,7 +11220,7 @@
 	* test/xsdtest/xsdtest.xml uri.c: after and exchange with James
 	  Clark it appeared I had bug in URI parsing code ...
 	* relaxng.c include/libxml/relaxng.h: completely revamped error
-	  reporting to not loose message from optional parts.
+	  reporting to not lose message from optional parts.
 	* xmllint.c: added timing for RNG validation steps
 	* result/relaxng/*: updated the result, all error messages changed
 
@@ -13182,7 +13182,7 @@
 	  xmlNewCharEncodingHandler as requested in #89415
 	* python/generator.py python/setup.py.in: applied cleanup
 	  patches from Marc-Andre Lemburg
-	* tree.c: fixing bug #89332 on a specific case of loosing 
+	* tree.c: fixing bug #89332 on a specific case of losing 
 	  the XML-1.0 namespace on xml:xxx attributes
 
 Wed Jul 31 23:27:42 2002  Aleksey Sanin  <aleksey@aleksey.com>
@@ -15356,7 +15356,7 @@
 
 Sat Oct  6 15:07:14 CEST 2001 Daniel Veillard <daniel@veillard.com>
 
-	* xpath.c: fixing #61673 part I, do not loose doc information
+	* xpath.c: fixing #61673 part I, do not lose doc information
 	  when copying result value trees.
 
 Sat Oct  6 11:58:58 CEST 2001 Daniel Veillard <daniel@veillard.com>
@@ -15970,7 +15970,7 @@
 Mon Jul  9 22:06:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* valid.c: fixed "Internal: MIXED struct bad" when #CDATA elements
-	  validation occured on content with element child
+	  validation occurred on content with element child
 
 Mon Jul  9 17:59:08 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
diff --git a/Makefile.am b/Makefile.am
index 9f988b0..15f78e1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,10 +10,10 @@
 
 AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
 
-noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \
-                testThreads testC14N testAutomata testRegexp \
-                testReader testapi testModule runtest runsuite testchar \
-		testdict runxmlconf testrecurse testlimits
+check_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \
+               testThreads testC14N testAutomata testRegexp \
+               testReader testapi testModule runtest runsuite testchar \
+	       testdict runxmlconf testrecurse testlimits
 
 bin_PROGRAMS = xmllint xmlcatalog
 
@@ -191,6 +191,7 @@
 testapi_LDFLAGS = 
 testapi_DEPENDENCIES = $(DEPS)
 testapi_LDADD= $(LDADDS)
+testapi_CFLAGS = -Wno-unused-function
 
 runxmlconf_SOURCES=runxmlconf.c
 runxmlconf_LDFLAGS = 
@@ -202,10 +203,16 @@
 #testOOM_DEPENDENCIES = $(DEPS)
 #testOOM_LDADD= $(LDADDS)
 
-runtests:
+runtests: runtest$(EXEEXT) testrecurse$(EXEEXT) testapi$(EXEEXT) \
+          testchar$(EXEEXT) testdict$(EXEEXT) runxmlconf$(EXEEXT)
 	[ -d test   ] || $(LN_S) $(srcdir)/test   .
 	[ -d result ] || $(LN_S) $(srcdir)/result .
-	$(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
+	$(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)
 
@@ -224,12 +231,12 @@
 
 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) tests ; fi)
-	@(cd doc/examples ; $(MAKE) tests)
+	    $(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"
-	-@($(CHECKER) $(top_builddir)/testapi -q)
+	-@(ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) $(top_builddir)/testapi -q)
 
 HTMLtests : testHTML$(EXEEXT)
 	@(echo > .memdump)
@@ -247,7 +254,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name result2.$$name error.$$name ; \
 	  fi ; fi ; done)
 
@@ -268,7 +275,7 @@
 	      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 ; \
+	      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"
@@ -282,7 +289,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name.sax ; \
 	  fi ; fi ; done)
 	@echo "## Push HTML SAX regression tests"
@@ -296,7 +303,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name.sax ; \
 	  fi ; fi ; done)
 
@@ -317,7 +324,7 @@
 	      $(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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
 	@echo "## XML regression tests on memory"
@@ -334,7 +341,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      diff result.$$name result2.$$name ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
@@ -356,7 +363,7 @@
 	      $(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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
 
@@ -377,7 +384,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
 
@@ -398,7 +405,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
 
@@ -419,7 +426,25 @@
 	      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 ; \
+	      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"
@@ -436,7 +461,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm error.$$name ; \
 	  fi ; fi ; done)
 
@@ -459,7 +484,7 @@
 	      $(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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
 
@@ -477,7 +502,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	-@(for i in $(srcdir)/test/URI/*.uri ; do \
@@ -491,7 +516,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 
@@ -505,13 +530,13 @@
 	  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 ; \
+	      $(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 2>&1 > result.$$name ; \
+	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done ; \
 	  for i in $(srcdir)/test/XPath/docs/* ; do \
@@ -526,10 +551,10 @@
 	      $(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 2>&1 > result.$$name ; \
+	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done ; fi ; done)
 
@@ -547,13 +572,13 @@
 	  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 ; \
+	      $(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 2>&1 > result.$$name ; \
+	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done ; fi ; done)
 
@@ -572,7 +597,7 @@
 	      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 ; \
+	      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 \
@@ -587,7 +612,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
 	@(echo > .memdump)
@@ -604,7 +629,7 @@
 	      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 ; \
+	      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 \
@@ -619,7 +644,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
 
@@ -640,7 +665,7 @@
 	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	      diff $(srcdir)/result/scripts/$$name result.$$name ; \
 	      diff $(srcdir)/result/scripts/$$name.err result.$$name.err` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name result.$$name.err ; \
 	  fi ; fi ; done)
 
@@ -659,7 +684,7 @@
 	      log=`$(CHECKER) $(top_builddir)/xmlcatalog --shell $$xml < $$i 2>&1 > result.$$name ; \
 	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	      diff $(srcdir)/result/catalogs/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	-@(for i in $(srcdir)/test/catalogs/*.script ; do \
@@ -674,7 +699,7 @@
 	      log=`$(CHECKER) $(top_builddir)/xmlcatalog --shell $$sgml < $$i > result.$$name ; \
 	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	      diff $(srcdir)/result/catalogs/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## Add and del operations on XML Catalogs"
@@ -738,7 +763,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## Reader on memory regression tests"
@@ -753,7 +778,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@(echo > .memdump)
@@ -769,7 +794,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## Reader entities substitution regression tests"
@@ -784,7 +809,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 
@@ -802,7 +827,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## SAX2 callbacks regression tests"
@@ -817,7 +842,22 @@
 	      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 ; \
+	      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)
 
@@ -829,7 +869,7 @@
 	  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 ; \
+	      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 \
@@ -843,7 +883,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## General documents valid regression tests"
@@ -859,7 +899,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
 
@@ -877,7 +917,7 @@
 	      log=`$(CHECKER) $(top_builddir)/testRegexp -i $$i 2>&1 > result.$$name ; \
 	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	      diff $(srcdir)/result/regexp/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 	@echo "## Formal expresssions regression tests"
@@ -892,7 +932,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 
@@ -910,7 +950,7 @@
 	      log=`$(CHECKER) $(top_builddir)/testAutomata $$i 2>&1 > result.$$name ; \
 	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
 	      diff $(srcdir)/result/automata/$$name result.$$name` ; \
-	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
 
@@ -961,7 +1001,7 @@
 			    cmdline="$$cmdline '`cat $(srcdir)/test/c14n/$$m/$$name.ns`'"; \
 			fi; \
 		    fi; \
-		    $$cmdline > $(srcdir)/test/c14n/test.tmp; \
+		    $$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 \
@@ -1002,7 +1042,7 @@
 	          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 ; \
+	          if [ -n "$$log" ] ; then echo "$$name"_"$$sno"_"$$xno" result ; echo "$$log" ; fi ; \
 	          rm res.$$name err.$$name ; \
 	       fi ; fi ;\
 	  done; done)
@@ -1027,7 +1067,7 @@
 	      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 ; \
+	      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 \
@@ -1049,7 +1089,7 @@
 	          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 ; \
+		  if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
 	          rm res.$$name err.$$name ; \
 	       fi ; fi ; \
 	  done; done)
@@ -1075,7 +1115,7 @@
 		      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 ; \
+	          if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
 	          rm res.$$name err.$$name ; \
 	       fi ; fi ; \
 	  done; done)
@@ -1104,7 +1144,7 @@
 	          diff $(srcdir)/result/schematron/"$$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 ; \
+		  if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
 	          rm res.$$name err.$$name ; \
 	       fi ; fi ; \
 	  done; done)
@@ -1153,7 +1193,7 @@
 	      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 ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done ;)
 
@@ -1217,6 +1257,7 @@
 	     enc.h save.h testThreadsWin32.c genUnicode.py TODO_SCHEMAS \
 	     dbgen.pl dbgenattr.pl regressions.py regressions.xml \
 	     README.tests Makefile.tests libxml2.syms timsort.h \
+	     README.zOS \
 	     $(CVS_EXTRA_DIST)
 
 
diff --git a/README.zOS b/README.zOS
new file mode 100644
index 0000000..6b6669a
--- /dev/null
+++ b/README.zOS
@@ -0,0 +1,212 @@
+Notes for compiling on zOS:
+
+- since testapi.c file is huge (over 52000 lines), it's compilation
+  fails: I skipped the problem by removing all references to testapi in the
+  Makefile.in, but it would be neater if one can build without test files
+  (I didn't find an option in configure...)
+
+- since the name of files (or qualifier) in PDS are limited to 8 I had to
+  rename xmlschemas.c and xmlschemastypes.c in (resp.) xmlsche.c xmlschet.c
+  (and I had to modify all occurences of these files accordingly in the
+  rest of the Makefile !!!).
+
+- in order to copy objects to PDS, I had the cp command at line 860
+  of Makefile.in
+
+libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES)
+        $(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
+        # Copy objects to PDS
+        @list='$(libxml2_OBJECTS)' ; for p in $$list; do \
+          cp -ACMv $$p "//'<PDS NAME>'"; \
+        done
+
+	with <PDS NAME> stands for the name of my PDS and
+	
+libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
+	parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
+	xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
+	HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
+	nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
+	threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
+	xmlsche.o xmlschet.o xmlunicode.o \
+	xmlreader.o relaxng.o dict.o SAX2.o \
+	xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
+	xmlmodule.o schematron.o xzlib.o 
+
+In order to handle the support of zOS without breaking the existing
+Makefile maybe a new option/flag zOs would copy xmlschemas.c and
+xmlschemastypes.c files and use specifics targets rather than existing
+ones with the longer names... A variable to handle the PDS name has to
+be provided also...
+
+See patch below for set of changes to Makefile.in
+
+Stéphane Michaut <smichaut@axway.com>
+July 2017
+
+
+--- Makefile.in	2017-08-01 08:17:15.000000000 +0200
++++ Makefile-new.in	2017-08-01 08:07:26.000000000 +0200
+@@ -41,7 +41,7 @@
+ 	testSAX$(EXEEXT) testHTML$(EXEEXT) testXPath$(EXEEXT) \
+ 	testURI$(EXEEXT) testThreads$(EXEEXT) testC14N$(EXEEXT) \
+ 	testAutomata$(EXEEXT) testRegexp$(EXEEXT) testReader$(EXEEXT) \
+-	testapi$(EXEEXT) testModule$(EXEEXT) runtest$(EXEEXT) \
++	testModule$(EXEEXT) runtest$(EXEEXT) \
+ 	runsuite$(EXEEXT) testchar$(EXEEXT) testdict$(EXEEXT) \
+ 	runxmlconf$(EXEEXT) testrecurse$(EXEEXT) testlimits$(EXEEXT)
+ bin_PROGRAMS = xmllint$(EXEEXT) xmlcatalog$(EXEEXT)
+@@ -106,6 +106,7 @@
+ 	debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c \
+ 	DOCBparser.c catalog.c globals.c threads.c c14n.c xmlstring.c \
+ 	buf.c xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
++        xmlsche.c xmlschet.c \
+ 	triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
+ 	xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c xmlmodule.c \
+ 	schematron.c xzlib.c
+@@ -118,10 +119,24 @@
+ 	nanohttp.lo nanoftp.lo $(am__objects_1) catalog.lo globals.lo \
+ 	threads.lo c14n.lo xmlstring.lo buf.lo xmlregexp.lo \
+ 	xmlschemas.lo xmlschemastypes.lo xmlunicode.lo \
++        xmlsche.lo xmlschet.lo \
+ 	$(am__objects_2) xmlreader.lo relaxng.lo dict.lo SAX2.lo \
+ 	xmlwriter.lo legacy.lo chvalid.lo pattern.lo xmlsave.lo \
+ 	xmlmodule.lo schematron.lo xzlib.lo
+ libxml2_la_OBJECTS = $(am_libxml2_la_OBJECTS)
++
++libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
++	parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
++	xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
++	HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
++	nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
++	threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
++	xmlschemas.o xmlschemastypes.o xmlunicode.o \
++	xmlsche.o xmlschemast.o \
++	xmlreader.o relaxng.o dict.o SAX2.o \
++	xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
++	xmlmodule.o schematron.o xzlib.o
++
+ AM_V_lt = $(am__v_lt_$(V))
+ am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+ am__v_lt_0 = --silent
+@@ -216,11 +231,6 @@
+ testXPath_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ 	$(testXPath_LDFLAGS) $(LDFLAGS) -o $@
+-am_testapi_OBJECTS = testapi.$(OBJEXT)
+-testapi_OBJECTS = $(am_testapi_OBJECTS)
+-testapi_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+-	$(testapi_LDFLAGS) $(LDFLAGS) -o $@
+ am_testchar_OBJECTS = testchar.$(OBJEXT)
+ testchar_OBJECTS = $(am_testchar_OBJECTS)
+ testchar_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+@@ -285,7 +295,7 @@
+ 	$(testReader_SOURCES) $(testRegexp_SOURCES) \
+ 	$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
+ 	$(testThreads_SOURCES) $(testURI_SOURCES) $(testXPath_SOURCES) \
+-	$(testapi_SOURCES) $(testchar_SOURCES) $(testdict_SOURCES) \
++	$(testchar_SOURCES) $(testdict_SOURCES) \
+ 	$(testlimits_SOURCES) $(testrecurse_SOURCES) \
+ 	$(xmlcatalog_SOURCES) $(xmllint_SOURCES)
+ DIST_SOURCES = $(am__libxml2_la_SOURCES_DIST) $(testdso_la_SOURCES) \
+@@ -295,7 +305,7 @@
+ 	$(testReader_SOURCES) $(testRegexp_SOURCES) \
+ 	$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
+ 	$(am__testThreads_SOURCES_DIST) $(testURI_SOURCES) \
+-	$(testXPath_SOURCES) $(testapi_SOURCES) $(testchar_SOURCES) \
++	$(testXPath_SOURCES) $(testchar_SOURCES) \
+ 	$(testdict_SOURCES) $(testlimits_SOURCES) \
+ 	$(testrecurse_SOURCES) $(xmlcatalog_SOURCES) \
+ 	$(xmllint_SOURCES)
+@@ -700,11 +710,6 @@
+ noinst_LTLIBRARIES = testdso.la
+ testdso_la_SOURCES = testdso.c
+ testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir)
+-BUILT_SOURCES = testapi.c
+-testapi_SOURCES = testapi.c
+-testapi_LDFLAGS = 
+-testapi_DEPENDENCIES = $(DEPS)
+-testapi_LDADD = $(LDADDS)
+ runxmlconf_SOURCES = runxmlconf.c
+ runxmlconf_LDFLAGS = 
+ runxmlconf_DEPENDENCIES = $(DEPS)
+@@ -854,6 +859,12 @@
+ 	done
+ libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES) 
+ 	$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
++        # Copie des obj
++	@list='$(libxml2_OBJECTS)' ; for p in $$list; do \
++	  echo "copy to PDS: $$p"; \
++	  cp -ACMv $$p "//'A009153.XRDEV230.FIC.OBJLIB.LIBXML'"; \
++	done 
++
+ testdso.la: $(testdso_la_OBJECTS) $(testdso_la_DEPENDENCIES) 
+ 	$(AM_V_CCLD)$(testdso_la_LINK)  $(testdso_la_OBJECTS) $(testdso_la_LIBADD) $(LIBS)
+ install-binPROGRAMS: $(bin_PROGRAMS)
+@@ -953,9 +964,6 @@
+ testXPath$(EXEEXT): $(testXPath_OBJECTS) $(testXPath_DEPENDENCIES) 
+ 	@rm -f testXPath$(EXEEXT)
+ 	$(AM_V_CCLD)$(testXPath_LINK) $(testXPath_OBJECTS) $(testXPath_LDADD) $(LIBS)
+-testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES) 
+-	@rm -f testapi$(EXEEXT)
+-	$(AM_V_CCLD)$(testapi_LINK) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS)
+ testchar$(EXEEXT): $(testchar_OBJECTS) $(testchar_DEPENDENCIES) 
+ 	@rm -f testchar$(EXEEXT)
+ 	$(AM_V_CCLD)$(testchar_LINK) $(testchar_OBJECTS) $(testchar_LDADD) $(LIBS)
+@@ -1056,7 +1064,6 @@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testThreadsWin32.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testURI.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testXPath.Po@am__quote@
+-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testchar.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdict.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdso.Plo@am__quote@
+@@ -1755,18 +1762,6 @@
+ 	uninstall-local uninstall-m4dataDATA uninstall-man \
+ 	uninstall-man1 uninstall-man3 uninstall-pkgconfigDATA
+ 
+-
+-# that one forces the rebuild when "make rebuild" is run on doc/
+-rebuild_testapi:
+-	-@(if [ "$(PYTHON)" != "" ] ; then \
+-	    $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
+-
+-# that one is just to make sure it is rebuilt if missing
+-# but adding the dependances generate mess
+-testapi.c: $(srcdir)/gentest.py
+-	-@(if [ "$(PYTHON)" != "" ] ; then \
+-	    $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
+-
+ #testOOM_SOURCES=testOOM.c testOOMlib.h testOOMlib.c
+ #testOOM_LDFLAGS = 
+ #testOOM_DEPENDENCIES = $(DEPS)
+@@ -1775,7 +1770,7 @@
+ runtests:
+ 	[ -d test   ] || $(LN_S) $(srcdir)/test   .
+ 	[ -d result ] || $(LN_S) $(srcdir)/result .
+-	$(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
++	$(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
+ 	@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
+ 	    $(MAKE) tests ; fi)
+ 
+@@ -1797,10 +1792,6 @@
+ 	    $(MAKE) tests ; fi)
+ 	@(cd doc/examples ; $(MAKE) tests)
+ 
+-APItests: testapi$(EXEEXT)
+-	@echo "## Running the API regression tests this may take a little while"
+-	-@($(CHECKER) $(top_builddir)/testapi -q)
+-
+ HTMLtests : testHTML$(EXEEXT)
+ 	@(echo > .memdump)
+ 	@echo "## HTML regression tests"
+@@ -2746,7 +2737,7 @@
+ dist-test: distdir
+ 	(mkdir -p $(distdir))
+ 	(cd $(srcdir) ; tar -cf - --exclude CVS --exclude .svn --exclude .git xstc/Tests) | (cd $(distdir); tar xf -)
+-	tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests  $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/testapi.c $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
++	tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests  $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
+ 	@(rm -rf $(distdir)/xstc/Test)
+ 
+ cleantar:
diff --git a/SAX2.c b/SAX2.c
index 5cbb700..0f261b7 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <stddef.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
@@ -1181,6 +1182,8 @@
 	        xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
 		if (name != NULL)
 		    xmlFree(name);
+                if (nval != NULL)
+                    xmlFree(nval);
 		return;
 	    }
 	} else {
@@ -1242,6 +1245,8 @@
 	        xmlFree(ns);
 		if (name != NULL)
 		    xmlFree(name);
+                if (nval != NULL)
+                    xmlFree(nval);
 		return;
 	    }
 	} else {
@@ -1311,6 +1316,8 @@
                                              name, namespace->href);
                         ctxt->wellFormed = 0;
                         if (ctxt->recovery == 0) ctxt->disableSAX = 1;
+                        if (name != NULL)
+                            xmlFree(name);
                         goto error;
                     }
                 }
@@ -1908,7 +1915,7 @@
 	    else {
 	        ret->line = 65535;
 		if (ctxt->options & XML_PARSE_BIG_LINES)
-		    ret->psvi = (void *) (long) ctxt->input->line;
+		    ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
 	    }
 	}
     }
@@ -2311,7 +2318,7 @@
 	} else {
             /*
              * any out of memory error would already have been raised
-             * but we can't be garanteed it's the actual error due to the
+             * but we can't be guaranteed it's the actual error due to the
              * API, best is to skip in this case
              */
 	    continue;
@@ -2805,7 +2812,8 @@
 	xmlTextConcat(lastChild, value, len);
     } else {
 	ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
-	xmlAddChild(ctxt->node, ret);
+	if (xmlAddChild(ctxt->node, ret) == NULL)
+		xmlFreeNode(ret);
     }
 }
 
diff --git a/buf.c b/buf.c
index 07922ff..21cb9d8 100644
--- a/buf.c
+++ b/buf.c
@@ -49,7 +49,7 @@
     size_t use;		        /* The buffer size used */
     size_t size;		/* The buffer size */
     xmlBufferPtr buffer;        /* wrapper for an old buffer */
-    int error;                  /* an error code if a failure occured */
+    int error;                  /* an error code if a failure occurred */
 };
 
 #ifdef WITH_BUFFER_COMPAT
@@ -231,7 +231,7 @@
 xmlBufCreateStatic(void *mem, size_t size) {
     xmlBufPtr ret;
 
-    if ((mem == NULL) || (size == 0))
+    if (mem == NULL)
         return(NULL);
 
     ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
@@ -701,7 +701,7 @@
  * used in the buffer. It does not account for the terminating zero
  * usually needed
  *
- * Returns the amount or 0 if none or an error occured
+ * Returns the amount or 0 if none or an error occurred
  */
 
 size_t
diff --git a/c14n.c b/c14n.c
index ca77f92..a0f2c19 100644
--- a/c14n.c
+++ b/c14n.c
@@ -89,7 +89,7 @@
 								 xmlNsPtr ns,
 								 xmlC14NCtxPtr ctx);
 
-static int			xmlC14NIsNodeInNodeset		(xmlNodeSetPtr nodes,
+static int			xmlC14NIsNodeInNodeset		(void *user_data,
 								 xmlNodePtr node,
 								 xmlNodePtr parent);
 
@@ -252,7 +252,8 @@
 #define XML_NAMESPACES_DEFAULT		16
 
 static int
-xmlC14NIsNodeInNodeset(xmlNodeSetPtr nodes, xmlNodePtr node, xmlNodePtr parent) {
+xmlC14NIsNodeInNodeset(void *user_data, xmlNodePtr node, xmlNodePtr parent) {
+    xmlNodeSetPtr nodes = (xmlNodeSetPtr) user_data;
     if((nodes != NULL) && (node != NULL)) {
 	if(node->type != XML_NAMESPACE_DECL) {
 	    return(xmlXPathNodeSetContains(nodes, node));
@@ -513,8 +514,10 @@
  * Returns -1 if ns1 < ns2, 0 if ns1 == ns2 or 1 if ns1 > ns2.
  */
 static int
-xmlC14NNsCompare(xmlNsPtr ns1, xmlNsPtr ns2)
+xmlC14NNsCompare(const void *data1, const void *data2)
 {
+    const xmlNsPtr ns1 = (const xmlNsPtr) data1;
+    const xmlNsPtr ns2 = (const xmlNsPtr) data2;
     if (ns1 == ns2)
         return (0);
     if (ns1 == NULL)
@@ -559,6 +562,11 @@
     return (1);
 }
 
+static int
+xmlC14NPrintNamespacesWalker(const void *ns, void *ctx) {
+    return xmlC14NPrintNamespaces((const xmlNsPtr) ns, (xmlC14NCtxPtr) ctx);
+}
+
 /**
  * xmlC14NProcessNamespacesAxis:
  * @ctx:		the C14N context
@@ -615,7 +623,7 @@
     /*
      * Create a sorted list to store element namespaces
      */
-    list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
+    list = xmlListCreate(NULL, xmlC14NNsCompare);
     if (list == NULL) {
         xmlC14NErrInternal("creating namespaces list (c14n)");
         return (-1);
@@ -663,7 +671,7 @@
     /*
      * print out all elements from list
      */
-    xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
+    xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
 
     /*
      * Cleanup
@@ -728,7 +736,7 @@
     /*
      * Create a sorted list to store element namespaces
      */
-    list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
+    list = xmlListCreate(NULL, xmlC14NNsCompare);
     if (list == NULL) {
         xmlC14NErrInternal("creating namespaces list (exc c14n)");
         return (-1);
@@ -840,7 +848,7 @@
     /*
      * print out all elements from list
      */
-    xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
+    xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
 
     /*
      * Cleanup
@@ -879,8 +887,10 @@
  * Returns -1 if attr1 < attr2, 0 if attr1 == attr2 or 1 if attr1 > attr2.
  */
 static int
-xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
+xmlC14NAttrsCompare(const void *data1, const void *data2)
 {
+    const xmlAttrPtr attr1 = (const xmlAttrPtr) data1;
+    const xmlAttrPtr attr2 = (const xmlAttrPtr) data2;
     int ret = 0;
 
     /*
@@ -931,8 +941,10 @@
  * Returns 1 on success or 0 on fail.
  */
 static int
-xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
+xmlC14NPrintAttrs(const void *data, void *user)
 {
+    const xmlAttrPtr attr = (const xmlAttrPtr) data;
+    xmlC14NCtxPtr ctx = (xmlC14NCtxPtr) user;
     xmlChar *value;
     xmlChar *buffer;
 
@@ -1142,7 +1154,7 @@
     /*
      * Create a sorted list to store element attributes
      */
-    list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NAttrsCompare);
+    list = xmlListCreate(NULL, xmlC14NAttrsCompare);
     if (list == NULL) {
         xmlC14NErrInternal("creating attributes list");
         return (-1);
@@ -1331,7 +1343,7 @@
     /*
      * print out all elements from list
      */
-    xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx);
+    xmlListWalk(list, xmlC14NPrintAttrs, (void *) ctx);
 
     /*
      * Cleanup
@@ -1375,13 +1387,6 @@
                 xmlFreeURI(uri);
                 return (-1);
             }
-            if ((xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "urn") != 0)
-                && (xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "dav") !=0)
-                && (xmlStrlen((const xmlChar *) uri->server) == 0)) {
-                xmlC14NErrRelativeNamespace(uri->scheme);
-                xmlFreeURI(uri);
-                return (-1);
-            }
             xmlFreeURI(uri);
         }
         ns = ns->next;
@@ -1971,7 +1976,7 @@
                  int mode, xmlChar ** inclusive_ns_prefixes,
                  int with_comments, xmlOutputBufferPtr buf) {
     return(xmlC14NExecute(doc,
-			(xmlC14NIsVisibleCallback)xmlC14NIsNodeInNodeset,
+			xmlC14NIsNodeInNodeset,
 			nodes,
 			mode,
 			inclusive_ns_prefixes,
diff --git a/catalog.c b/catalog.c
index 6dfdfbb..f814121 100644
--- a/catalog.c
+++ b/catalog.c
@@ -319,12 +319,13 @@
 
 /**
  * xmlFreeCatalogEntry:
- * @ret:  a Catalog entry
+ * @payload:  a Catalog entry
  *
  * Free the memory allocated to a Catalog entry
  */
 static void
-xmlFreeCatalogEntry(xmlCatalogEntryPtr ret) {
+xmlFreeCatalogEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlCatalogEntryPtr ret = (xmlCatalogEntryPtr) payload;
     if (ret == NULL)
 	return;
     /*
@@ -367,20 +368,22 @@
 
     while (ret != NULL) {
 	next = ret->next;
-	xmlFreeCatalogEntry(ret);
+	xmlFreeCatalogEntry(ret, NULL);
 	ret = next;
     }
 }
 
 /**
  * xmlFreeCatalogHashEntryList:
- * @ret:  a Catalog entry list
+ * @payload:  a Catalog entry list
  *
  * Free the memory allocated to list of Catalog entries from the
  * catalog file hash.
  */
 static void
-xmlFreeCatalogHashEntryList(xmlCatalogEntryPtr catal) {
+xmlFreeCatalogHashEntryList(void *payload,
+                            const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlCatalogEntryPtr catal = (xmlCatalogEntryPtr) payload;
     xmlCatalogEntryPtr children, next;
 
     if (catal == NULL)
@@ -391,11 +394,11 @@
 	next = children->next;
 	children->dealloc = 0;
 	children->children = NULL;
-	xmlFreeCatalogEntry(children);
+	xmlFreeCatalogEntry(children, NULL);
 	children = next;
     }
     catal->dealloc = 0;
-    xmlFreeCatalogEntry(catal);
+    xmlFreeCatalogEntry(catal, NULL);
 }
 
 /**
@@ -440,8 +443,7 @@
     if (catal->xml != NULL)
 	xmlFreeCatalogEntryList(catal->xml);
     if (catal->sgml != NULL)
-	xmlHashFree(catal->sgml,
-		(xmlHashDeallocator) xmlFreeCatalogEntry);
+	xmlHashFree(catal->sgml, xmlFreeCatalogEntry);
     xmlFree(catal);
 }
 
@@ -460,7 +462,10 @@
  * Serialize an SGML Catalog entry
  */
 static void
-xmlCatalogDumpEntry(xmlCatalogEntryPtr entry, FILE *out) {
+xmlCatalogDumpEntry(void *payload, void *data,
+                    const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlCatalogEntryPtr entry = (xmlCatalogEntryPtr) payload;
+    FILE *out = (FILE *) data;
     if ((entry == NULL) || (out == NULL))
 	return;
     switch (entry->type) {
@@ -723,7 +728,10 @@
  * Convert one entry from the catalog
  */
 static void
-xmlCatalogConvertEntry(xmlCatalogEntryPtr entry, xmlCatalogPtr catal) {
+xmlCatalogConvertEntry(void *payload, void *data,
+                       const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlCatalogEntryPtr entry = (xmlCatalogEntryPtr) payload;
+    xmlCatalogPtr catal = (xmlCatalogPtr) data;
     if ((entry == NULL) || (catal == NULL) || (catal->sgml == NULL) ||
 	(catal->xml == NULL))
 	return;
@@ -756,8 +764,7 @@
 	    entry->type = XML_CATA_CATALOG;
 	    break;
 	default:
-	    xmlHashRemoveEntry(catal->sgml, entry->name,
-		               (xmlHashDeallocator) xmlFreeCatalogEntry);
+	    xmlHashRemoveEntry(catal->sgml, entry->name, xmlFreeCatalogEntry);
 	    return;
     }
     /*
@@ -797,9 +804,7 @@
 	xmlGenericError(xmlGenericErrorContext,
 		"Converting SGML catalog to XML\n");
     }
-    xmlHashScan(catal->sgml,
-		(xmlHashScanner) xmlCatalogConvertEntry,
-		&catal);
+    xmlHashScan(catal->sgml, xmlCatalogConvertEntry, &catal);
     return(0);
 }
 
@@ -2396,6 +2401,7 @@
 		case SGML_CATA_ENTITY:
 		    if (*cur == '%')
 			type = SGML_CATA_PENTITY;
+                    /* Falls through. */
 		case SGML_CATA_PENTITY:
 		case SGML_CATA_DOCTYPE:
 		case SGML_CATA_LINKTYPE:
@@ -2485,7 +2491,7 @@
 			                       NULL, XML_CATA_PREFER_NONE, NULL);
 		    res = xmlHashAddEntry(catal->sgml, name, entry);
 		    if (res < 0) {
-			xmlFreeCatalogEntry(entry);
+			xmlFreeCatalogEntry(entry, NULL);
 		    }
 		    xmlFree(filename);
 		}
@@ -2498,7 +2504,7 @@
 			                       XML_CATA_PREFER_NONE, NULL);
 		    res = xmlHashAddEntry(catal->sgml, sysid, entry);
 		    if (res < 0) {
-			xmlFreeCatalogEntry(entry);
+			xmlFreeCatalogEntry(entry, NULL);
 		    }
 		} else {
 		    xmlChar *filename;
@@ -2936,8 +2942,7 @@
     if (catal->type == XML_XML_CATALOG_TYPE) {
 	xmlDumpXMLCatalog(out, catal->xml);
     } else {
-	xmlHashScan(catal->sgml,
-		    (xmlHashScanner) xmlCatalogDumpEntry, out);
+	xmlHashScan(catal->sgml, xmlCatalogDumpEntry, out);
     }
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
@@ -3001,8 +3006,7 @@
     if (catal->type == XML_XML_CATALOG_TYPE) {
 	res = xmlDelXMLCatalog(catal->xml, value);
     } else {
-	res = xmlHashRemoveEntry(catal->sgml, value,
-		(xmlHashDeallocator) xmlFreeCatalogEntry);
+	res = xmlHashRemoveEntry(catal->sgml, value, xmlFreeCatalogEntry);
 	if (res == 0)
 	    res = 1;
     }
@@ -3283,8 +3287,7 @@
 	xmlGenericError(xmlGenericErrorContext,
 		"Catalogs cleanup\n");
     if (xmlCatalogXMLFiles != NULL)
-	xmlHashFree(xmlCatalogXMLFiles,
-		    (xmlHashDeallocator)xmlFreeCatalogHashEntryList);
+	xmlHashFree(xmlCatalogXMLFiles, xmlFreeCatalogHashEntryList);
     xmlCatalogXMLFiles = NULL;
     if (xmlDefaultCatalog != NULL)
 	xmlFreeCatalog(xmlDefaultCatalog);
diff --git a/configure.ac b/configure.ac
index 911984e..8dbc56c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@
 
 LIBXML_MAJOR_VERSION=2
 LIBXML_MINOR_VERSION=9
-LIBXML_MICRO_VERSION=4
+LIBXML_MICRO_VERSION=7
 LIBXML_MICRO_VERSION_SUFFIX=
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@@ -1053,9 +1053,9 @@
 else
     echo Enabling multithreaded support
 
-    dnl Default to native threads on Win32
+    dnl Default to native threads on Windows
     case $host_os in
-       *mingw32*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
+       *mingw*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
                WITH_THREADS="1"
                THREADS_W32="1"
                THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
@@ -1640,7 +1640,6 @@
  CPPFLAGS="$CPPFLAGS -DWIN32"
  WIN32_EXTRA_LIBADD="-lws2_32"
  WIN32_EXTRA_LDFLAGS="-no-undefined"
- AC_DEFINE([_WINSOCKAPI_],1,[Using the Win32 Socket implementation])
  if test "${PYTHON}" != ""
  then
    WIN32_EXTRA_PYTHON_LIBADD="-L${pythondir}/../../libs -lpython$(echo ${PYTHON_VERSION} | tr -d .)"
diff --git a/debugXML.c b/debugXML.c
index a1b550a..c98db0b 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -1229,8 +1229,11 @@
 }
 
 static void
-xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt)
+xmlCtxtDumpEntityCallback(void *payload, void *data,
+                          const xmlChar *name ATTRIBUTE_UNUSED)
 {
+    xmlEntityPtr cur = (xmlEntityPtr) payload;
+    xmlDebugCtxtPtr ctxt = (xmlDebugCtxtPtr) data;
     if (cur == NULL) {
         if (!ctxt->check)
             fprintf(ctxt->output, "Entity is NULL");
@@ -1289,8 +1292,7 @@
 
         if (!ctxt->check)
             fprintf(ctxt->output, "Entities in internal subset\n");
-        xmlHashScan(table, (xmlHashScanner) xmlCtxtDumpEntityCallback,
-                    ctxt);
+        xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
     } else
         fprintf(ctxt->output, "No entities in internal subset\n");
     if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
@@ -1299,8 +1301,7 @@
 
         if (!ctxt->check)
             fprintf(ctxt->output, "Entities in external subset\n");
-        xmlHashScan(table, (xmlHashScanner) xmlCtxtDumpEntityCallback,
-                    ctxt);
+        xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
     } else if (!ctxt->check)
         fprintf(ctxt->output, "No entities in external subset\n");
 }
@@ -2931,7 +2932,7 @@
 		  fprintf(ctxt->output, "\tvalidate     check the document for errors\n");
 #endif /* LIBXML_VALID_ENABLED */
 #ifdef LIBXML_SCHEMAS_ENABLED
-		  fprintf(ctxt->output, "\trelaxng rng  validate the document agaisnt the Relax-NG schemas\n");
+		  fprintf(ctxt->output, "\trelaxng rng  validate the document against the Relax-NG schemas\n");
 #endif
 		  fprintf(ctxt->output, "\tgrep string  search for a string in the subtree\n");
 #ifdef LIBXML_VALID_ENABLED
diff --git a/dict.c b/dict.c
index c0585fe..0ef3718 100644
--- a/dict.c
+++ b/dict.c
@@ -48,7 +48,7 @@
 #else
 #ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
-#elif defined(WIN32)
+#elif defined(_WIN32)
 typedef unsigned __int32 uint32_t;
 #endif
 #endif
@@ -249,7 +249,7 @@
 #endif
     pool = dict->strings;
     while (pool != NULL) {
-	if (pool->end - pool->free > namelen)
+	if ((size_t)(pool->end - pool->free) > namelen)
 	    goto found_pool;
 	if (pool->size > size) size = pool->size;
         limit += pool->size;
@@ -317,7 +317,7 @@
 #endif
     pool = dict->strings;
     while (pool != NULL) {
-	if (pool->end - pool->free > namelen + plen + 1)
+	if ((size_t)(pool->end - pool->free) > namelen + plen + 1)
 	    goto found_pool;
 	if (pool->size > size) size = pool->size;
         limit += pool->size;
@@ -453,14 +453,23 @@
     }
     switch (namelen) {
         case 10: value += name[9];
+        /* Falls through. */
         case 9: value += name[8];
+        /* Falls through. */
         case 8: value += name[7];
+        /* Falls through. */
         case 7: value += name[6];
+        /* Falls through. */
         case 6: value += name[5];
+        /* Falls through. */
         case 5: value += name[4];
+        /* Falls through. */
         case 4: value += name[3];
+        /* Falls through. */
         case 3: value += name[2];
+        /* Falls through. */
         case 2: value += name[1];
+        /* Falls through. */
         default: break;
     }
     return(value);
@@ -496,15 +505,25 @@
     }
     switch (plen) {
         case 10: value += prefix[9];
+        /* Falls through. */
         case 9: value += prefix[8];
+        /* Falls through. */
         case 8: value += prefix[7];
+        /* Falls through. */
         case 7: value += prefix[6];
+        /* Falls through. */
         case 6: value += prefix[5];
+        /* Falls through. */
         case 5: value += prefix[4];
+        /* Falls through. */
         case 4: value += prefix[3];
+        /* Falls through. */
         case 3: value += prefix[2];
+        /* Falls through. */
         case 2: value += prefix[1];
+        /* Falls through. */
         case 1: value += prefix[0];
+        /* Falls through. */
         default: break;
     }
     len -= plen;
@@ -514,15 +533,25 @@
     }
     switch (len) {
         case 10: value += name[9];
+        /* Falls through. */
         case 9: value += name[8];
+        /* Falls through. */
         case 8: value += name[7];
+        /* Falls through. */
         case 7: value += name[6];
+        /* Falls through. */
         case 6: value += name[5];
+        /* Falls through. */
         case 5: value += name[4];
+        /* Falls through. */
         case 4: value += name[3];
+        /* Falls through. */
         case 3: value += name[2];
+        /* Falls through. */
         case 2: value += name[1];
+        /* Falls through. */
         case 1: value += name[0];
+        /* Falls through. */
         default: break;
     }
     return(value);
@@ -533,7 +562,7 @@
  *
  * Create a new dictionary
  *
- * Returns the newly created dictionary, or NULL if an error occured.
+ * Returns the newly created dictionary, or NULL if an error occurred.
  */
 xmlDictPtr
 xmlDictCreate(void) {
@@ -580,7 +609,7 @@
  * new dictionary, then in @sub, and if not found are created in the
  * new dictionary.
  *
- * Returns the newly created dictionary, or NULL if an error occured.
+ * Returns the newly created dictionary, or NULL if an error occurred.
  */
 xmlDictPtr
 xmlDictCreateSub(xmlDictPtr sub) {
@@ -699,7 +728,7 @@
 	    } else {
 	        /*
 		 * we don't have much ways to alert from herei
-		 * result is loosing an entry and unicity garantee
+		 * result is losing an entry and unicity guarantee
 		 */
 	        ret = -1;
 	    }
diff --git a/doc/APIchunk0.html b/doc/APIchunk0.html
index c90e042..75378fc 100644
--- a/doc/APIchunk0.html
+++ b/doc/APIchunk0.html
@@ -104,6 +104,7 @@
 <a href="html/libxml-globals.html#xmlCleanupGlobals">xmlCleanupGlobals</a><br />
 <a href="html/libxml-globals.html#xmlInitGlobals">xmlInitGlobals</a><br />
 </dd><dt>AegeanNumbers</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsAegeanNumbers">xmlUCSIsAegeanNumbers</a><br />
+</dd><dt>Alias</dt><dd><a href="html/libxml-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a><br />
 </dd><dt>All</dt><dd><a href="html/libxml-schemasInternals.html#_xmlSchema">_xmlSchema</a><br />
 <a href="html/libxml-schemasInternals.html#_xmlSchemaType">_xmlSchemaType</a><br />
 <a href="html/libxml-nanoftp.html#xmlNanoFTPGet">xmlNanoFTPGet</a><br />
@@ -242,6 +243,7 @@
 </dd><dt>Bopomofo</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsBopomofo">xmlUCSIsBopomofo</a><br />
 </dd><dt>BopomofoExtended</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsBopomofoExtended">xmlUCSIsBopomofoExtended</a><br />
 </dd><dt>Both</dt><dd><a href="html/libxml-parserInternals.html#XML_SUBSTITUTE_BOTH">XML_SUBSTITUTE_BOTH</a><br />
+<a href="html/libxml-tree.html#xmlSplitQName2">xmlSplitQName2</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPushNode">xmlStreamPushNode</a><br />
diff --git a/doc/APIchunk13.html b/doc/APIchunk13.html
index dba5952..a87a2b4 100644
--- a/doc/APIchunk13.html
+++ b/doc/APIchunk13.html
@@ -517,6 +517,7 @@
 <a href="html/libxml-tree.html#xmlNodeListGetRawString">xmlNodeListGetRawString</a><br />
 <a href="html/libxml-pattern.html#xmlPatternMatch">xmlPatternMatch</a><br />
 <a href="html/libxml-tree.html#xmlRemoveProp">xmlRemoveProp</a><br />
+<a href="html/libxml-tree.html#xmlSplitQName2">xmlSplitQName2</a><br />
 <a href="html/libxml-xmlstring.html#xmlUTF8Strlen">xmlUTF8Strlen</a><br />
 <a href="html/libxml-valid.html#xmlValidateRoot">xmlValidateRoot</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathLeading">xmlXPathLeading</a><br />
diff --git a/doc/APIchunk14.html b/doc/APIchunk14.html
index 0e33ddb..90b8249 100644
--- a/doc/APIchunk14.html
+++ b/doc/APIchunk14.html
@@ -322,7 +322,6 @@
 <a href="html/libxml-tree.html#xmlNodeGetBase">xmlNodeGetBase</a><br />
 <a href="html/libxml-parser.html#xmlParseBalancedChunkMemoryRecover">xmlParseBalancedChunkMemoryRecover</a><br />
 <a href="html/libxml-xmlwriter.html#xmlTextWriterFullEndElement">xmlTextWriterFullEndElement</a><br />
-<a href="html/libxml-xpathInternals.html#xmlXPathRoundFunction">xmlXPathRoundFunction</a><br />
 </dd><dt>event</dt><dd><a href="html/libxml-xmlschemas.html#xmlSchemaSAXPlug">xmlSchemaSAXPlug</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSAXUnplug">xmlSchemaSAXUnplug</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidateStream">xmlSchemaValidateStream</a><br />
diff --git a/doc/APIchunk16.html b/doc/APIchunk16.html
index 92d3845..df2307d 100644
--- a/doc/APIchunk16.html
+++ b/doc/APIchunk16.html
@@ -42,7 +42,6 @@
 </dd><dt>gMonthDay</dt><dd><a href="html/libxml-xmlschemastypes.html#xmlSchemaGetCanonValue">xmlSchemaGetCanonValue</a><br />
 </dd><dt>gYear</dt><dd><a href="html/libxml-xmlschemastypes.html#xmlSchemaGetCanonValue">xmlSchemaGetCanonValue</a><br />
 </dd><dt>gYearMonth</dt><dd><a href="html/libxml-xmlschemastypes.html#xmlSchemaGetCanonValue">xmlSchemaGetCanonValue</a><br />
-</dd><dt>garanteed</dt><dd><a href="html/libxml-xmlstring.html#xmlUTF8Strsize">xmlUTF8Strsize</a><br />
 </dd><dt>garbage</dt><dd><a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemSetup">xmlGcMemSetup</a><br />
 </dd><dt>gcc</dt><dd><a href="html/libxml-hash.html#XML_CAST_FPTR">XML_CAST_FPTR</a><br />
@@ -183,6 +182,7 @@
 <a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
 </dd><dt>guaranteed</dt><dd><a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
+<a href="html/libxml-xmlstring.html#xmlUTF8Strsize">xmlUTF8Strsize</a><br />
 </dd><dt>guess</dt><dd><a href="html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a><br />
 <a href="html/libxml-threads.html#xmlCleanupThreads">xmlCleanupThreads</a><br />
 </dd></dl><h2>Letter h:</h2><dl><dt>had</dt><dd><a href="html/libxml-tree.html#xmlNewGlobalNs">xmlNewGlobalNs</a><br />
@@ -194,6 +194,7 @@
 <a href="html/libxml-parserInternals.html#xmlParseElementContentDecl">xmlParseElementContentDecl</a><br />
 <a href="html/libxml-parserInternals.html#xmlParsePEReference">xmlParsePEReference</a><br />
 <a href="html/libxml-parserInternals.html#xmlParserHandlePEReference">xmlParserHandlePEReference</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>handlers</dt><dd><a href="html/libxml-xlink.html#xlinkSetDefaultHandler">xlinkSetDefaultHandler</a><br />
 <a href="html/libxml-encoding.html#xmlCleanupCharEncodingHandlers">xmlCleanupCharEncodingHandlers</a><br />
 <a href="html/libxml-xmlIO.html#xmlRegisterDefaultInputCallbacks">xmlRegisterDefaultInputCallbacks</a><br />
diff --git a/doc/APIchunk17.html b/doc/APIchunk17.html
index 070f8ce..9978330 100644
--- a/doc/APIchunk17.html
+++ b/doc/APIchunk17.html
@@ -267,6 +267,7 @@
 <a href="html/libxml-xmlregexp.html#xmlExpParse">xmlExpParse</a><br />
 </dd><dt>infinity</dt><dd><a href="html/libxml-xpathInternals.html#xmlXPathCeilingFunction">xmlXPathCeilingFunction</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathFloorFunction">xmlXPathFloorFunction</a><br />
+<a href="html/libxml-xpathInternals.html#xmlXPathRoundFunction">xmlXPathRoundFunction</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathStringFunction">xmlXPathStringFunction</a><br />
 </dd><dt>info</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
 <a href="html/libxml-encoding.html#xmlCharEncodingOutputFunc">xmlCharEncodingOutputFunc</a><br />
diff --git a/doc/APIchunk18.html b/doc/APIchunk18.html
index 90249a1..fea13d2 100644
--- a/doc/APIchunk18.html
+++ b/doc/APIchunk18.html
@@ -366,6 +366,7 @@
 <a href="html/libxml-parser.html#xmlSetFeature">xmlSetFeature</a><br />
 <a href="html/libxml-xmlstring.html#xmlUTF8Strloc">xmlUTF8Strloc</a><br />
 <a href="html/libxml-xpointer.html#xmlXPtrLocationSetAdd">xmlXPtrLocationSetAdd</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>locations</dt><dd><a href="html/libxml-xpointer.html#_xmlLocationSet">_xmlLocationSet</a><br />
 </dd><dt>locator</dt><dd><a href="html/libxml-SAX.html#setDocumentLocator">setDocumentLocator</a><br />
 <a href="html/libxml-parser.html#setDocumentLocatorSAXFunc">setDocumentLocatorSAXFunc</a><br />
diff --git a/doc/APIchunk2.html b/doc/APIchunk2.html
index 1d10f93..8a7d8f7 100644
--- a/doc/APIchunk2.html
+++ b/doc/APIchunk2.html
@@ -327,7 +327,6 @@
 </dd><dt>Ethiopic</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsEthiopic">xmlUCSIsEthiopic</a><br />
 </dd><dt>Evaluate</dt><dd><a href="html/libxml-xpath.html#xmlXPathCompiledEval">xmlXPathCompiledEval</a><br />
 <a href="html/libxml-xpath.html#xmlXPathEval">xmlXPathEval</a><br />
-<a href="html/libxml-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a><br />
 <a href="html/libxml-xpath.html#xmlXPathEvalPredicate">xmlXPathEvalPredicate</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathEvaluatePredicateResult">xmlXPathEvaluatePredicateResult</a><br />
 <a href="html/libxml-xpath.html#xmlXPathNodeEval">xmlXPathNodeEval</a><br />
diff --git a/doc/APIchunk20.html b/doc/APIchunk20.html
index 0317066..d16bfcf 100644
--- a/doc/APIchunk20.html
+++ b/doc/APIchunk20.html
@@ -105,7 +105,6 @@
 <a href="html/libxml-xmlschemas.html#xmlSchemaSAXPlug">xmlSchemaSAXPlug</a><br />
 <a href="html/libxml-tree.html#xmlSetBufferAllocationScheme">xmlSetBufferAllocationScheme</a><br />
 <a href="html/libxml-debugXML.html#xmlShellPwd">xmlShellPwd</a><br />
-<a href="html/libxml-xmlstring.html#xmlStrncat">xmlStrncat</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderCurrentDoc">xmlTextReaderCurrentDoc</a><br />
 <a href="html/libxml-valid.html#xmlValidCtxtNormalizeAttributeValue">xmlValidCtxtNormalizeAttributeValue</a><br />
 <a href="html/libxml-valid.html#xmlValidNormalizeAttributeValue">xmlValidNormalizeAttributeValue</a><br />
@@ -195,6 +194,7 @@
 <a href="html/libxml-xmlregexp.html#xmlRegExecPushString2">xmlRegExecPushString2</a><br />
 </dd><dt>non-negative</dt><dd><a href="html/libxml-c14n.html#xmlC14NDocSaveTo">xmlC14NDocSaveTo</a><br />
 <a href="html/libxml-c14n.html#xmlC14NExecute">xmlC14NExecute</a><br />
+<a href="html/libxml-xmlreader.html#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a><br />
 </dd><dt>non-normative</dt><dd><a href="html/libxml-encoding.html#xmlDetectCharEncoding">xmlDetectCharEncoding</a><br />
 </dd><dt>non-null</dt><dd><a href="html/libxml-debugXML.html#xmlShellPrintNode">xmlShellPrintNode</a><br />
 </dd><dt>non-recursive</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
diff --git a/doc/APIchunk21.html b/doc/APIchunk21.html
index c655198..85fa55e 100644
--- a/doc/APIchunk21.html
+++ b/doc/APIchunk21.html
@@ -59,7 +59,11 @@
 </dd><dt>occur</dt><dd><a href="html/libxml-schemasInternals.html#XML_SCHEMAS_TYPE_VARIETY_ABSENT">XML_SCHEMAS_TYPE_VARIETY_ABSENT</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseComment">xmlParseComment</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseMarkupDecl">xmlParseMarkupDecl</a><br />
-</dd><dt>occured</dt><dd><a href="html/libxml-xmlerror.html#xmlCtxtGetLastError">xmlCtxtGetLastError</a><br />
+</dd><dt>occurences</dt><dd><a href="html/libxml-xmlautomata.html#xmlAutomataNewCountTrans">xmlAutomataNewCountTrans</a><br />
+<a href="html/libxml-xmlautomata.html#xmlAutomataNewCountTrans2">xmlAutomataNewCountTrans2</a><br />
+<a href="html/libxml-xmlautomata.html#xmlAutomataNewOnceTrans">xmlAutomataNewOnceTrans</a><br />
+<a href="html/libxml-xmlautomata.html#xmlAutomataNewOnceTrans2">xmlAutomataNewOnceTrans2</a><br />
+</dd><dt>occurred</dt><dd><a href="html/libxml-xmlerror.html#xmlCtxtGetLastError">xmlCtxtGetLastError</a><br />
 <a href="html/libxml-dict.html#xmlDictCreate">xmlDictCreate</a><br />
 <a href="html/libxml-dict.html#xmlDictCreateSub">xmlDictCreateSub</a><br />
 <a href="html/libxml-xmlerror.html#xmlGetLastError">xmlGetLastError</a><br />
@@ -67,13 +71,9 @@
 <a href="html/libxml-hash.html#xmlHashCreateDict">xmlHashCreateDict</a><br />
 <a href="html/libxml-list.html#xmlListRemoveFirst">xmlListRemoveFirst</a><br />
 <a href="html/libxml-list.html#xmlListRemoveLast">xmlListRemoveLast</a><br />
-<a href="html/libxml-xmlreader.html#xmlTextReaderErrorFunc">xmlTextReaderErrorFunc</a><br />
-</dd><dt>occurences</dt><dd><a href="html/libxml-xmlautomata.html#xmlAutomataNewCountTrans">xmlAutomataNewCountTrans</a><br />
-<a href="html/libxml-xmlautomata.html#xmlAutomataNewCountTrans2">xmlAutomataNewCountTrans2</a><br />
-<a href="html/libxml-xmlautomata.html#xmlAutomataNewOnceTrans">xmlAutomataNewOnceTrans</a><br />
-<a href="html/libxml-xmlautomata.html#xmlAutomataNewOnceTrans2">xmlAutomataNewOnceTrans2</a><br />
-</dd><dt>occurred</dt><dd><a href="html/libxml-xmlmemory.html#xmlMemStrdupLoc">xmlMemStrdupLoc</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemStrdupLoc">xmlMemStrdupLoc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemoryStrdup">xmlMemoryStrdup</a><br />
+<a href="html/libxml-xmlreader.html#xmlTextReaderErrorFunc">xmlTextReaderErrorFunc</a><br />
 </dd><dt>occurrence</dt><dd><a href="html/libxml-xmlstring.html#xmlStrcasestr">xmlStrcasestr</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrchr">xmlStrchr</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrstr">xmlStrstr</a><br />
diff --git a/doc/APIchunk23.html b/doc/APIchunk23.html
index 16c7c21..a18be6e 100644
--- a/doc/APIchunk23.html
+++ b/doc/APIchunk23.html
@@ -124,6 +124,7 @@
 <a href="html/libxml-debugXML.html#xmlShell">xmlShell</a><br />
 </dd><dt>ready</dt><dd><a href="html/libxml-parserInternals.html#INPUT_CHUNK">INPUT_CHUNK</a><br />
 <a href="html/libxml-xmlautomata.html#xmlAutomataCompile">xmlAutomataCompile</a><br />
+</dd><dt>real</dt><dd><a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>realloc</dt><dd><a href="html/libxml-tree.html#_xmlBuffer">_xmlBuffer</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemSetup">xmlGcMemSetup</a><br />
@@ -133,6 +134,7 @@
 <a href="html/libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlReallocLoc">xmlReallocLoc</a><br />
 </dd><dt>reallocated</dt><dd><a href="html/libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a><br />
+<a href="html/libxml-xmlstring.html#xmlStrcat">xmlStrcat</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrncat">xmlStrncat</a><br />
 </dd><dt>really</dt><dd><a href="html/libxml-HTMLtree.html#HTML_COMMENT_NODE">HTML_COMMENT_NODE</a><br />
 <a href="html/libxml-HTMLtree.html#HTML_ENTITY_REF_NODE">HTML_ENTITY_REF_NODE</a><br />
diff --git a/doc/APIchunk24.html b/doc/APIchunk24.html
index e81f34d..5b17955 100644
--- a/doc/APIchunk24.html
+++ b/doc/APIchunk24.html
@@ -548,6 +548,7 @@
 <a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
 <a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-xmlwriter.html#xmlTextWriterWriteRawLen">xmlTextWriterWriteRawLen</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>specialized</dt><dd><a href="html/libxml-tree.html#_xmlDOMWrapCtxt">_xmlDOMWrapCtxt</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemSetup">xmlGcMemSetup</a><br />
@@ -667,6 +668,7 @@
 <a href="html/libxml-valid.html#xmlValidNormalizeAttributeValue">xmlValidNormalizeAttributeValue</a><br />
 <a href="html/libxml-valid.html#xmlValidateDocumentFinal">xmlValidateDocumentFinal</a><br />
 <a href="html/libxml-valid.html#xmlValidateDtdFinal">xmlValidateDtdFinal</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>steps</dt><dd><a href="html/libxml-uri.html#xmlNormalizeURIPath">xmlNormalizeURIPath</a><br />
 <a href="html/libxml-valid.html#xmlValidateDocumentFinal">xmlValidateDocumentFinal</a><br />
 </dd><dt>still</dt><dd><a href="html/libxml-parserInternals.html#xmlCheckLanguageID">xmlCheckLanguageID</a><br />
diff --git a/doc/APIchunk28.html b/doc/APIchunk28.html
index c5993f9..3018456 100644
--- a/doc/APIchunk28.html
+++ b/doc/APIchunk28.html
@@ -480,6 +480,7 @@
 <a href="html/libxml-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a><br />
 <a href="html/libxml-xpointer.html#xmlXPtrNewContext">xmlXPtrNewContext</a><br />
 </dd><dt>xmlXPathError</dt><dd><a href="">err</a><br />
+</dd><dt>xmlXPathEval</dt><dd><a href="html/libxml-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a><br />
 </dd><dt>xmlXPathEvalPredicate</dt><dd><a href="html/libxml-xpointer.html#xmlXPtrEvalRangePredicate">xmlXPtrEvalRangePredicate</a><br />
 </dd><dt>xmlXPathFreeObject</dt><dd><a href="html/libxml-xpath.html#xmlXPathFreeNodeSetList">xmlXPathFreeNodeSetList</a><br />
 </dd><dt>xmlXPathFunction</dt><dd><a href="html/libxml-xpathInternals.html#xmlXPathFunctionLookup">xmlXPathFunctionLookup</a><br />
@@ -531,6 +532,7 @@
 <a href="html/libxml-xmlreader.html#xmlReaderWalker">xmlReaderWalker</a><br />
 </dd><dt>xpath</dt><dd><a href="html/libxml-debugXML.html#xmlShellPrintXPathError">xmlShellPrintXPathError</a><br />
 <a href="html/libxml-debugXML.html#xmlShellPrintXPathResult">xmlShellPrintXPathResult</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>xpointer</dt><dd><a href="html/libxml-xinclude.html#XINCLUDE_PARSE_XPOINTER">XINCLUDE_PARSE_XPOINTER</a><br />
 </dd></dl><h2 align="center"><a href="APIchunk0.html">A-B</a>
 <a href="APIchunk1.html">C-C</a>
diff --git a/doc/APIchunk5.html b/doc/APIchunk5.html
index da60d1a..44f5d02 100644
--- a/doc/APIchunk5.html
+++ b/doc/APIchunk5.html
@@ -56,6 +56,7 @@
 <a href="html/libxml-schemasInternals.html#_xmlSchemaElement">_xmlSchemaElement</a><br />
 <a href="html/libxml-schemasInternals.html#_xmlSchemaFacet">_xmlSchemaFacet</a><br />
 <a href="html/libxml-schemasInternals.html#_xmlSchemaType">_xmlSchemaType</a><br />
+<a href="html/libxml-xpointer.html#xmlXPtrRangeToFunction">xmlXPtrRangeToFunction</a><br />
 </dd><dt>Obtain</dt><dd><a href="html/libxml-xmlreader.html#xmlTextReaderLocatorBaseURI">xmlTextReaderLocatorBaseURI</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderLocatorLineNumber">xmlTextReaderLocatorLineNumber</a><br />
 </dd><dt>Ogham</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsOgham">xmlUCSIsOgham</a><br />
@@ -72,7 +73,8 @@
 </dd><dt>Oriya</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsOriya">xmlUCSIsOriya</a><br />
 </dd><dt>Osmanya</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsOsmanya">xmlUCSIsOsmanya</a><br />
 </dd><dt>Other</dt><dd><a href="html/libxml-xpath.html#xmlXPathContextSetCache">xmlXPathContextSetCache</a><br />
-</dd><dt>Otherwise</dt><dd><a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
+</dd><dt>Otherwise</dt><dd><a href="html/libxml-tree.html#xmlSplitQName2">xmlSplitQName2</a><br />
+<a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 </dd><dt>Output</dt><dd><a href="html/libxml-xmlIO.html#xmlOutputCloseCallback">xmlOutputCloseCallback</a><br />
 <a href="html/libxml-xmlIO.html#xmlOutputMatchCallback">xmlOutputMatchCallback</a><br />
diff --git a/doc/APIfunctions.html b/doc/APIfunctions.html
index f9ac249..caa0a87 100644
--- a/doc/APIfunctions.html
+++ b/doc/APIfunctions.html
@@ -147,7 +147,9 @@
 <a href="html/libxml-HTMLparser.html#htmlIsScriptAttribute">htmlIsScriptAttribute</a><br />
 <a href="html/libxml-HTMLtree.html#htmlNewDoc">htmlNewDoc</a><br />
 <a href="html/libxml-HTMLtree.html#htmlNewDocNoDtD">htmlNewDocNoDtD</a><br />
+<a href="html/libxml-HTMLparser.html#htmlParseDoc">htmlParseDoc</a><br />
 <a href="html/libxml-HTMLparser.html#htmlReadDoc">htmlReadDoc</a><br />
+<a href="html/libxml-HTMLparser.html#htmlSAXParseDoc">htmlSAXParseDoc</a><br />
 <a href="html/libxml-HTMLtree.html#htmlSetMetaEncoding">htmlSetMetaEncoding</a><br />
 <a href="html/libxml-HTMLparser.html#htmlTagLookup">htmlTagLookup</a><br />
 <a href="html/libxml-SAX.html#ignorableWhitespace">ignorableWhitespace</a><br />
@@ -1039,8 +1041,6 @@
 <a href="html/libxml-DOCBparser.html#docbSAXParseDoc">docbSAXParseDoc</a><br />
 <a href="html/libxml-SAX.html#entityDecl">entityDecl</a><br />
 <a href="html/libxml-parser.html#entityDeclSAXFunc">entityDeclSAXFunc</a><br />
-<a href="html/libxml-HTMLparser.html#htmlParseDoc">htmlParseDoc</a><br />
-<a href="html/libxml-HTMLparser.html#htmlSAXParseDoc">htmlSAXParseDoc</a><br />
 <a href="html/libxml-tree.html#xmlBuildQName">xmlBuildQName</a><br />
 <a href="html/libxml-parserInternals.html#xmlCopyChar">xmlCopyChar</a><br />
 <a href="html/libxml-parserInternals.html#xmlCopyCharMultiByte">xmlCopyCharMultiByte</a><br />
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 0cc0a50..6bda566 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -243,7 +243,7 @@
 
 api: libxml2-api.xml libxml2-refs.xml $(APIPAGES) $(srcdir)/html/index.html $(WIN32_DIR)/libxml2.def.src ../elfgcchack.h $(srcdir)/site.xsl
 
-web: $(PAGES)
+web: $(PAGES) xmllint.html xmlcatalog_man.html
 
 ../elfgcchack.h: $(srcdir)/elfgcchack.xsl $(srcdir)/libxml2-api.xml
 	-@(if [ -x $(XSLTPROC) ] ; then \
@@ -314,9 +314,15 @@
 xmllint.1: xmllint.xml
 	-@($(XSLTPROC) --nonet xmllint.xml)
 
+xmllint.html: xmllint.xml
+	-@($(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl xmllint.xml)
+
 xmlcatalog.1: xmlcatalog_man.xml
 	-@($(XSLTPROC) --nonet xmlcatalog_man.xml)
 
+xmlcatalog_man.html: xmlcatalog_man.xml
+	-@($(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl xmlcatalog_man.xml)
+
 check-extra-dist:
 	for f in $(EXTRA_DIST_wc) ; do echo $$f; done | sort -u >tmp.EXTRA_DIST_wc
 	for f in $(EXTRA_DIST) ;    do echo $$f; done | sort    >tmp.EXTRA_DIST
diff --git a/doc/bugs.html b/doc/bugs.html
index 55ff296..52970d3 100644
--- a/doc/bugs.html
+++ b/doc/bugs.html
@@ -13,7 +13,7 @@
 bug tracking database</a> (make sure to use the "libxml2" module name). I
 look at reports there regularly and it's good to have a reminder when a bug
 is still open. Be sure to specify that the bug is for the package libxml2.</p><p>For small problems you can try to get help on IRC, the #xml channel on
-irc.gnome.org (port 6667) usually have a few person subscribed which may help
+irc.gnome.org (port 6667) usually has a few people subscribed which may help
 (but there is no guarantee and if a real issue is raised it should go on the
 mailing-list for archival).</p><p>There is also a mailing-list <a href="mailto:xml@gnome.org">xml@gnome.org</a> for libxml, with an  <a href="http://mail.gnome.org/archives/xml/">on-line archive</a> (<a href="http://xmlsoft.org/messages">old</a>). To subscribe to this list,
 please visit the <a href="http://mail.gnome.org/mailman/listinfo/xml">associated Web</a> page and
diff --git a/doc/devhelp/libxml2-HTMLparser.html b/doc/devhelp/libxml2-HTMLparser.html
index 6d8a42a..3af5a9c 100644
--- a/doc/devhelp/libxml2-HTMLparser.html
+++ b/doc/devhelp/libxml2-HTMLparser.html
@@ -96,9 +96,9 @@
 <a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlCtxtReadFile">htmlCtxtReadFile</a>	(<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br/>					 const char * filename, <br/>					 const char * encoding, <br/>					 int options);
 int	<a href="#htmlParseDocument">htmlParseDocument</a>		(<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt);
 <a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>	<a href="#htmlNewParserCtxt">htmlNewParserCtxt</a>	(void);
-<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlSAXParseDoc">htmlSAXParseDoc</a>		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding, <br/>					 <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br/>					 void * userData);
+<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlSAXParseDoc">htmlSAXParseDoc</a>		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding, <br/>					 <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br/>					 void * userData);
 int	<a href="#htmlCtxtUseOptions">htmlCtxtUseOptions</a>		(<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br/>					 int options);
-<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlParseDoc">htmlParseDoc</a>		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding);
+<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlParseDoc">htmlParseDoc</a>		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding);
 </pre>
     </div>
     <div class="refsect1" lang="en">
@@ -315,7 +315,7 @@
 </pre><p>Parse a Chunk of memory</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an HTML parser context</td></tr><tr><td><span class="term"><i><tt>chunk</tt></i>:</span></td><td>an char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size in byte of the chunk</td></tr><tr><td><span class="term"><i><tt>terminate</tt></i>:</span></td><td>last chunk indicator</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>zero if no error, the <a href="libxml2-xmlerror.html#xmlParserErrors">xmlParserErrors</a> otherwise.</td></tr></tbody></table></div></div>
         <hr/>
-        <div class="refsect2" lang="en"><h3><a name="htmlParseDoc"/>htmlParseDoc ()</h3><pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlParseDoc		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding)<br/>
+        <div class="refsect2" lang="en"><h3><a name="htmlParseDoc"/>htmlParseDoc ()</h3><pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlParseDoc		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding)<br/>
 </pre><p>parse an HTML in-memory document and build a tree.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>a pointer to an array of <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a></td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>a free form C string describing the HTML document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div></div>
         <hr/>
@@ -355,7 +355,7 @@
 </pre><p>parse an XML in-memory document and build a tree.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>buffer</tt></i>:</span></td><td>a pointer to a char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the array</td></tr><tr><td><span class="term"><i><tt>URL</tt></i>:</span></td><td>the base URL to use for the document</td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>the document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of htmlParserOption(s)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div></div>
         <hr/>
-        <div class="refsect2" lang="en"><h3><a name="htmlSAXParseDoc"/>htmlSAXParseDoc ()</h3><pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlSAXParseDoc		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding, <br/>					 <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br/>					 void * userData)<br/>
+        <div class="refsect2" lang="en"><h3><a name="htmlSAXParseDoc"/>htmlSAXParseDoc ()</h3><pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlSAXParseDoc		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const char * encoding, <br/>					 <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br/>					 void * userData)<br/>
 </pre><p>Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>a pointer to an array of <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a></td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>a free form C string describing the HTML document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>sax</tt></i>:</span></td><td>the SAX handler block</td></tr><tr><td><span class="term"><i><tt>userData</tt></i>:</span></td><td>if using SAX, this pointer will be provided on callbacks.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree unless SAX is NULL or the document is not well formed.</td></tr></tbody></table></div></div>
         <hr/>
diff --git a/doc/devhelp/libxml2-dict.html b/doc/devhelp/libxml2-dict.html
index 3776c5b..6bff563 100644
--- a/doc/devhelp/libxml2-dict.html
+++ b/doc/devhelp/libxml2-dict.html
@@ -82,11 +82,11 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlDictCreate"/>xmlDictCreate ()</h3><pre class="programlisting"><a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreate		(void)<br/>
 </pre><p>Create a new dictionary</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occured.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occurred.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlDictCreateSub"/>xmlDictCreateSub ()</h3><pre class="programlisting"><a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreateSub	(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> sub)<br/>
 </pre><p>Create a new dictionary, inheriting strings from the read-only dictionary @sub. On lookup, strings are first searched in the new dictionary, then in @sub, and if not found are created in the new dictionary.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>sub</tt></i>:</span></td><td>an existing dictionary</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occured.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>sub</tt></i>:</span></td><td>an existing dictionary</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occurred.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlDictExists"/>xmlDictExists ()</h3><pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictExists		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br/>					 int len)<br/>
 </pre><p>Check if the @name exists in the dictionary @dict.</p>
diff --git a/doc/devhelp/libxml2-hash.html b/doc/devhelp/libxml2-hash.html
index c5a9911..b0de53d 100644
--- a/doc/devhelp/libxml2-hash.html
+++ b/doc/devhelp/libxml2-hash.html
@@ -130,11 +130,11 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlHashCreate"/>xmlHashCreate ()</h3><pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>	xmlHashCreate		(int size)<br/>
 </pre><p>Create a new xmlHashTablePtr.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occured.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occurred.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlHashCreateDict"/>xmlHashCreateDict ()</h3><pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>	xmlHashCreateDict	(int size, <br/>					 <a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br/>
 </pre><p>Create a new <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> which will use @dict as the internal dictionary</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>a dictionary to use for the hash</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occured.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>a dictionary to use for the hash</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occurred.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlHashFree"/>xmlHashFree ()</h3><pre class="programlisting">void	xmlHashFree			(<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br/>					 <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br/>
 </pre><p>Free the hash @table and its contents. The userdata is deallocated with @f if provided.</p>
diff --git a/doc/devhelp/libxml2-list.html b/doc/devhelp/libxml2-list.html
index 8a4fa73..8019c23 100644
--- a/doc/devhelp/libxml2-list.html
+++ b/doc/devhelp/libxml2-list.html
@@ -186,11 +186,11 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlListRemoveFirst"/>xmlListRemoveFirst ()</h3><pre class="programlisting">int	xmlListRemoveFirst		(<a href="libxml2-list.html#xmlListPtr">xmlListPtr</a> l, <br/>					 void * data)<br/>
 </pre><p>Remove the first instance associated to data in the list</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occured, or 0 if not found</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occurred, or 0 if not found</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlListRemoveLast"/>xmlListRemoveLast ()</h3><pre class="programlisting">int	xmlListRemoveLast		(<a href="libxml2-list.html#xmlListPtr">xmlListPtr</a> l, <br/>					 void * data)<br/>
 </pre><p>Remove the last instance associated to data in the list</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occured, or 0 if not found</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occurred, or 0 if not found</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlListReverse"/>xmlListReverse ()</h3><pre class="programlisting">void	xmlListReverse			(<a href="libxml2-list.html#xmlListPtr">xmlListPtr</a> l)<br/>
 </pre><p>Reverse the order of the elements in the list</p>
diff --git a/doc/devhelp/libxml2-schemasInternals.html b/doc/devhelp/libxml2-schemasInternals.html
index 2f9cbc9..ab91754 100644
--- a/doc/devhelp/libxml2-schemasInternals.html
+++ b/doc/devhelp/libxml2-schemasInternals.html
@@ -39,7 +39,7 @@
       <span class="refentrytitle">schemasInternals</span>
     </h2>
     <p>schemasInternals - internal interfaces for XML Schemas</p>
-    <p>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not garanteed to be API or ABI stable ! </p>
+    <p>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not guaranteed to be API or ABI stable ! </p>
     <p>Author(s): Daniel Veillard </p>
     <div class="refsynopsisdiv">
       <h2>Synopsis</h2>
diff --git a/doc/devhelp/libxml2-tree.html b/doc/devhelp/libxml2-tree.html
index ac85d60..44e1e03 100644
--- a/doc/devhelp/libxml2-tree.html
+++ b/doc/devhelp/libxml2-tree.html
@@ -1542,7 +1542,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlSplitQName2"/>xmlSplitQName2 ()</h3><pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlSplitQName2		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br/>					 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** prefix)<br/>
 </pre><p>parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the full QName</td></tr><tr><td><span class="term"><i><tt>prefix</tt></i>:</span></td><td>a <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> **</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if not a QName, otherwise the local part, and prefix is updated to get the Prefix if any.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the full QName</td></tr><tr><td><span class="term"><i><tt>prefix</tt></i>:</span></td><td>a <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> **</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if the name doesn't have a prefix. Otherwise, returns the local part, and prefix is updated to get the Prefix. Both the return value and the prefix must be freed by the caller.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlSplitQName3"/>xmlSplitQName3 ()</h3><pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlSplitQName3		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br/>					 int * len)<br/>
 </pre><p>parse an XML qualified name string,i</p>
diff --git a/doc/devhelp/libxml2-xmlerror.html b/doc/devhelp/libxml2-xmlerror.html
index 13bab8a..6a93649 100644
--- a/doc/devhelp/libxml2-xmlerror.html
+++ b/doc/devhelp/libxml2-xmlerror.html
@@ -897,7 +897,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlCtxtGetLastError"/>xmlCtxtGetLastError ()</h3><pre class="programlisting"><a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>	xmlCtxtGetLastError	(void * ctx)<br/>
 </pre><p>Get the last parsing error registered.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occured or a pointer to the error</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occurred or a pointer to the error</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlCtxtResetLastError"/>xmlCtxtResetLastError ()</h3><pre class="programlisting">void	xmlCtxtResetLastError		(void * ctx)<br/>
 </pre><p>Cleanup the last global error registered. For parsing error this does not change the well-formedness result.</p>
@@ -905,7 +905,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlGetLastError"/>xmlGetLastError ()</h3><pre class="programlisting"><a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>	xmlGetLastError		(void)<br/>
 </pre><p>Get the last global error registered. This is per thread if compiled with thread support.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occured or a pointer to the error</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occurred or a pointer to the error</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlParserError"/>xmlParserError ()</h3><pre class="programlisting">void	xmlParserError			(void * ctx, <br/>					 const char * msg, <br/>					 ... ...)<br/>
 </pre><p>Display and format an error messages, gives file, line, position and extra parameters.</p>
diff --git a/doc/devhelp/libxml2-xmlreader.html b/doc/devhelp/libxml2-xmlreader.html
index 3814f43..2051f70 100644
--- a/doc/devhelp/libxml2-xmlreader.html
+++ b/doc/devhelp/libxml2-xmlreader.html
@@ -213,7 +213,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlTextReaderErrorFunc"/>Function type xmlTextReaderErrorFunc</h3><pre class="programlisting">void	xmlTextReaderErrorFunc		(void * arg, <br/>					 const char * msg, <br/>					 <a href="libxml2-xmlreader.html#xmlParserSeverities">xmlParserSeverities</a> severity, <br/>					 <a href="libxml2-xmlreader.html#xmlTextReaderLocatorPtr">xmlTextReaderLocatorPtr</a> locator)<br/>
 </pre><p>Signature of an error callback from a reader parser</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>arg</tt></i>:</span></td><td>the user argument</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message</td></tr><tr><td><span class="term"><i><tt>severity</tt></i>:</span></td><td>the severity of the error</td></tr><tr><td><span class="term"><i><tt>locator</tt></i>:</span></td><td>a locator indicating where the error occured</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>arg</tt></i>:</span></td><td>the user argument</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message</td></tr><tr><td><span class="term"><i><tt>severity</tt></i>:</span></td><td>the severity of the error</td></tr><tr><td><span class="term"><i><tt>locator</tt></i>:</span></td><td>a locator indicating where the error occurred</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlFreeTextReader"/>xmlFreeTextReader ()</h3><pre class="programlisting">void	xmlFreeTextReader		(<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br/>
 </pre><p>Deallocate all the resources associated to the reader</p>
@@ -477,7 +477,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlTextReaderPreservePattern"/>xmlTextReaderPreservePattern ()</h3><pre class="programlisting">int	xmlTextReaderPreservePattern	(<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)<br/>
 </pre><p>This tells the XML Reader to preserve all nodes matched by the pattern. The caller must also use xmlTextReaderCurrentDoc() to keep an handle on the resulting document once parsing has finished</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a positive number in case of success and -1 in case of error</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a non-negative number in case of success and -1 in case of error</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlTextReaderQuoteChar"/>xmlTextReaderQuoteChar ()</h3><pre class="programlisting">int	xmlTextReaderQuoteChar		(<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br/>
 </pre><p>The quotation mark character used to enclose the value of an attribute.</p>
diff --git a/doc/devhelp/libxml2-xmlstring.html b/doc/devhelp/libxml2-xmlstring.html
index ca90ed4..95a845f 100644
--- a/doc/devhelp/libxml2-xmlstring.html
+++ b/doc/devhelp/libxml2-xmlstring.html
@@ -133,7 +133,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlStrcat"/>xmlStrcat ()</h3><pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrcat		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add)<br/>
 </pre><p>a strcat for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * containing the concatenated string.</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * containing the concatenated string. The original @cur is reallocated and should not be freed.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlStrchr"/>xmlStrchr ()</h3><pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrchr		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br/>					 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> val)<br/>
 </pre><p>a strchr for xmlChar's</p>
@@ -157,7 +157,7 @@
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlStrncat"/>xmlStrncat ()</h3><pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrncat		(<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add, <br/>					 int len)<br/>
 </pre><p>a strncat for array of xmlChar's, it will extend @cur with the len first bytes of @add. Note that if @len &lt; 0 then this is an API error and NULL will be returned.</p>
-<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the length of @add</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *, the original @cur is reallocated if needed and should not be freed</td></tr></tbody></table></div></div>
+<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the length of @add</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *, the original @cur is reallocated and should not be freed.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlStrncatNew"/>xmlStrncatNew ()</h3><pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrncatNew		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br/>					 int len)<br/>
 </pre><p>same as xmlStrncat, but creates a new string. The original two strings are not freed. If @len is &lt; 0 then the length will be calculated automatically.</p>
@@ -204,7 +204,7 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>the input UTF8 *</td></tr><tr><td><span class="term"><i><tt>pos</tt></i>:</span></td><td>the position of the desired UTF8 char (in chars)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the UTF8 character or NULL</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlUTF8Strsize"/>xmlUTF8Strsize ()</h3><pre class="programlisting">int	xmlUTF8Strsize			(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br/>					 int len)<br/>
-</pre><p>storage size of an UTF8 string the behaviour is not garanteed if the input string is not UTF-8</p>
+</pre><p>storage size of an UTF8 string the behaviour is not guaranteed if the input string is not UTF-8</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>a sequence of UTF-8 encoded bytes</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the number of <a href="libxml2-SAX.html#characters">characters</a> in the array</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the storage size of the first 'len' <a href="libxml2-SAX.html#characters">characters</a> of ARRAY</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlUTF8Strsub"/>xmlUTF8Strsub ()</h3><pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlUTF8Strsub		(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br/>					 int start, <br/>					 int len)<br/>
diff --git a/doc/devhelp/libxml2-xpath.html b/doc/devhelp/libxml2-xpath.html
index 640c715..6a40682 100644
--- a/doc/devhelp/libxml2-xpath.html
+++ b/doc/devhelp/libxml2-xpath.html
@@ -473,7 +473,7 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the XPath expression</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the XPath context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> resulting from the evaluation or NULL. the caller has to free the object.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPathEvalExpression"/>xmlXPathEvalExpression ()</h3><pre class="programlisting"><a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPathEvalExpression	(const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br/>						 <a href="libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> ctxt)<br/>
-</pre><p>Evaluate the XPath expression in the given context.</p>
+</pre><p>Alias for xmlXPathEval().</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the XPath expression</td></tr><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> resulting from the evaluation or NULL. the caller has to free the object.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPathEvalPredicate"/>xmlXPathEvalPredicate ()</h3><pre class="programlisting">int	xmlXPathEvalPredicate		(<a href="libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> ctxt, <br/>					 <a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> res)<br/>
diff --git a/doc/devhelp/libxml2-xpathInternals.html b/doc/devhelp/libxml2-xpathInternals.html
index 0597343..17d27cd 100644
--- a/doc/devhelp/libxml2-xpathInternals.html
+++ b/doc/devhelp/libxml2-xpathInternals.html
@@ -694,7 +694,7 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath Parser context</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPathRoundFunction"/>xmlXPathRoundFunction ()</h3><pre class="programlisting">void	xmlXPathRoundFunction		(<a href="libxml2-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br/>					 int nargs)<br/>
-</pre><p>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is even is returned.</p>
+</pre><p>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath Parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of arguments</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPathStartsWithFunction"/>xmlXPathStartsWithFunction ()</h3><pre class="programlisting">void	xmlXPathStartsWithFunction	(<a href="libxml2-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br/>					 int nargs)<br/>
diff --git a/doc/devhelp/libxml2-xpointer.html b/doc/devhelp/libxml2-xpointer.html
index 807eed7..4d7c337 100644
--- a/doc/devhelp/libxml2-xpointer.html
+++ b/doc/devhelp/libxml2-xpointer.html
@@ -158,7 +158,7 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>start</tt></i>:</span></td><td>the starting point</td></tr><tr><td><span class="term"><i><tt>end</tt></i>:</span></td><td>the ending point</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPtrRangeToFunction"/>xmlXPtrRangeToFunction ()</h3><pre class="programlisting">void	xmlXPtrRangeToFunction		(<a href="libxml2-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br/>					 int nargs)<br/>
-</pre><p>Implement the range-to() XPointer function</p>
+</pre><p>Implement the range-to() XPointer function Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPointer Parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of args</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlXPtrWrapLocationSet"/>xmlXPtrWrapLocationSet ()</h3><pre class="programlisting"><a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPtrWrapLocationSet	(<a href="libxml2-xpointer.html#xmlLocationSetPtr">xmlLocationSetPtr</a> val)<br/>
diff --git a/doc/elfgcchack.xsl b/doc/elfgcchack.xsl
index 9b1a9bc..8dd5c6a 100644
--- a/doc/elfgcchack.xsl
+++ b/doc/elfgcchack.xsl
@@ -18,7 +18,7 @@
 #ifdef IN_LIBXML
 #ifdef __GNUC__
 #ifdef PIC
-#ifdef linux
+#ifdef __linux__
 #if (__GNUC__ == 3 &amp;&amp; __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
 
 #include "libxml/c14n.h"
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 57af9c2..ef59fce 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -13,7 +13,7 @@
 rebuild: examples.xml index.html
 .PHONY: rebuild
 
-examples.xml: index.py $(noinst_PROGRAMS:=.c)
+examples.xml: index.py $(check_PROGRAMS:=.c)
 	cd $(srcdir) && $(PYTHON) index.py
 	$(MAKE) Makefile
 
@@ -49,7 +49,7 @@
 	xpath1.res \
 	xpath2.res
 
-noinst_PROGRAMS = \
+check_PROGRAMS = \
 	io1 \
 	io2 \
 	parse1 \
@@ -99,37 +99,38 @@
 valgrind: 
 	$(MAKE) CHECKER='valgrind' tests
 
-tests: $(noinst_PROGRAMS)
-	test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .
+tests: $(check_PROGRAMS)
+	@test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .
 	@(echo '## examples regression tests')
 	@(echo > .memdump)
-	$(CHECKER) ./io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res
+	@$(CHECKER) ./io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res
+	@$(CHECKER) ./io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./parse1 test1.xml
+	@$(CHECKER) ./parse1 test1.xml
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./parse2 test2.xml
+	@$(CHECKER) ./parse2 test2.xml
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./parse3
+	@$(CHECKER) ./parse3
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./parse4 test3.xml
+	@$(CHECKER) ./parse4 test3.xml
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
+	@$(CHECKER) ./reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
+	@$(CHECKER) ./reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res
+	@$(CHECKER) ./reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res
+	@$(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done
+	@$(CHECKER) ./testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res
+	@$(CHECKER) ./tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res
+	@$(CHECKER) ./tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res
+	@$(CHECKER) ./xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-	$(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res
+	@$(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res
 	@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
+	@rm *.tmp
diff --git a/doc/examples/examples.xml b/doc/examples/examples.xml
index 28929cc..d38247b 100644
--- a/doc/examples/examples.xml
+++ b/doc/examples/examples.xml
@@ -1,123 +1,4 @@
 <examples>
-  <example filename='xpath1.c'>
-    <synopsis>Evaluate XPath expression and prints result node set.</synopsis>
-    <purpose>Shows how to evaluate XPath expression and register known namespaces in XPath context.</purpose>
-    <usage>xpath1 &lt;xml-file&gt; &lt;xpath-expr&gt; [&lt;known-ns-list&gt;]</usage>
-    <test>xpath1 test3.xml &apos;//child2&apos; &gt; xpath1.tmp &amp;&amp; diff xpath1.tmp $(srcdir)/xpath1.res</test>
-    <author>Aleksey Sanin</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>XPath</section>
-    <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
-      <include>&lt;libxml/xpath.h&gt;</include>
-      <include>&lt;libxml/xpathInternals.h&gt;</include>
-      <include>&lt;libxml/tree.h&gt;</include>
-    </includes>
-    <uses>
-      <enum line='229' file='tree' name='XML_ELEMENT_NODE'/>
-      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
-      <function line='54' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='117' file='xpath' name='xmlXPathEvalExpression'/>
-      <function line='94' file='parser' name='xmlParseFile'/>
-      <function line='186' file='xpathInternals' name='xmlXPathRegisterNs'/>
-      <function line='129' file='xpath' name='xmlXPathFreeObject'/>
-      <variable line='193' file='globals' name='xmlFree'/>
-      <typedef line='218' file='tree' name='xmlNsPtr'/>
-      <function line='101' file='xpath' name='xmlXPathNewContext'/>
-      <function line='49' file='parser' name='xmlCleanupParser'/>
-      <macro line='43' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
-      <function line='130' file='xpath' name='xmlXPathFreeContext'/>
-      <function line='39' file='parser' name='xmlInitParser'/>
-      <function line='156' file='xmlstring' name='xmlStrdup'/>
-      <function line='131' file='tree' name='xmlFreeDoc'/>
-      <function line='180' file='xmlstring' name='xmlStrchr'/>
-      <typedef line='206' file='tree' name='xmlNodePtr'/>
-      <typedef line='86' file='tree' name='xmlDocPtr'/>
-      <enum line='217' file='tree' name='XML_NAMESPACE_DECL'/>
-    </uses>
-  </example>
-  <example filename='parse3.c'>
-    <synopsis>Parse an XML document in memory to a tree and free it</synopsis>
-    <purpose>Demonstrate the use of xmlReadMemory() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
-    <usage>parse3</usage>
-    <test>parse3</test>
-    <author>Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>Parsing</section>
-    <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='33' file='parser' name='xmlReadMemory'/>
-      <function line='58' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='54' file='parser' name='xmlCleanupParser'/>
-      <macro line='49' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='38' file='tree' name='xmlFreeDoc'/>
-      <typedef line='27' file='tree' name='xmlDocPtr'/>
-    </uses>
-  </example>
-  <example filename='reader2.c'>
-    <synopsis>Parse and validate an XML file with an xmlReader</synopsis>
-    <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
-    <usage>reader2 &lt;valid_xml_filename&gt;</usage>
-    <test>reader2 test2.xml &gt; reader1.tmp &amp;&amp; diff reader1.tmp $(srcdir)/reader1.res</test>
-    <author>Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>xmlReader</section>
-    <includes>
-      <include>&lt;libxml/xmlreader.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='45' file='xmlstring' name='xmlStrlen'/>
-      <function line='109' file='parser' name='xmlCleanupParser'/>
-      <function line='38' file='xmlreader' name='xmlTextReaderNodeType'/>
-      <typedef line='60' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='113' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='34' file='xmlreader' name='xmlTextReaderConstValue'/>
-      <enum line='70' file='parser' name='XML_PARSE_NOENT'/>
-      <function line='37' file='xmlreader' name='xmlTextReaderDepth'/>
-      <enum line='71' file='parser' name='XML_PARSE_DTDVALID'/>
-      <enum line='69' file='parser' name='XML_PARSE_DTDATTR'/>
-      <function line='84' file='xmlreader' name='xmlFreeTextReader'/>
-      <macro line='104' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='30' file='xmlreader' name='xmlTextReaderConstName'/>
-      <function line='41' file='xmlreader' name='xmlTextReaderHasValue'/>
-      <function line='76' file='xmlreader' name='xmlTextReaderRead'/>
-      <function line='40' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
-      <function line='68' file='xmlreader' name='xmlReaderForFile'/>
-      <function line='81' file='xmlreader' name='xmlTextReaderIsValid'/>
-    </uses>
-  </example>
-  <example filename='tree2.c'>
-    <synopsis>Creates a tree</synopsis>
-    <purpose>Shows how to create document, nodes and dump it to stdout or file.</purpose>
-    <usage>tree2 &lt;filename&gt;  -Default output: stdout</usage>
-    <test>tree2 &gt; tree2.tmp &amp;&amp; diff tree2.tmp $(srcdir)/tree2.res</test>
-    <author>Lucas Brasilino &lt;brasilino@recife.pe.gov.br&gt;</author>
-    <copy>see Copyright for the status of this software </copy>
-    <section>Tree</section>
-    <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='75' file='tree' name='xmlNewText'/>
-      <function line='110' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='96' file='tree' name='xmlSaveFormatFileEnc'/>
-      <function line='78' file='tree' name='xmlAddChild'/>
-      <function line='41' file='tree' name='xmlDocSetRootElement'/>
-      <function line='105' file='parser' name='xmlCleanupParser'/>
-      <macro line='34' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='89' file='tree' name='xmlNewProp'/>
-      <function line='88' file='tree' name='xmlNewChild'/>
-      <function line='74' file='tree' name='xmlNewNode'/>
-      <function line='46' file='tree' name='xmlCreateIntSubset'/>
-      <function line='99' file='tree' name='xmlFreeDoc'/>
-      <function line='39' file='tree' name='xmlNewDoc'/>
-    </uses>
-  </example>
   <example filename='io1.c'>
     <synopsis>Example of custom Input/Output</synopsis>
     <purpose>Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.</purpose>
@@ -144,6 +25,96 @@
       <typedef line='105' file='tree' name='xmlDocPtr'/>
     </uses>
   </example>
+  <example filename='io2.c'>
+    <synopsis>Output to char buffer</synopsis>
+    <purpose>Demonstrate the use of xmlDocDumpMemory to output document to a character buffer</purpose>
+    <usage>io2</usage>
+    <test>io2 &gt; io2.tmp &amp;&amp; diff io2.tmp $(srcdir)/io2.res</test>
+    <author>John Fleck</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>InputOutput</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='29' file='tree' name='xmlNodeSetContent'/>
+      <function line='36' file='tree' name='xmlDocDumpFormatMemory'/>
+      <variable line='42' file='globals' name='xmlFree'/>
+      <function line='30' file='tree' name='xmlDocSetRootElement'/>
+      <typedef line='20' file='tree' name='xmlDocPtr'/>
+      <function line='43' file='tree' name='xmlFreeDoc'/>
+      <typedef line='19' file='tree' name='xmlNodePtr'/>
+      <function line='27' file='tree' name='xmlNewDoc'/>
+      <function line='28' file='tree' name='xmlNewNode'/>
+    </uses>
+  </example>
+  <example filename='parse1.c'>
+    <synopsis>Parse an XML file to a tree and free it</synopsis>
+    <purpose>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
+    <usage>parse1 test1.xml</usage>
+    <test>parse1 test1.xml</test>
+    <author>Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>Parsing</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='54' file='xmlmemory' name='xmlMemoryDump'/>
+      <function line='50' file='parser' name='xmlCleanupParser'/>
+      <macro line='45' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <typedef line='24' file='tree' name='xmlDocPtr'/>
+      <function line='31' file='tree' name='xmlFreeDoc'/>
+      <function line='26' file='parser' name='xmlReadFile'/>
+    </uses>
+  </example>
+  <example filename='parse2.c'>
+    <synopsis>Parse and validate an XML file to a tree and free the result</synopsis>
+    <purpose>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</purpose>
+    <usage>parse2 test2.xml</usage>
+    <test>parse2 test2.xml</test>
+    <author>Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>Parsing</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='47' file='parser' name='xmlFreeParserCtxt'/>
+      <enum line='35' file='parser' name='XML_PARSE_DTDVALID'/>
+      <function line='29' file='parser' name='xmlNewParserCtxt'/>
+      <typedef line='25' file='tree' name='xmlParserCtxtPtr'/>
+      <function line='35' file='parser' name='xmlCtxtReadFile'/>
+      <function line='66' file='parser' name='xmlCleanupParser'/>
+      <macro line='61' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='44' file='tree' name='xmlFreeDoc'/>
+      <typedef line='26' file='tree' name='xmlDocPtr'/>
+      <function line='70' file='xmlmemory' name='xmlMemoryDump'/>
+    </uses>
+  </example>
+  <example filename='parse3.c'>
+    <synopsis>Parse an XML document in memory to a tree and free it</synopsis>
+    <purpose>Demonstrate the use of xmlReadMemory() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
+    <usage>parse3</usage>
+    <test>parse3</test>
+    <author>Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>Parsing</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='33' file='parser' name='xmlReadMemory'/>
+      <function line='58' file='xmlmemory' name='xmlMemoryDump'/>
+      <function line='54' file='parser' name='xmlCleanupParser'/>
+      <macro line='49' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='38' file='tree' name='xmlFreeDoc'/>
+      <typedef line='27' file='tree' name='xmlDocPtr'/>
+    </uses>
+  </example>
   <example filename='parse4.c'>
     <synopsis>Parse an XML document chunk by chunk to a tree and free it</synopsis>
     <purpose>Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
@@ -168,58 +139,6 @@
       <typedef line='47' file='tree' name='xmlDocPtr'/>
     </uses>
   </example>
-  <example filename='xpath2.c'>
-    <synopsis>Load a document, locate subelements with XPath, modify said elements and save the resulting document.</synopsis>
-    <purpose>Shows how to make a full round-trip from a load/edit/save</purpose>
-    <usage>xpath2 &lt;xml-file&gt; &lt;xpath-expr&gt; &lt;new-value&gt;</usage>
-    <test>xpath2 test3.xml &apos;//discarded&apos; discarded &gt; xpath2.tmp &amp;&amp; diff xpath2.tmp $(srcdir)/xpath2.res</test>
-    <author>Aleksey Sanin and Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>XPath</section>
-    <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
-      <include>&lt;libxml/xpath.h&gt;</include>
-      <include>&lt;libxml/xpathInternals.h&gt;</include>
-      <include>&lt;libxml/tree.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='162' file='tree' name='xmlNodeSetContent'/>
-      <function line='127' file='tree' name='xmlDocDump'/>
-      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
-      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
-      <function line='95' file='parser' name='xmlParseFile'/>
-      <function line='123' file='xpath' name='xmlXPathFreeObject'/>
-      <function line='102' file='xpath' name='xmlXPathNewContext'/>
-      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
-      <function line='124' file='xpath' name='xmlXPathFreeContext'/>
-      <function line='41' file='parser' name='xmlInitParser'/>
-      <function line='131' file='tree' name='xmlFreeDoc'/>
-      <enum line='180' file='tree' name='XML_NAMESPACE_DECL'/>
-      <typedef line='86' file='tree' name='xmlDocPtr'/>
-    </uses>
-  </example>
-  <example filename='io2.c'>
-    <synopsis>Output to char buffer</synopsis>
-    <purpose>Demonstrate the use of xmlDocDumpMemory to output document to a character buffer</purpose>
-    <usage>io2</usage>
-    <test>io2 &gt; io2.tmp &amp;&amp; diff io2.tmp $(srcdir)/io2.res</test>
-    <author>John Fleck</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>InputOutput</section>
-    <includes>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='29' file='tree' name='xmlNodeSetContent'/>
-      <function line='36' file='tree' name='xmlDocDumpFormatMemory'/>
-      <variable line='42' file='globals' name='xmlFree'/>
-      <function line='30' file='tree' name='xmlDocSetRootElement'/>
-      <typedef line='20' file='tree' name='xmlDocPtr'/>
-      <typedef line='19' file='tree' name='xmlNodePtr'/>
-      <function line='27' file='tree' name='xmlNewDoc'/>
-      <function line='28' file='tree' name='xmlNewNode'/>
-    </uses>
-  </example>
   <example filename='reader1.c'>
     <synopsis>Parse an XML file with an xmlReader</synopsis>
     <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the informations about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
@@ -233,11 +152,14 @@
     </includes>
     <uses>
       <function line='44' file='xmlstring' name='xmlStrlen'/>
+      <function line='94' file='parser' name='xmlCleanupParser'/>
       <function line='37' file='xmlreader' name='xmlTextReaderNodeType'/>
       <typedef line='59' file='xmlreader' name='xmlTextReaderPtr'/>
+      <function line='98' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='33' file='xmlreader' name='xmlTextReaderConstValue'/>
       <function line='36' file='xmlreader' name='xmlTextReaderDepth'/>
       <function line='69' file='xmlreader' name='xmlFreeTextReader'/>
+      <macro line='89' file='xmlversion' name='LIBXML_TEST_VERSION'/>
       <function line='29' file='xmlreader' name='xmlTextReaderConstName'/>
       <function line='40' file='xmlreader' name='xmlTextReaderHasValue'/>
       <function line='67' file='xmlreader' name='xmlTextReaderRead'/>
@@ -245,22 +167,33 @@
       <function line='62' file='xmlreader' name='xmlReaderForFile'/>
     </uses>
   </example>
-  <example filename='tree1.c'>
-    <synopsis>Navigates a tree to print element names</synopsis>
-    <purpose>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</purpose>
-    <usage>tree1 filename_or_URL</usage>
-    <test>tree1 test2.xml &gt; tree1.tmp &amp;&amp; diff tree1.tmp $(srcdir)/tree1.res</test>
-    <author>Dodji Seketeli</author>
+  <example filename='reader2.c'>
+    <synopsis>Parse and validate an XML file with an xmlReader</synopsis>
+    <purpose>Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
+    <usage>reader2 &lt;valid_xml_filename&gt;</usage>
+    <test>reader2 test2.xml &gt; reader1.tmp &amp;&amp; diff reader1.tmp $(srcdir)/reader1.res</test>
+    <author>Daniel Veillard</author>
     <copy>see Copyright for the status of this software. </copy>
-    <section>Tree</section>
+    <section>xmlReader</section>
     <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xmlreader.h&gt;</include>
     </includes>
     <uses>
-      <enum line='36' file='tree' name='XML_ELEMENT_NODE'/>
-      <function line='74' file='tree' name='xmlDocGetRootElement'/>
-      <function line='67' file='parser' name='xmlReadFile'/>
+      <function line='45' file='xmlstring' name='xmlStrlen'/>
+      <function line='38' file='xmlreader' name='xmlTextReaderNodeType'/>
+      <typedef line='60' file='xmlreader' name='xmlTextReaderPtr'/>
+      <function line='34' file='xmlreader' name='xmlTextReaderConstValue'/>
+      <enum line='70' file='parser' name='XML_PARSE_NOENT'/>
+      <function line='37' file='xmlreader' name='xmlTextReaderDepth'/>
+      <enum line='71' file='parser' name='XML_PARSE_DTDVALID'/>
+      <enum line='69' file='parser' name='XML_PARSE_DTDATTR'/>
+      <function line='84' file='xmlreader' name='xmlFreeTextReader'/>
+      <function line='30' file='xmlreader' name='xmlTextReaderConstName'/>
+      <function line='41' file='xmlreader' name='xmlTextReaderHasValue'/>
+      <function line='76' file='xmlreader' name='xmlTextReaderRead'/>
+      <function line='40' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
+      <function line='68' file='xmlreader' name='xmlReaderForFile'/>
+      <function line='81' file='xmlreader' name='xmlTextReaderIsValid'/>
     </uses>
   </example>
   <example filename='reader3.c'>
@@ -284,42 +217,6 @@
       <function line='38' file='xmlreader' name='xmlReaderForFile'/>
     </uses>
   </example>
-  <example filename='parse2.c'>
-    <synopsis>Parse and validate an XML file to a tree and free the result</synopsis>
-    <purpose>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</purpose>
-    <usage>parse2 test2.xml</usage>
-    <test>parse2 test2.xml</test>
-    <author>Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>Parsing</section>
-    <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='47' file='parser' name='xmlFreeParserCtxt'/>
-      <enum line='35' file='parser' name='XML_PARSE_DTDVALID'/>
-      <function line='29' file='parser' name='xmlNewParserCtxt'/>
-      <typedef line='25' file='tree' name='xmlParserCtxtPtr'/>
-      <function line='35' file='parser' name='xmlCtxtReadFile'/>
-    </uses>
-  </example>
-  <example filename='parse1.c'>
-    <synopsis>Parse an XML file to a tree and free it</synopsis>
-    <purpose>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</purpose>
-    <usage>parse1 test1.xml</usage>
-    <test>parse1 test1.xml</test>
-    <author>Daniel Veillard</author>
-    <copy>see Copyright for the status of this software. </copy>
-    <section>Parsing</section>
-    <includes>
-      <include>&lt;libxml/tree.h&gt;</include>
-      <include>&lt;libxml/parser.h&gt;</include>
-    </includes>
-    <uses>
-      <function line='26' file='parser' name='xmlReadFile'/>
-    </uses>
-  </example>
   <example filename='reader4.c'>
     <synopsis>Parse multiple XML files reusing an xmlReader</synopsis>
     <purpose>Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context.  (Note that the XMLReader functions require libxml2 version later than 2.6.)</purpose>
@@ -384,21 +281,124 @@
       <function line='885' file='tree' name='xmlNewDoc'/>
     </uses>
   </example>
+  <example filename='tree1.c'>
+    <synopsis>Navigates a tree to print element names</synopsis>
+    <purpose>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</purpose>
+    <usage>tree1 filename_or_URL</usage>
+    <test>tree1 test2.xml &gt; tree1.tmp &amp;&amp; diff tree1.tmp $(srcdir)/tree1.res</test>
+    <author>Dodji Seketeli</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>Tree</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <enum line='36' file='tree' name='XML_ELEMENT_NODE'/>
+      <function line='74' file='tree' name='xmlDocGetRootElement'/>
+      <function line='67' file='parser' name='xmlReadFile'/>
+    </uses>
+  </example>
+  <example filename='tree2.c'>
+    <synopsis>Creates a tree</synopsis>
+    <purpose>Shows how to create document, nodes and dump it to stdout or file.</purpose>
+    <usage>tree2 &lt;filename&gt;  -Default output: stdout</usage>
+    <test>tree2 &gt; tree2.tmp &amp;&amp; diff tree2.tmp $(srcdir)/tree2.res</test>
+    <author>Lucas Brasilino &lt;brasilino@recife.pe.gov.br&gt;</author>
+    <copy>see Copyright for the status of this software </copy>
+    <section>Tree</section>
+    <includes>
+      <include>&lt;libxml/tree.h&gt;</include>
+      <include>&lt;libxml/parser.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='74' file='tree' name='xmlNewText'/>
+      <function line='95' file='tree' name='xmlSaveFormatFileEnc'/>
+      <function line='77' file='tree' name='xmlAddChild'/>
+      <function line='40' file='tree' name='xmlDocSetRootElement'/>
+      <function line='88' file='tree' name='xmlNewProp'/>
+      <function line='87' file='tree' name='xmlNewChild'/>
+      <function line='73' file='tree' name='xmlNewNode'/>
+      <function line='45' file='tree' name='xmlCreateIntSubset'/>
+      <function line='38' file='tree' name='xmlNewDoc'/>
+    </uses>
+  </example>
+  <example filename='xpath1.c'>
+    <synopsis>Evaluate XPath expression and prints result node set.</synopsis>
+    <purpose>Shows how to evaluate XPath expression and register known namespaces in XPath context.</purpose>
+    <usage>xpath1 &lt;xml-file&gt; &lt;xpath-expr&gt; [&lt;known-ns-list&gt;]</usage>
+    <test>xpath1 test3.xml &apos;//child2&apos; &gt; xpath1.tmp &amp;&amp; diff xpath1.tmp $(srcdir)/xpath1.res</test>
+    <author>Aleksey Sanin</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>XPath</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xpath.h&gt;</include>
+      <include>&lt;libxml/xpathInternals.h&gt;</include>
+      <include>&lt;libxml/tree.h&gt;</include>
+    </includes>
+    <uses>
+      <enum line='229' file='tree' name='XML_ELEMENT_NODE'/>
+      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
+      <function line='117' file='xpath' name='xmlXPathEvalExpression'/>
+      <function line='94' file='parser' name='xmlParseFile'/>
+      <function line='186' file='xpathInternals' name='xmlXPathRegisterNs'/>
+      <function line='129' file='xpath' name='xmlXPathFreeObject'/>
+      <variable line='193' file='globals' name='xmlFree'/>
+      <typedef line='218' file='tree' name='xmlNsPtr'/>
+      <function line='101' file='xpath' name='xmlXPathNewContext'/>
+      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
+      <function line='130' file='xpath' name='xmlXPathFreeContext'/>
+      <function line='39' file='parser' name='xmlInitParser'/>
+      <function line='156' file='xmlstring' name='xmlStrdup'/>
+      <function line='180' file='xmlstring' name='xmlStrchr'/>
+      <typedef line='206' file='tree' name='xmlNodePtr'/>
+      <enum line='217' file='tree' name='XML_NAMESPACE_DECL'/>
+    </uses>
+  </example>
+  <example filename='xpath2.c'>
+    <synopsis>Load a document, locate subelements with XPath, modify said elements and save the resulting document.</synopsis>
+    <purpose>Shows how to make a full round-trip from a load/edit/save</purpose>
+    <usage>xpath2 &lt;xml-file&gt; &lt;xpath-expr&gt; &lt;new-value&gt;</usage>
+    <test>xpath2 test3.xml &apos;//discarded&apos; discarded &gt; xpath2.tmp &amp;&amp; diff xpath2.tmp $(srcdir)/xpath2.res</test>
+    <author>Aleksey Sanin and Daniel Veillard</author>
+    <copy>see Copyright for the status of this software. </copy>
+    <section>XPath</section>
+    <includes>
+      <include>&lt;libxml/parser.h&gt;</include>
+      <include>&lt;libxml/xpath.h&gt;</include>
+      <include>&lt;libxml/xpathInternals.h&gt;</include>
+      <include>&lt;libxml/tree.h&gt;</include>
+    </includes>
+    <uses>
+      <function line='162' file='tree' name='xmlNodeSetContent'/>
+      <function line='127' file='tree' name='xmlDocDump'/>
+      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
+      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
+      <function line='95' file='parser' name='xmlParseFile'/>
+      <function line='123' file='xpath' name='xmlXPathFreeObject'/>
+      <function line='102' file='xpath' name='xmlXPathNewContext'/>
+      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
+      <function line='124' file='xpath' name='xmlXPathFreeContext'/>
+      <function line='41' file='parser' name='xmlInitParser'/>
+      <enum line='180' file='tree' name='XML_NAMESPACE_DECL'/>
+    </uses>
+  </example>
   <symbols>
     <symbol name='LIBXML_TEST_VERSION'>
-      <ref filename='xpath1.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='reader2.c'/>
-      <ref filename='tree2.c'/>
       <ref filename='io1.c'/>
+      <ref filename='parse1.c'/>
+      <ref filename='parse2.c'/>
+      <ref filename='parse3.c'/>
       <ref filename='parse4.c'/>
+      <ref filename='reader1.c'/>
     </symbol>
     <symbol name='XML_DEFAULT_VERSION'>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='XML_ELEMENT_NODE'>
-      <ref filename='xpath1.c'/>
       <ref filename='tree1.c'/>
+      <ref filename='xpath1.c'/>
     </symbol>
     <symbol name='XML_NAMESPACE_DECL'>
       <ref filename='xpath1.c'/>
@@ -408,8 +408,8 @@
       <ref filename='reader2.c'/>
     </symbol>
     <symbol name='XML_PARSE_DTDVALID'>
-      <ref filename='reader2.c'/>
       <ref filename='parse2.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='XML_PARSE_NOENT'>
       <ref filename='reader2.c'/>
@@ -430,12 +430,12 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlCleanupParser'>
-      <ref filename='xpath1.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='reader2.c'/>
-      <ref filename='tree2.c'/>
       <ref filename='io1.c'/>
+      <ref filename='parse1.c'/>
+      <ref filename='parse2.c'/>
+      <ref filename='parse3.c'/>
       <ref filename='parse4.c'/>
+      <ref filename='reader1.c'/>
     </symbol>
     <symbol name='xmlCreateIntSubset'>
       <ref filename='tree2.c'/>
@@ -448,8 +448,8 @@
     </symbol>
     <symbol name='xmlDocDump'>
       <ref filename='io1.c'/>
-      <ref filename='xpath2.c'/>
       <ref filename='reader3.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlDocDumpFormatMemory'>
       <ref filename='io2.c'/>
@@ -458,41 +458,41 @@
       <ref filename='tree1.c'/>
     </symbol>
     <symbol name='xmlDocPtr'>
-      <ref filename='xpath1.c'/>
-      <ref filename='parse3.c'/>
       <ref filename='io1.c'/>
-      <ref filename='parse4.c'/>
-      <ref filename='xpath2.c'/>
       <ref filename='io2.c'/>
+      <ref filename='parse1.c'/>
+      <ref filename='parse2.c'/>
+      <ref filename='parse3.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlDocSetRootElement'>
-      <ref filename='tree2.c'/>
       <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
+      <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlFindCharEncodingHandler'>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlFree'>
-      <ref filename='xpath1.c'/>
       <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
+      <ref filename='xpath1.c'/>
     </symbol>
     <symbol name='xmlFreeDoc'>
-      <ref filename='xpath1.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='tree2.c'/>
       <ref filename='io1.c'/>
+      <ref filename='io2.c'/>
+      <ref filename='parse1.c'/>
+      <ref filename='parse2.c'/>
+      <ref filename='parse3.c'/>
       <ref filename='parse4.c'/>
-      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlFreeParserCtxt'>
-      <ref filename='parse4.c'/>
       <ref filename='parse2.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlFreeTextReader'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='reader3.c'/>
       <ref filename='reader4.c'/>
     </symbol>
@@ -507,27 +507,27 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlMemoryDump'>
-      <ref filename='xpath1.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='reader2.c'/>
-      <ref filename='tree2.c'/>
       <ref filename='io1.c'/>
+      <ref filename='parse1.c'/>
+      <ref filename='parse2.c'/>
+      <ref filename='parse3.c'/>
       <ref filename='parse4.c'/>
+      <ref filename='reader1.c'/>
     </symbol>
     <symbol name='xmlNewChild'>
       <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlNewDoc'>
-      <ref filename='tree2.c'/>
       <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
+      <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlNewDocNode'>
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlNewNode'>
-      <ref filename='tree2.c'/>
       <ref filename='io2.c'/>
+      <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlNewParserCtxt'>
       <ref filename='parse2.c'/>
@@ -551,13 +551,13 @@
       <ref filename='testWriter.c'/>
     </symbol>
     <symbol name='xmlNodePtr'>
-      <ref filename='xpath1.c'/>
       <ref filename='io2.c'/>
       <ref filename='testWriter.c'/>
+      <ref filename='xpath1.c'/>
     </symbol>
     <symbol name='xmlNodeSetContent'>
-      <ref filename='xpath2.c'/>
       <ref filename='io2.c'/>
+      <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlNsPtr'>
       <ref filename='xpath1.c'/>
@@ -570,20 +570,20 @@
       <ref filename='xpath2.c'/>
     </symbol>
     <symbol name='xmlParserCtxtPtr'>
-      <ref filename='parse4.c'/>
       <ref filename='parse2.c'/>
+      <ref filename='parse4.c'/>
     </symbol>
     <symbol name='xmlReadFile'>
-      <ref filename='tree1.c'/>
       <ref filename='parse1.c'/>
+      <ref filename='tree1.c'/>
     </symbol>
     <symbol name='xmlReadMemory'>
-      <ref filename='parse3.c'/>
       <ref filename='io1.c'/>
+      <ref filename='parse3.c'/>
     </symbol>
     <symbol name='xmlReaderForFile'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='reader3.c'/>
       <ref filename='reader4.c'/>
     </symbol>
@@ -609,52 +609,52 @@
       <ref filename='xpath1.c'/>
     </symbol>
     <symbol name='xmlStrlen'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderConstName'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderConstValue'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderCurrentDoc'>
       <ref filename='reader3.c'/>
       <ref filename='reader4.c'/>
     </symbol>
     <symbol name='xmlTextReaderDepth'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderHasValue'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderIsEmptyElement'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderIsValid'>
       <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderNodeType'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
     </symbol>
     <symbol name='xmlTextReaderPreservePattern'>
       <ref filename='reader3.c'/>
     </symbol>
     <symbol name='xmlTextReaderPtr'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='reader3.c'/>
       <ref filename='reader4.c'/>
     </symbol>
     <symbol name='xmlTextReaderRead'>
-      <ref filename='reader2.c'/>
       <ref filename='reader1.c'/>
+      <ref filename='reader2.c'/>
       <ref filename='reader3.c'/>
       <ref filename='reader4.c'/>
     </symbol>
@@ -725,22 +725,22 @@
       <example filename='io2.c'/>
     </section>
     <section name='Parsing'>
+      <example filename='parse1.c'/>
+      <example filename='parse2.c'/>
       <example filename='parse3.c'/>
       <example filename='parse4.c'/>
-      <example filename='parse2.c'/>
-      <example filename='parse1.c'/>
     </section>
     <section name='Tree'>
-      <example filename='tree2.c'/>
       <example filename='tree1.c'/>
+      <example filename='tree2.c'/>
     </section>
     <section name='XPath'>
       <example filename='xpath1.c'/>
       <example filename='xpath2.c'/>
     </section>
     <section name='xmlReader'>
-      <example filename='reader2.c'/>
       <example filename='reader1.c'/>
+      <example filename='reader2.c'/>
       <example filename='reader3.c'/>
       <example filename='reader4.c'/>
     </section>
diff --git a/doc/examples/index.py b/doc/examples/index.py
index 7e0efaa..ac44ec5 100755
--- a/doc/examples/index.py
+++ b/doc/examples/index.py
@@ -235,7 +235,7 @@
 rebuild: examples.xml index.html
 .PHONY: rebuild
 
-examples.xml: index.py $(noinst_PROGRAMS:=.c)
+examples.xml: index.py $(check_PROGRAMS:=.c)
 	cd $(srcdir) && $(PYTHON) index.py
 	$(MAKE) Makefile
 
@@ -259,20 +259,21 @@
     for extra in extras:
         EXTRA_DIST = EXTRA_DIST + " \\\n\t" + extra
     Makefile = Makefile + "EXTRA_DIST =%s\n\n" % (EXTRA_DIST)
-    noinst_PROGRAMS=""
+    check_PROGRAMS=""
     for example in examples:
-        noinst_PROGRAMS = noinst_PROGRAMS + " \\\n\t" + example
-    Makefile = Makefile + "noinst_PROGRAMS =%s\n\n" % (noinst_PROGRAMS)
+        check_PROGRAMS = check_PROGRAMS + " \\\n\t" + example
+    Makefile = Makefile + "check_PROGRAMS =%s\n\n" % (check_PROGRAMS)
     for example in examples:
         Makefile = Makefile + "%s_SOURCES = %s.c\n\n" % (example, example)
     Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind' tests\n\n"
-    Makefile = Makefile + "tests: $(noinst_PROGRAMS)\n"
-    Makefile = Makefile + "\ttest -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .\n"
+    Makefile = Makefile + "tests: $(check_PROGRAMS)\n"
+    Makefile = Makefile + "\t@test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .\n"
     Makefile = Makefile + "\t@(echo '## examples regression tests')\n"
     Makefile = Makefile + "\t@(echo > .memdump)\n"
     for test in tests:
-        Makefile = Makefile + "\t$(CHECKER) %s\n" % (test)
+        Makefile = Makefile + "\t@$(CHECKER) %s\n" % (test)
         Makefile = Makefile + '\t@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0\n'
+    Makefile = Makefile + "\t@rm *.tmp\n"
     try:
 	old = open("Makefile.am", "r").read()
 	if old != Makefile:
@@ -302,7 +303,7 @@
     output = open("examples.xml", "w")
     output.write("<examples>\n")
 
-    for file in glob.glob('*.c'):
+    for file in sorted(glob.glob('*.c')):
 	parse(file, output)
 	examples.append(file[:-2])
 
diff --git a/doc/examples/testWriter.c b/doc/examples/testWriter.c
index f662f76..82e8d3a 100644
--- a/doc/examples/testWriter.c
+++ b/doc/examples/testWriter.c
@@ -102,7 +102,7 @@
      * Please observe, that the input to the xmlTextWriter functions
      * HAS to be in UTF-8, even if the output XML is encoded
      * in iso-8859-1 */
-    tmp = ConvertInput("This is a comment with special chars: <äöü>",
+    tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>",
                        MY_ENCODING);
     rc = xmlTextWriterWriteComment(writer, tmp);
     if (rc < 0) {
@@ -139,7 +139,7 @@
     }
 
     /* Write a comment as child of ORDER */
-    tmp = ConvertInput("<äöü>", MY_ENCODING);
+    tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING);
     rc = xmlTextWriterWriteFormatComment(writer,
 		     "This is another comment with special chars: %s",
 		     tmp);
@@ -177,7 +177,7 @@
     }
 
     /* Write an element named "NAME_1" as child of HEADER. */
-    tmp = ConvertInput("Müller", MY_ENCODING);
+    tmp = ConvertInput("M\xFCller", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp);
     if (rc < 0) {
         printf
@@ -187,7 +187,7 @@
     if (tmp != NULL) xmlFree(tmp);
 
     /* Write an element named "NAME_2" as child of HEADER. */
-    tmp = ConvertInput("Jörg", MY_ENCODING);
+    tmp = ConvertInput("J\xF6rg", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp);
     if (rc < 0) {
         printf
@@ -381,7 +381,7 @@
      * Please observe, that the input to the xmlTextWriter functions
      * HAS to be in UTF-8, even if the output XML is encoded
      * in iso-8859-1 */
-    tmp = ConvertInput("This is a comment with special chars: <äöü>",
+    tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>",
                        MY_ENCODING);
     rc = xmlTextWriterWriteComment(writer, tmp);
     if (rc < 0) {
@@ -418,7 +418,7 @@
     }
 
     /* Write a comment as child of ORDER */
-    tmp = ConvertInput("<äöü>", MY_ENCODING);
+    tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING);
     rc = xmlTextWriterWriteFormatComment(writer,
 		     "This is another comment with special chars: %s",
                                          tmp);
@@ -456,7 +456,7 @@
     }
 
     /* Write an element named "NAME_1" as child of HEADER. */
-    tmp = ConvertInput("Müller", MY_ENCODING);
+    tmp = ConvertInput("M\xFCller", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp);
     if (rc < 0) {
         printf
@@ -466,7 +466,7 @@
     if (tmp != NULL) xmlFree(tmp);
 
     /* Write an element named "NAME_2" as child of HEADER. */
-    tmp = ConvertInput("Jörg", MY_ENCODING);
+    tmp = ConvertInput("J\xF6rg", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp);
 
     if (rc < 0) {
@@ -656,7 +656,7 @@
      * Please observe, that the input to the xmlTextWriter functions
      * HAS to be in UTF-8, even if the output XML is encoded
      * in iso-8859-1 */
-    tmp = ConvertInput("This is a comment with special chars: <äöü>",
+    tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>",
                        MY_ENCODING);
     rc = xmlTextWriterWriteComment(writer, tmp);
     if (rc < 0) {
@@ -689,7 +689,7 @@
     }
 
     /* Write a comment as child of ORDER */
-    tmp = ConvertInput("<äöü>", MY_ENCODING);
+    tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING);
     rc = xmlTextWriterWriteFormatComment(writer,
 		 "This is another comment with special chars: %s",
 		                         tmp);
@@ -726,7 +726,7 @@
     }
 
     /* Write an element named "NAME_1" as child of HEADER. */
-    tmp = ConvertInput("Müller", MY_ENCODING);
+    tmp = ConvertInput("M\xFCller", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp);
     if (rc < 0) {
         printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
@@ -735,7 +735,7 @@
     if (tmp != NULL) xmlFree(tmp);
 
     /* Write an element named "NAME_2" as child of HEADER. */
-    tmp = ConvertInput("Jörg", MY_ENCODING);
+    tmp = ConvertInput("J\xF6rg", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp);
     if (rc < 0) {
         printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
@@ -920,7 +920,7 @@
      * Please observe, that the input to the xmlTextWriter functions
      * HAS to be in UTF-8, even if the output XML is encoded
      * in iso-8859-1 */
-    tmp = ConvertInput("This is a comment with special chars: <äöü>",
+    tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>",
                        MY_ENCODING);
     rc = xmlTextWriterWriteComment(writer, tmp);
     if (rc < 0) {
@@ -955,7 +955,7 @@
     }
 
     /* Write a comment as child of ORDER */
-    tmp = ConvertInput("<äöü>", MY_ENCODING);
+    tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING);
     rc = xmlTextWriterWriteFormatComment(writer,
 			 "This is another comment with special chars: %s",
 					  tmp);
@@ -992,7 +992,7 @@
     }
 
     /* Write an element named "NAME_1" as child of HEADER. */
-    tmp = ConvertInput("Müller", MY_ENCODING);
+    tmp = ConvertInput("M\xFCller", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp);
     if (rc < 0) {
         printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
@@ -1001,7 +1001,7 @@
     if (tmp != NULL) xmlFree(tmp);
 
     /* Write an element named "NAME_2" as child of HEADER. */
-    tmp = ConvertInput("Jörg", MY_ENCODING);
+    tmp = ConvertInput("J\xF6rg", MY_ENCODING);
     rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp);
     if (rc < 0) {
         printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
diff --git a/doc/examples/tree2.c b/doc/examples/tree2.c
index 1cd1abe..6548e29 100644
--- a/doc/examples/tree2.c
+++ b/doc/examples/tree2.c
@@ -27,7 +27,6 @@
 {
     xmlDocPtr doc = NULL;       /* document pointer */
     xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */
-    xmlDtdPtr dtd = NULL;       /* DTD pointer */
     char buff[256];
     int i, j;
 
@@ -43,7 +42,7 @@
     /*
      * Creates a DTD declaration. Isn't mandatory. 
      */
-    dtd = xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd");
+    xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd");
 
     /* 
      * xmlNewChild() creates a new node, which is "attached" as child node
diff --git a/doc/html/libxml-HTMLparser.html b/doc/html/libxml-HTMLparser.html
index f5f77af..7d9d299 100644
--- a/doc/html/libxml-HTMLparser.html
+++ b/doc/html/libxml-HTMLparser.html
@@ -50,7 +50,7 @@
 <pre class="programlisting"><a href="libxml-HTMLparser.html#htmlStatus">htmlStatus</a>	<a href="#htmlNodeStatus">htmlNodeStatus</a>		(const <a href="libxml-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> node, <br />					 int legacy)</pre>
 <pre class="programlisting">int	<a href="#htmlParseCharRef">htmlParseCharRef</a>		(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)</pre>
 <pre class="programlisting">int	<a href="#htmlParseChunk">htmlParseChunk</a>			(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br />					 const char * chunk, <br />					 int size, <br />					 int terminate)</pre>
-<pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlParseDoc">htmlParseDoc</a>		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding)</pre>
+<pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlParseDoc">htmlParseDoc</a>		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding)</pre>
 <pre class="programlisting">int	<a href="#htmlParseDocument">htmlParseDocument</a>		(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)</pre>
 <pre class="programlisting">void	<a href="#htmlParseElement">htmlParseElement</a>		(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)</pre>
 <pre class="programlisting">const <a href="libxml-HTMLparser.html#htmlEntityDesc">htmlEntityDesc</a> *	<a href="#htmlParseEntityRef">htmlParseEntityRef</a>	(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br />						 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** str)</pre>
@@ -60,7 +60,7 @@
 <pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlReadFile">htmlReadFile</a>		(const char * filename, <br />					 const char * encoding, <br />					 int options)</pre>
 <pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlReadIO">htmlReadIO</a>		(<a href="libxml-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br />					 <a href="libxml-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br />					 void * ioctx, <br />					 const char * URL, <br />					 const char * encoding, <br />					 int options)</pre>
 <pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlReadMemory">htmlReadMemory</a>		(const char * buffer, <br />					 int size, <br />					 const char * URL, <br />					 const char * encoding, <br />					 int options)</pre>
-<pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlSAXParseDoc">htmlSAXParseDoc</a>		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)</pre>
+<pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlSAXParseDoc">htmlSAXParseDoc</a>		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)</pre>
 <pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	<a href="#htmlSAXParseFile">htmlSAXParseFile</a>	(const char * filename, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)</pre>
 <pre class="programlisting">const <a href="libxml-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *	<a href="#htmlTagLookup">htmlTagLookup</a>	(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * tag)</pre>
 <h2>Description</h2>
@@ -155,7 +155,7 @@
 </pre><p>parse Reference declarations [66] CharRef ::= '&amp;#' [0-9]+ ';' | '&amp;#x' [0-9a-fA-F]+ ';'</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an HTML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the value parsed (as an int)</td></tr></tbody></table></div><h3><a name="htmlParseChunk" id="htmlParseChunk"></a>Function: htmlParseChunk</h3><pre class="programlisting">int	htmlParseChunk			(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br />					 const char * chunk, <br />					 int size, <br />					 int terminate)<br />
 </pre><p>Parse a Chunk of memory</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an HTML parser context</td></tr><tr><td><span class="term"><i><tt>chunk</tt></i>:</span></td><td>an char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size in byte of the chunk</td></tr><tr><td><span class="term"><i><tt>terminate</tt></i>:</span></td><td>last chunk indicator</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>zero if no error, the <a href="libxml-xmlerror.html#xmlParserErrors">xmlParserErrors</a> otherwise.</td></tr></tbody></table></div><h3><a name="htmlParseDoc" id="htmlParseDoc"></a>Function: htmlParseDoc</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlParseDoc		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an HTML parser context</td></tr><tr><td><span class="term"><i><tt>chunk</tt></i>:</span></td><td>an char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size in byte of the chunk</td></tr><tr><td><span class="term"><i><tt>terminate</tt></i>:</span></td><td>last chunk indicator</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>zero if no error, the <a href="libxml-xmlerror.html#xmlParserErrors">xmlParserErrors</a> otherwise.</td></tr></tbody></table></div><h3><a name="htmlParseDoc" id="htmlParseDoc"></a>Function: htmlParseDoc</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlParseDoc		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding)<br />
 </pre><p>parse an HTML in-memory document and build a tree.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>a pointer to an array of <a href="libxml-xmlstring.html#xmlChar">xmlChar</a></td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>a free form C string describing the HTML document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div><h3><a name="htmlParseDocument" id="htmlParseDocument"></a>Function: htmlParseDocument</h3><pre class="programlisting">int	htmlParseDocument		(<a href="libxml-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)<br />
 </pre><p>parse an HTML document (and build a tree if using the standard SAX interface).</p>
@@ -175,7 +175,7 @@
 </pre><p>parse an HTML document from I/O functions and source and build a tree.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ioread</tt></i>:</span></td><td>an I/O read function</td></tr><tr><td><span class="term"><i><tt>ioclose</tt></i>:</span></td><td>an I/O close function</td></tr><tr><td><span class="term"><i><tt>ioctx</tt></i>:</span></td><td>an I/O handler</td></tr><tr><td><span class="term"><i><tt>URL</tt></i>:</span></td><td>the base URL to use for the document</td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>the document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of htmlParserOption(s)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div><h3><a name="htmlReadMemory" id="htmlReadMemory"></a>Function: htmlReadMemory</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlReadMemory		(const char * buffer, <br />					 int size, <br />					 const char * URL, <br />					 const char * encoding, <br />					 int options)<br />
 </pre><p>parse an XML in-memory document and build a tree.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>buffer</tt></i>:</span></td><td>a pointer to a char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the array</td></tr><tr><td><span class="term"><i><tt>URL</tt></i>:</span></td><td>the base URL to use for the document</td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>the document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of htmlParserOption(s)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div><h3><a name="htmlSAXParseDoc" id="htmlSAXParseDoc"></a>Function: htmlSAXParseDoc</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlSAXParseDoc		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>buffer</tt></i>:</span></td><td>a pointer to a char array</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the array</td></tr><tr><td><span class="term"><i><tt>URL</tt></i>:</span></td><td>the base URL to use for the document</td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>the document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of htmlParserOption(s)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree</td></tr></tbody></table></div><h3><a name="htmlSAXParseDoc" id="htmlSAXParseDoc"></a>Function: htmlSAXParseDoc</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlSAXParseDoc		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)<br />
 </pre><p>Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>a pointer to an array of <a href="libxml-xmlstring.html#xmlChar">xmlChar</a></td></tr><tr><td><span class="term"><i><tt>encoding</tt></i>:</span></td><td>a free form C string describing the HTML document encoding, or NULL</td></tr><tr><td><span class="term"><i><tt>sax</tt></i>:</span></td><td>the SAX handler block</td></tr><tr><td><span class="term"><i><tt>userData</tt></i>:</span></td><td>if using SAX, this pointer will be provided on callbacks.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the resulting document tree unless SAX is NULL or the document is not well formed.</td></tr></tbody></table></div><h3><a name="htmlSAXParseFile" id="htmlSAXParseFile"></a>Function: htmlSAXParseFile</h3><pre class="programlisting"><a href="libxml-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>	htmlSAXParseFile	(const char * filename, <br />					 const char * encoding, <br />					 <a href="libxml-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br />					 void * userData)<br />
 </pre><p>parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
diff --git a/doc/html/libxml-dict.html b/doc/html/libxml-dict.html
index 74e243b..0854d29 100644
--- a/doc/html/libxml-dict.html
+++ b/doc/html/libxml-dict.html
@@ -33,9 +33,9 @@
 </pre><p>Free the dictionary mutex. Do not call unless sure the library is not in use anymore !</p>
 <h3><a name="xmlDictCreate" id="xmlDictCreate"></a>Function: xmlDictCreate</h3><pre class="programlisting"><a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreate		(void)<br />
 </pre><p>Create a new dictionary</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occured.</td></tr></tbody></table></div><h3><a name="xmlDictCreateSub" id="xmlDictCreateSub"></a>Function: xmlDictCreateSub</h3><pre class="programlisting"><a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreateSub	(<a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> sub)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occurred.</td></tr></tbody></table></div><h3><a name="xmlDictCreateSub" id="xmlDictCreateSub"></a>Function: xmlDictCreateSub</h3><pre class="programlisting"><a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreateSub	(<a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> sub)<br />
 </pre><p>Create a new dictionary, inheriting strings from the read-only dictionary @sub. On lookup, strings are first searched in the new dictionary, then in @sub, and if not found are created in the new dictionary.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>sub</tt></i>:</span></td><td>an existing dictionary</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occured.</td></tr></tbody></table></div><h3><a name="xmlDictExists" id="xmlDictExists"></a>Function: xmlDictExists</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictExists		(<a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 int len)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>sub</tt></i>:</span></td><td>an existing dictionary</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created dictionary, or NULL if an error occurred.</td></tr></tbody></table></div><h3><a name="xmlDictExists" id="xmlDictExists"></a>Function: xmlDictExists</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictExists		(<a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 int len)<br />
 </pre><p>Check if the @name exists in the dictionary @dict.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>the dictionary</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name of the userdata</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the length of the name, if -1 it is recomputed</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the internal copy of the name or NULL if not found.</td></tr></tbody></table></div><h3><a name="xmlDictFree" id="xmlDictFree"></a>Function: xmlDictFree</h3><pre class="programlisting">void	xmlDictFree			(<a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br />
 </pre><p>Free the hash @dict and its contents. The userdata is deallocated with @f if provided.</p>
diff --git a/doc/html/libxml-hash.html b/doc/html/libxml-hash.html
index 922e3f1..f3e4a4a 100644
--- a/doc/html/libxml-hash.html
+++ b/doc/html/libxml-hash.html
@@ -66,9 +66,9 @@
 </pre><p>Scan the hash @table and applied @f to each value.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>table</tt></i>:</span></td><td>the hash table</td></tr><tr><td><span class="term"><i><tt>f</tt></i>:</span></td><td>the copier function for items in the hash</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the new table or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlHashCreate" id="xmlHashCreate"></a>Function: xmlHashCreate</h3><pre class="programlisting"><a href="libxml-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>	xmlHashCreate		(int size)<br />
 </pre><p>Create a new xmlHashTablePtr.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occured.</td></tr></tbody></table></div><h3><a name="xmlHashCreateDict" id="xmlHashCreateDict"></a>Function: xmlHashCreateDict</h3><pre class="programlisting"><a href="libxml-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>	xmlHashCreateDict	(int size, <br />					 <a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occurred.</td></tr></tbody></table></div><h3><a name="xmlHashCreateDict" id="xmlHashCreateDict"></a>Function: xmlHashCreateDict</h3><pre class="programlisting"><a href="libxml-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>	xmlHashCreateDict	(int size, <br />					 <a href="libxml-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br />
 </pre><p>Create a new <a href="libxml-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> which will use @dict as the internal dictionary</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>a dictionary to use for the hash</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occured.</td></tr></tbody></table></div><h3><a name="xmlHashDeallocator" id="xmlHashDeallocator"></a>Function type: xmlHashDeallocator</h3><pre class="programlisting">Function type: xmlHashDeallocator
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size of the hash table</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>a dictionary to use for the hash</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object, or NULL if an error occurred.</td></tr></tbody></table></div><h3><a name="xmlHashDeallocator" id="xmlHashDeallocator"></a>Function type: xmlHashDeallocator</h3><pre class="programlisting">Function type: xmlHashDeallocator
 void	xmlHashDeallocator		(void * payload, <br />					 <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name)
 </pre><p>Callback to free data from a hash.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>payload</tt></i>:</span></td><td>the data in the hash</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name associated</td></tr></tbody></table></div><br />
 <h3><a name="xmlHashFree" id="xmlHashFree"></a>Function: xmlHashFree</h3><pre class="programlisting">void	xmlHashFree			(<a href="libxml-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br />					 <a href="libxml-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br />
diff --git a/doc/html/libxml-list.html b/doc/html/libxml-list.html
index 33e60d1..f6b6c5b 100644
--- a/doc/html/libxml-list.html
+++ b/doc/html/libxml-list.html
@@ -98,9 +98,9 @@
 </pre><p>Remove the all instance associated to data in the list</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the number of deallocation, or 0 if not found</td></tr></tbody></table></div><h3><a name="xmlListRemoveFirst" id="xmlListRemoveFirst"></a>Function: xmlListRemoveFirst</h3><pre class="programlisting">int	xmlListRemoveFirst		(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l, <br />					 void * data)<br />
 </pre><p>Remove the first instance associated to data in the list</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occured, or 0 if not found</td></tr></tbody></table></div><h3><a name="xmlListRemoveLast" id="xmlListRemoveLast"></a>Function: xmlListRemoveLast</h3><pre class="programlisting">int	xmlListRemoveLast		(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l, <br />					 void * data)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occurred, or 0 if not found</td></tr></tbody></table></div><h3><a name="xmlListRemoveLast" id="xmlListRemoveLast"></a>Function: xmlListRemoveLast</h3><pre class="programlisting">int	xmlListRemoveLast		(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l, <br />					 void * data)<br />
 </pre><p>Remove the last instance associated to data in the list</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occured, or 0 if not found</td></tr></tbody></table></div><h3><a name="xmlListReverse" id="xmlListReverse"></a>Function: xmlListReverse</h3><pre class="programlisting">void	xmlListReverse			(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr><tr><td><span class="term"><i><tt>data</tt></i>:</span></td><td>list data</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if a deallocation occurred, or 0 if not found</td></tr></tbody></table></div><h3><a name="xmlListReverse" id="xmlListReverse"></a>Function: xmlListReverse</h3><pre class="programlisting">void	xmlListReverse			(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l)<br />
 </pre><p>Reverse the order of the elements in the list</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>l</tt></i>:</span></td><td>a list</td></tr></tbody></table></div><h3><a name="xmlListReverseSearch" id="xmlListReverseSearch"></a>Function: xmlListReverseSearch</h3><pre class="programlisting">void *	xmlListReverseSearch		(<a href="libxml-list.html#xmlListPtr">xmlListPtr</a> l, <br />					 void * data)<br />
 </pre><p>Search the list in reverse order for an existing value of @data</p>
diff --git a/doc/html/libxml-schemasInternals.html b/doc/html/libxml-schemasInternals.html
index db4a5a1..954f0d2 100644
--- a/doc/html/libxml-schemasInternals.html
+++ b/doc/html/libxml-schemasInternals.html
@@ -10,7 +10,7 @@
 </style><style type="text/css">
       div.deprecated pre.programlisting {border-style: double;border-color:red}
       pre.programlisting {border-style: double;background: #EECFA1}
-    </style><title>Module schemasInternals from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module schemasInternals from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://opencsw.org/packages/libxml2">Solaris binaries</a></li><li><a href="http://www.explain.com.au/oss/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://lxml.de/">lxml Python bindings</a></li><li><a href="http://cpan.uwinnipeg.ca/dist/XML-LibXML">Perl bindings</a></li><li><a href="http://libxmlplusplus.sourceforge.net/">C++ bindings</a></li><li><a href="http://www.zend.com/php5/articles/php5-xmlphp.php#Heading4">PHP bindings</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://libxml.rubyforge.org/">Ruby bindings</a></li><li><a href="http://tclxml.sourceforge.net/">Tcl bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-relaxng.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-relaxng.html">relaxng</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-schematron.html">schematron</a></th><td><a accesskey="n" href="libxml-schematron.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not garanteed to be API or ABI stable ! </p><h2>Table of Contents</h2><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_LAX">XML_SCHEMAS_ANYATTR_LAX</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_SKIP">XML_SCHEMAS_ANYATTR_SKIP</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_STRICT">XML_SCHEMAS_ANYATTR_STRICT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_LAX">XML_SCHEMAS_ANY_LAX</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_SKIP">XML_SCHEMAS_ANY_SKIP</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_STRICT">XML_SCHEMAS_ANY_STRICT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_GLOBAL">XML_SCHEMAS_ATTRGROUP_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_HAS_REFS">XML_SCHEMAS_ATTRGROUP_HAS_REFS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_MARKED">XML_SCHEMAS_ATTRGROUP_MARKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_REDEFINED">XML_SCHEMAS_ATTRGROUP_REDEFINED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED">XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_FIXED">XML_SCHEMAS_ATTR_FIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_GLOBAL">XML_SCHEMAS_ATTR_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_INTERNAL_RESOLVED">XML_SCHEMAS_ATTR_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_NSDEFAULT">XML_SCHEMAS_ATTR_NSDEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_OPTIONAL">XML_SCHEMAS_ATTR_USE_OPTIONAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_PROHIBITED">XML_SCHEMAS_ATTR_USE_PROHIBITED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_REQUIRED">XML_SCHEMAS_ATTR_USE_REQUIRED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION">XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION">XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION">XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_ABSTRACT">XML_SCHEMAS_ELEM_ABSTRACT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_ABSENT">XML_SCHEMAS_ELEM_BLOCK_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_EXTENSION">XML_SCHEMAS_ELEM_BLOCK_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_RESTRICTION">XML_SCHEMAS_ELEM_BLOCK_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION">XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_CIRCULAR">XML_SCHEMAS_ELEM_CIRCULAR</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_DEFAULT">XML_SCHEMAS_ELEM_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_ABSENT">XML_SCHEMAS_ELEM_FINAL_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_EXTENSION">XML_SCHEMAS_ELEM_FINAL_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_RESTRICTION">XML_SCHEMAS_ELEM_FINAL_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FIXED">XML_SCHEMAS_ELEM_FIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_GLOBAL">XML_SCHEMAS_ELEM_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_INTERNAL_CHECKED">XML_SCHEMAS_ELEM_INTERNAL_CHECKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_INTERNAL_RESOLVED">XML_SCHEMAS_ELEM_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_NILLABLE">XML_SCHEMAS_ELEM_NILLABLE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_NSDEFAULT">XML_SCHEMAS_ELEM_NSDEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_REF">XML_SCHEMAS_ELEM_REF</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD">XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_TOPLEVEL">XML_SCHEMAS_ELEM_TOPLEVEL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_COLLAPSE">XML_SCHEMAS_FACET_COLLAPSE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_PRESERVE">XML_SCHEMAS_FACET_PRESERVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_REPLACE">XML_SCHEMAS_FACET_REPLACE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_UNKNOWN">XML_SCHEMAS_FACET_UNKNOWN</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_EXTENSION">XML_SCHEMAS_FINAL_DEFAULT_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_LIST">XML_SCHEMAS_FINAL_DEFAULT_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION">XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_UNION">XML_SCHEMAS_FINAL_DEFAULT_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_INCLUDING_CONVERT_NS">XML_SCHEMAS_INCLUDING_CONVERT_NS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_QUALIF_ATTR">XML_SCHEMAS_QUALIF_ATTR</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_QUALIF_ELEM">XML_SCHEMAS_QUALIF_ELEM</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_ABSTRACT">XML_SCHEMAS_TYPE_ABSTRACT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_DEFAULT">XML_SCHEMAS_TYPE_BLOCK_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_EXTENSION">XML_SCHEMAS_TYPE_BLOCK_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_RESTRICTION">XML_SCHEMAS_TYPE_BLOCK_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE">XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION">XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION">XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FACETSNEEDVALUE">XML_SCHEMAS_TYPE_FACETSNEEDVALUE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_DEFAULT">XML_SCHEMAS_TYPE_FINAL_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_EXTENSION">XML_SCHEMAS_TYPE_FINAL_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_LIST">XML_SCHEMAS_TYPE_FINAL_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_RESTRICTION">XML_SCHEMAS_TYPE_FINAL_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_UNION">XML_SCHEMAS_TYPE_FINAL_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FIXUP_1">XML_SCHEMAS_TYPE_FIXUP_1</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_GLOBAL">XML_SCHEMAS_TYPE_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_HAS_FACETS">XML_SCHEMAS_TYPE_HAS_FACETS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_INTERNAL_INVALID">XML_SCHEMAS_TYPE_INTERNAL_INVALID</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_INTERNAL_RESOLVED">XML_SCHEMAS_TYPE_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_MARKED">XML_SCHEMAS_TYPE_MARKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_MIXED">XML_SCHEMAS_TYPE_MIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_NORMVALUENEEDED">XML_SCHEMAS_TYPE_NORMVALUENEEDED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD">XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_REDEFINED">XML_SCHEMAS_TYPE_REDEFINED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_ABSENT">XML_SCHEMAS_TYPE_VARIETY_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_ATOMIC">XML_SCHEMAS_TYPE_VARIETY_ATOMIC</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_LIST">XML_SCHEMAS_TYPE_VARIETY_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_UNION">XML_SCHEMAS_TYPE_VARIETY_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE">XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE">XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_REPLACE">XML_SCHEMAS_TYPE_WHITESPACE_REPLACE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_WILDCARD_COMPLETE">XML_SCHEMAS_WILDCARD_COMPLETE</a></pre><pre class="programlisting">Structure <a href="#xmlSchemaAnnot">xmlSchemaAnnot</a><br />struct _xmlSchemaAnnot
+    </style><title>Module schemasInternals from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module schemasInternals from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://opencsw.org/packages/libxml2">Solaris binaries</a></li><li><a href="http://www.explain.com.au/oss/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://lxml.de/">lxml Python bindings</a></li><li><a href="http://cpan.uwinnipeg.ca/dist/XML-LibXML">Perl bindings</a></li><li><a href="http://libxmlplusplus.sourceforge.net/">C++ bindings</a></li><li><a href="http://www.zend.com/php5/articles/php5-xmlphp.php#Heading4">PHP bindings</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://libxml.rubyforge.org/">Ruby bindings</a></li><li><a href="http://tclxml.sourceforge.net/">Tcl bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-relaxng.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-relaxng.html">relaxng</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-schematron.html">schematron</a></th><td><a accesskey="n" href="libxml-schematron.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not guaranteed to be API or ABI stable ! </p><h2>Table of Contents</h2><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_LAX">XML_SCHEMAS_ANYATTR_LAX</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_SKIP">XML_SCHEMAS_ANYATTR_SKIP</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANYATTR_STRICT">XML_SCHEMAS_ANYATTR_STRICT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_LAX">XML_SCHEMAS_ANY_LAX</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_SKIP">XML_SCHEMAS_ANY_SKIP</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ANY_STRICT">XML_SCHEMAS_ANY_STRICT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_GLOBAL">XML_SCHEMAS_ATTRGROUP_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_HAS_REFS">XML_SCHEMAS_ATTRGROUP_HAS_REFS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_MARKED">XML_SCHEMAS_ATTRGROUP_MARKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_REDEFINED">XML_SCHEMAS_ATTRGROUP_REDEFINED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED">XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_FIXED">XML_SCHEMAS_ATTR_FIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_GLOBAL">XML_SCHEMAS_ATTR_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_INTERNAL_RESOLVED">XML_SCHEMAS_ATTR_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_NSDEFAULT">XML_SCHEMAS_ATTR_NSDEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_OPTIONAL">XML_SCHEMAS_ATTR_USE_OPTIONAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_PROHIBITED">XML_SCHEMAS_ATTR_USE_PROHIBITED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ATTR_USE_REQUIRED">XML_SCHEMAS_ATTR_USE_REQUIRED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION">XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION">XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION">XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_ABSTRACT">XML_SCHEMAS_ELEM_ABSTRACT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_ABSENT">XML_SCHEMAS_ELEM_BLOCK_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_EXTENSION">XML_SCHEMAS_ELEM_BLOCK_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_RESTRICTION">XML_SCHEMAS_ELEM_BLOCK_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION">XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_CIRCULAR">XML_SCHEMAS_ELEM_CIRCULAR</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_DEFAULT">XML_SCHEMAS_ELEM_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_ABSENT">XML_SCHEMAS_ELEM_FINAL_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_EXTENSION">XML_SCHEMAS_ELEM_FINAL_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FINAL_RESTRICTION">XML_SCHEMAS_ELEM_FINAL_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_FIXED">XML_SCHEMAS_ELEM_FIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_GLOBAL">XML_SCHEMAS_ELEM_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_INTERNAL_CHECKED">XML_SCHEMAS_ELEM_INTERNAL_CHECKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_INTERNAL_RESOLVED">XML_SCHEMAS_ELEM_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_NILLABLE">XML_SCHEMAS_ELEM_NILLABLE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_NSDEFAULT">XML_SCHEMAS_ELEM_NSDEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_REF">XML_SCHEMAS_ELEM_REF</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD">XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_ELEM_TOPLEVEL">XML_SCHEMAS_ELEM_TOPLEVEL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_COLLAPSE">XML_SCHEMAS_FACET_COLLAPSE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_PRESERVE">XML_SCHEMAS_FACET_PRESERVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_REPLACE">XML_SCHEMAS_FACET_REPLACE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FACET_UNKNOWN">XML_SCHEMAS_FACET_UNKNOWN</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_EXTENSION">XML_SCHEMAS_FINAL_DEFAULT_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_LIST">XML_SCHEMAS_FINAL_DEFAULT_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION">XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_FINAL_DEFAULT_UNION">XML_SCHEMAS_FINAL_DEFAULT_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_INCLUDING_CONVERT_NS">XML_SCHEMAS_INCLUDING_CONVERT_NS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_QUALIF_ATTR">XML_SCHEMAS_QUALIF_ATTR</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_QUALIF_ELEM">XML_SCHEMAS_QUALIF_ELEM</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_ABSTRACT">XML_SCHEMAS_TYPE_ABSTRACT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_DEFAULT">XML_SCHEMAS_TYPE_BLOCK_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_EXTENSION">XML_SCHEMAS_TYPE_BLOCK_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BLOCK_RESTRICTION">XML_SCHEMAS_TYPE_BLOCK_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE">XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION">XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION">XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FACETSNEEDVALUE">XML_SCHEMAS_TYPE_FACETSNEEDVALUE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_DEFAULT">XML_SCHEMAS_TYPE_FINAL_DEFAULT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_EXTENSION">XML_SCHEMAS_TYPE_FINAL_EXTENSION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_LIST">XML_SCHEMAS_TYPE_FINAL_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_RESTRICTION">XML_SCHEMAS_TYPE_FINAL_RESTRICTION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FINAL_UNION">XML_SCHEMAS_TYPE_FINAL_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_FIXUP_1">XML_SCHEMAS_TYPE_FIXUP_1</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_GLOBAL">XML_SCHEMAS_TYPE_GLOBAL</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_HAS_FACETS">XML_SCHEMAS_TYPE_HAS_FACETS</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_INTERNAL_INVALID">XML_SCHEMAS_TYPE_INTERNAL_INVALID</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_INTERNAL_RESOLVED">XML_SCHEMAS_TYPE_INTERNAL_RESOLVED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_MARKED">XML_SCHEMAS_TYPE_MARKED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_MIXED">XML_SCHEMAS_TYPE_MIXED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_NORMVALUENEEDED">XML_SCHEMAS_TYPE_NORMVALUENEEDED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD">XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_REDEFINED">XML_SCHEMAS_TYPE_REDEFINED</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_ABSENT">XML_SCHEMAS_TYPE_VARIETY_ABSENT</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_ATOMIC">XML_SCHEMAS_TYPE_VARIETY_ATOMIC</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_LIST">XML_SCHEMAS_TYPE_VARIETY_LIST</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_VARIETY_UNION">XML_SCHEMAS_TYPE_VARIETY_UNION</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE">XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE">XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_TYPE_WHITESPACE_REPLACE">XML_SCHEMAS_TYPE_WHITESPACE_REPLACE</a></pre><pre class="programlisting">#define <a href="#XML_SCHEMAS_WILDCARD_COMPLETE">XML_SCHEMAS_WILDCARD_COMPLETE</a></pre><pre class="programlisting">Structure <a href="#xmlSchemaAnnot">xmlSchemaAnnot</a><br />struct _xmlSchemaAnnot
 </pre><pre class="programlisting">Typedef <a href="libxml-schemasInternals.html#xmlSchemaAnnot">xmlSchemaAnnot</a> * <a name="xmlSchemaAnnotPtr" id="xmlSchemaAnnotPtr">xmlSchemaAnnotPtr</a>
 </pre><pre class="programlisting">Structure <a href="#xmlSchemaAttribute">xmlSchemaAttribute</a><br />struct _xmlSchemaAttribute
 </pre><pre class="programlisting">Structure <a href="#xmlSchemaAttributeGroup">xmlSchemaAttributeGroup</a><br />struct _xmlSchemaAttributeGroup
diff --git a/doc/html/libxml-tree.html b/doc/html/libxml-tree.html
index d95872d..09e7bdc 100644
--- a/doc/html/libxml-tree.html
+++ b/doc/html/libxml-tree.html
@@ -964,7 +964,7 @@
 </pre><p>update all nodes under the tree to point to the right document</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>tree</tt></i>:</span></td><td>the top element</td></tr><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>the document</td></tr></tbody></table></div><h3><a name="xmlSplitQName2" id="xmlSplitQName2"></a>Function: xmlSplitQName2</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlSplitQName2		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** prefix)<br />
 </pre><p>parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the full QName</td></tr><tr><td><span class="term"><i><tt>prefix</tt></i>:</span></td><td>a <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> **</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if not a QName, otherwise the local part, and prefix is updated to get the Prefix if any.</td></tr></tbody></table></div><h3><a name="xmlSplitQName3" id="xmlSplitQName3"></a>Function: xmlSplitQName3</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlSplitQName3		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 int * len)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the full QName</td></tr><tr><td><span class="term"><i><tt>prefix</tt></i>:</span></td><td>a <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> **</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if the name doesn't have a prefix. Otherwise, returns the local part, and prefix is updated to get the Prefix. Both the return value and the prefix must be freed by the caller.</td></tr></tbody></table></div><h3><a name="xmlSplitQName3" id="xmlSplitQName3"></a>Function: xmlSplitQName3</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlSplitQName3		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 int * len)<br />
 </pre><p>parse an XML qualified name string,i</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the full QName</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>an int *</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if it is not a Qualified Name, otherwise, update len with the length in byte of the prefix and return a pointer to the start of the name without the prefix</td></tr></tbody></table></div><h3><a name="xmlStringGetNodeList" id="xmlStringGetNodeList"></a>Function: xmlStringGetNodeList</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlStringGetNodeList	(const <a href="libxml-tree.html#xmlDoc">xmlDoc</a> * doc, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * value)<br />
 </pre><p>Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.</p>
diff --git a/doc/html/libxml-xmlerror.html b/doc/html/libxml-xmlerror.html
index 5c3a104..2550ac0 100644
--- a/doc/html/libxml-xmlerror.html
+++ b/doc/html/libxml-xmlerror.html
@@ -832,14 +832,14 @@
 </pre><p>Save the original error to the new place.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>from</tt></i>:</span></td><td>a source error</td></tr><tr><td><span class="term"><i><tt>to</tt></i>:</span></td><td>a target error</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success and -1 in case of error.</td></tr></tbody></table></div><h3><a name="xmlCtxtGetLastError" id="xmlCtxtGetLastError"></a>Function: xmlCtxtGetLastError</h3><pre class="programlisting"><a href="libxml-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>	xmlCtxtGetLastError	(void * ctx)<br />
 </pre><p>Get the last parsing error registered.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occured or a pointer to the error</td></tr></tbody></table></div><h3><a name="xmlCtxtResetLastError" id="xmlCtxtResetLastError"></a>Function: xmlCtxtResetLastError</h3><pre class="programlisting">void	xmlCtxtResetLastError		(void * ctx)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occurred or a pointer to the error</td></tr></tbody></table></div><h3><a name="xmlCtxtResetLastError" id="xmlCtxtResetLastError"></a>Function: xmlCtxtResetLastError</h3><pre class="programlisting">void	xmlCtxtResetLastError		(void * ctx)<br />
 </pre><p>Cleanup the last global error registered. For parsing error this does not change the well-formedness result.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr></tbody></table></div><h3><a name="xmlGenericErrorFunc" id="xmlGenericErrorFunc"></a>Function type: xmlGenericErrorFunc</h3><pre class="programlisting">Function type: xmlGenericErrorFunc
 void	xmlGenericErrorFunc		(void * ctx, <br />					 const char * msg, <br />					 ... ...)
 </pre><p>Signature of the function to use when there is an error and no parsing or validity context available .</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>a parsing context</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message</td></tr><tr><td><span class="term"><i><tt>...</tt></i>:</span></td><td>the extra arguments of the varags to format the message</td></tr></tbody></table></div><br />
 <h3><a name="xmlGetLastError" id="xmlGetLastError"></a>Function: xmlGetLastError</h3><pre class="programlisting"><a href="libxml-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>	xmlGetLastError		(void)<br />
 </pre><p>Get the last global error registered. This is per thread if compiled with thread support.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occured or a pointer to the error</td></tr></tbody></table></div><h3><a name="xmlParserError" id="xmlParserError"></a>Function: xmlParserError</h3><pre class="programlisting">void	xmlParserError			(void * ctx, <br />					 const char * msg, <br />					 ... ...)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>NULL if no error occurred or a pointer to the error</td></tr></tbody></table></div><h3><a name="xmlParserError" id="xmlParserError"></a>Function: xmlParserError</h3><pre class="programlisting">void	xmlParserError			(void * ctx, <br />					 const char * msg, <br />					 ... ...)<br />
 </pre><p>Display and format an error messages, gives file, line, position and extra parameters.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message to display/transmit</td></tr><tr><td><span class="term"><i><tt>...</tt></i>:</span></td><td>extra parameters for the message display</td></tr></tbody></table></div><h3><a name="xmlParserPrintFileContext" id="xmlParserPrintFileContext"></a>Function: xmlParserPrintFileContext</h3><pre class="programlisting">void	xmlParserPrintFileContext	(<a href="libxml-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input)<br />
 </pre><p>Displays current context within the input content for error tracking</p>
diff --git a/doc/html/libxml-xmlreader.html b/doc/html/libxml-xmlreader.html
index f7e00fb..b9bd032 100644
--- a/doc/html/libxml-xmlreader.html
+++ b/doc/html/libxml-xmlreader.html
@@ -218,7 +218,7 @@
 </pre><p>The depth of the node in the tree.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the depth or -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderErrorFunc" id="xmlTextReaderErrorFunc"></a>Function type: xmlTextReaderErrorFunc</h3><pre class="programlisting">Function type: xmlTextReaderErrorFunc
 void	xmlTextReaderErrorFunc		(void * arg, <br />					 const char * msg, <br />					 <a href="libxml-xmlreader.html#xmlParserSeverities">xmlParserSeverities</a> severity, <br />					 <a href="libxml-xmlreader.html#xmlTextReaderLocatorPtr">xmlTextReaderLocatorPtr</a> locator)
-</pre><p>Signature of an error callback from a reader parser</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>arg</tt></i>:</span></td><td>the user argument</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message</td></tr><tr><td><span class="term"><i><tt>severity</tt></i>:</span></td><td>the severity of the error</td></tr><tr><td><span class="term"><i><tt>locator</tt></i>:</span></td><td>a locator indicating where the error occured</td></tr></tbody></table></div><br />
+</pre><p>Signature of an error callback from a reader parser</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>arg</tt></i>:</span></td><td>the user argument</td></tr><tr><td><span class="term"><i><tt>msg</tt></i>:</span></td><td>the message</td></tr><tr><td><span class="term"><i><tt>severity</tt></i>:</span></td><td>the severity of the error</td></tr><tr><td><span class="term"><i><tt>locator</tt></i>:</span></td><td>a locator indicating where the error occurred</td></tr></tbody></table></div><br />
 <h3><a name="xmlTextReaderExpand" id="xmlTextReaderExpand"></a>Function: xmlTextReaderExpand</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlTextReaderExpand	(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
 </pre><p>Reads the contents of the current node and the full subtree. It then makes the subtree available until the next xmlTextReaderRead() call</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a node pointer valid until the next xmlTextReaderRead() call or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlTextReaderGetAttribute" id="xmlTextReaderGetAttribute"></a>Function: xmlTextReaderGetAttribute</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlTextReaderGetAttribute	(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br />						 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name)<br />
@@ -287,7 +287,7 @@
 </pre><p>This tells the XML Reader to preserve the current node. The caller must also use xmlTextReaderCurrentDoc() to keep an handle on the resulting document once parsing has finished</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlTextReaderPreservePattern" id="xmlTextReaderPreservePattern"></a>Function: xmlTextReaderPreservePattern</h3><pre class="programlisting">int	xmlTextReaderPreservePattern	(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)<br />
 </pre><p>This tells the XML Reader to preserve all nodes matched by the pattern. The caller must also use xmlTextReaderCurrentDoc() to keep an handle on the resulting document once parsing has finished</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a positive number in case of success and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderQuoteChar" id="xmlTextReaderQuoteChar"></a>Function: xmlTextReaderQuoteChar</h3><pre class="programlisting">int	xmlTextReaderQuoteChar		(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a non-negative number in case of success and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderQuoteChar" id="xmlTextReaderQuoteChar"></a>Function: xmlTextReaderQuoteChar</h3><pre class="programlisting">int	xmlTextReaderQuoteChar		(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
 </pre><p>The quotation mark character used to enclose the value of an attribute.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>" or ' and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderRead" id="xmlTextReaderRead"></a>Function: xmlTextReaderRead</h3><pre class="programlisting">int	xmlTextReaderRead		(<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
 </pre><p>Moves the position of the current instance to the next node in the stream, exposing its properties.</p>
diff --git a/doc/html/libxml-xmlstring.html b/doc/html/libxml-xmlstring.html
index 89e9809..dc8248c 100644
--- a/doc/html/libxml-xmlstring.html
+++ b/doc/html/libxml-xmlstring.html
@@ -67,7 +67,7 @@
 </pre><p>a case-ignoring strstr for xmlChar's</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array (haystack)</td></tr><tr><td><span class="term"><i><tt>val</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> to search (needle)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td></tr></tbody></table></div><h3><a name="xmlStrcat" id="xmlStrcat"></a>Function: xmlStrcat</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrcat		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * add)<br />
 </pre><p>a strcat for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * containing the concatenated string.</td></tr></tbody></table></div><h3><a name="xmlStrchr" id="xmlStrchr"></a>Function: xmlStrchr</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrchr		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str, <br />					 <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> val)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * containing the concatenated string. The original @cur is reallocated and should not be freed.</td></tr></tbody></table></div><h3><a name="xmlStrchr" id="xmlStrchr"></a>Function: xmlStrchr</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrchr		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str, <br />					 <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> val)<br />
 </pre><p>a strchr for xmlChar's</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>val</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> to search</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td></tr></tbody></table></div><h3><a name="xmlStrcmp" id="xmlStrcmp"></a>Function: xmlStrcmp</h3><pre class="programlisting">int	xmlStrcmp			(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str1, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str2)<br />
 </pre><p>a strcmp for xmlChar's</p>
@@ -79,7 +79,7 @@
 </pre><p>a strncasecmp for xmlChar's</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str1</tt></i>:</span></td><td>the first <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *</td></tr><tr><td><span class="term"><i><tt>str2</tt></i>:</span></td><td>the second <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the max comparison length</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the integer result of the comparison</td></tr></tbody></table></div><h3><a name="xmlStrncat" id="xmlStrncat"></a>Function: xmlStrncat</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrncat		(<a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * add, <br />					 int len)<br />
 </pre><p>a strncat for array of xmlChar's, it will extend @cur with the len first bytes of @add. Note that if @len &lt; 0 then this is an API error and NULL will be returned.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the length of @add</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *, the original @cur is reallocated if needed and should not be freed</td></tr></tbody></table></div><h3><a name="xmlStrncatNew" id="xmlStrncatNew"></a>Function: xmlStrncatNew</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrncatNew		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str1, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str2, <br />					 int len)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the original <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array</td></tr><tr><td><span class="term"><i><tt>add</tt></i>:</span></td><td>the <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * array added</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the length of @add</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *, the original @cur is reallocated and should not be freed.</td></tr></tbody></table></div><h3><a name="xmlStrncatNew" id="xmlStrncatNew"></a>Function: xmlStrncatNew</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlStrncatNew		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str1, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str2, <br />					 int len)<br />
 </pre><p>same as xmlStrncat, but creates a new string. The original two strings are not freed. If @len is &lt; 0 then the length will be calculated automatically.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str1</tt></i>:</span></td><td>first <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> string</td></tr><tr><td><span class="term"><i><tt>str2</tt></i>:</span></td><td>second <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> string</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the len of @str2 or &lt; 0</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td></tr></tbody></table></div><h3><a name="xmlStrncmp" id="xmlStrncmp"></a>Function: xmlStrncmp</h3><pre class="programlisting">int	xmlStrncmp			(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str1, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str2, <br />					 int len)<br />
 </pre><p>a strncmp for xmlChar's</p>
@@ -102,7 +102,7 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>the input UTF8 *</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the len of @utf (in chars)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new UTF8 * or NULL</td></tr></tbody></table></div><h3><a name="xmlUTF8Strpos" id="xmlUTF8Strpos"></a>Function: xmlUTF8Strpos</h3><pre class="programlisting">const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlUTF8Strpos		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * utf, <br />					 int pos)<br />
 </pre><p>a function to provide the equivalent of fetching a character from a string array</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>the input UTF8 *</td></tr><tr><td><span class="term"><i><tt>pos</tt></i>:</span></td><td>the position of the desired UTF8 char (in chars)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the UTF8 character or NULL</td></tr></tbody></table></div><h3><a name="xmlUTF8Strsize" id="xmlUTF8Strsize"></a>Function: xmlUTF8Strsize</h3><pre class="programlisting">int	xmlUTF8Strsize			(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * utf, <br />					 int len)<br />
-</pre><p>storage size of an UTF8 string the behaviour is not garanteed if the input string is not UTF-8</p>
+</pre><p>storage size of an UTF8 string the behaviour is not guaranteed if the input string is not UTF-8</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>a sequence of UTF-8 encoded bytes</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the number of <a href="libxml-SAX.html#characters">characters</a> in the array</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the storage size of the first 'len' <a href="libxml-SAX.html#characters">characters</a> of ARRAY</td></tr></tbody></table></div><h3><a name="xmlUTF8Strsub" id="xmlUTF8Strsub"></a>Function: xmlUTF8Strsub</h3><pre class="programlisting"><a href="libxml-xmlstring.html#xmlChar">xmlChar</a> *	xmlUTF8Strsub		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * utf, <br />					 int start, <br />					 int len)<br />
 </pre><p>Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>utf</tt></i>:</span></td><td>a sequence of UTF-8 encoded bytes</td></tr><tr><td><span class="term"><i><tt>start</tt></i>:</span></td><td>relative pos of first char</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>total number to copy</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to a newly created string or NULL if any problem</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/html/libxml-xpath.html b/doc/html/libxml-xpath.html
index e47e600..d22ab9f 100644
--- a/doc/html/libxml-xpath.html
+++ b/doc/html/libxml-xpath.html
@@ -270,7 +270,7 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an XPath context</td></tr><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the XPath expression</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-xpath.html#xmlXPathCompExprPtr">xmlXPathCompExprPtr</a> resulting from the compilation or NULL. the caller has to free the object.</td></tr></tbody></table></div><h3><a name="xmlXPathEval" id="xmlXPathEval"></a>Function: xmlXPathEval</h3><pre class="programlisting"><a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPathEval	(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str, <br />					 <a href="libxml-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> ctx)<br />
 </pre><p>Evaluate the XPath Location Path in the given context.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the XPath expression</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the XPath context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> resulting from the evaluation or NULL. the caller has to free the object.</td></tr></tbody></table></div><h3><a name="xmlXPathEvalExpression" id="xmlXPathEvalExpression"></a>Function: xmlXPathEvalExpression</h3><pre class="programlisting"><a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPathEvalExpression	(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str, <br />						 <a href="libxml-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> ctxt)<br />
-</pre><p>Evaluate the XPath expression in the given context.</p>
+</pre><p>Alias for xmlXPathEval().</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the XPath expression</td></tr><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> resulting from the evaluation or NULL. the caller has to free the object.</td></tr></tbody></table></div><h3><a name="xmlXPathEvalFunc" id="xmlXPathEvalFunc"></a>Function type: xmlXPathEvalFunc</h3><pre class="programlisting">Function type: xmlXPathEvalFunc
 void	xmlXPathEvalFunc		(<a href="libxml-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br />					 int nargs)
 </pre><p>An XPath evaluation function, the parameters are on the XPath context stack.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an XPath parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of arguments passed to the function</td></tr></tbody></table></div><br />
diff --git a/doc/html/libxml-xpathInternals.html b/doc/html/libxml-xpathInternals.html
index f12d808..49546ab 100644
--- a/doc/html/libxml-xpathInternals.html
+++ b/doc/html/libxml-xpathInternals.html
@@ -348,7 +348,7 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath context</td></tr></tbody></table></div><h3><a name="xmlXPathRoot" id="xmlXPathRoot"></a>Function: xmlXPathRoot</h3><pre class="programlisting">void	xmlXPathRoot			(<a href="libxml-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt)<br />
 </pre><p>Initialize the context to the root of the document</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath Parser context</td></tr></tbody></table></div><h3><a name="xmlXPathRoundFunction" id="xmlXPathRoundFunction"></a>Function: xmlXPathRoundFunction</h3><pre class="programlisting">void	xmlXPathRoundFunction		(<a href="libxml-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br />					 int nargs)<br />
-</pre><p>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is even is returned.</p>
+</pre><p>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath Parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of arguments</td></tr></tbody></table></div><h3><a name="xmlXPathStartsWithFunction" id="xmlXPathStartsWithFunction"></a>Function: xmlXPathStartsWithFunction</h3><pre class="programlisting">void	xmlXPathStartsWithFunction	(<a href="libxml-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br />					 int nargs)<br />
 </pre><p>Implement the starts-with() XPath function boolean starts-with(string, string) The starts-with function returns true if the first argument string starts with the second argument string, and otherwise returns false.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPath Parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of arguments</td></tr></tbody></table></div><h3><a name="xmlXPathStringEvalNumber" id="xmlXPathStringEvalNumber"></a>Function: xmlXPathStringEvalNumber</h3><pre class="programlisting">double	xmlXPathStringEvalNumber	(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * str)<br />
diff --git a/doc/html/libxml-xpointer.html b/doc/html/libxml-xpointer.html
index 45526de..66eb80b 100644
--- a/doc/html/libxml-xpointer.html
+++ b/doc/html/libxml-xpointer.html
@@ -77,7 +77,7 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>start</tt></i>:</span></td><td>the starting point</td></tr><tr><td><span class="term"><i><tt>end</tt></i>:</span></td><td>the ending node</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object.</td></tr></tbody></table></div><h3><a name="xmlXPtrNewRangePoints" id="xmlXPtrNewRangePoints"></a>Function: xmlXPtrNewRangePoints</h3><pre class="programlisting"><a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPtrNewRangePoints	(<a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> start, <br />						 <a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> end)<br />
 </pre><p>Create a new <a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> of type range using 2 Points</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>start</tt></i>:</span></td><td>the starting point</td></tr><tr><td><span class="term"><i><tt>end</tt></i>:</span></td><td>the ending point</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object.</td></tr></tbody></table></div><h3><a name="xmlXPtrRangeToFunction" id="xmlXPtrRangeToFunction"></a>Function: xmlXPtrRangeToFunction</h3><pre class="programlisting">void	xmlXPtrRangeToFunction		(<a href="libxml-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br />					 int nargs)<br />
-</pre><p>Implement the range-to() XPointer function</p>
+</pre><p>Implement the range-to() XPointer function Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>the XPointer Parser context</td></tr><tr><td><span class="term"><i><tt>nargs</tt></i>:</span></td><td>the number of args</td></tr></tbody></table></div><h3><a name="xmlXPtrWrapLocationSet" id="xmlXPtrWrapLocationSet"></a>Function: xmlXPtrWrapLocationSet</h3><pre class="programlisting"><a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a>	xmlXPtrWrapLocationSet	(<a href="libxml-xpointer.html#xmlLocationSetPtr">xmlLocationSetPtr</a> val)<br />
 </pre><p>Wrap the LocationSet @val in a new <a href="libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a></p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>val</tt></i>:</span></td><td>the LocationSet value</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the newly created object.</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index a0a0117..ab74ee0 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -1127,7 +1127,7 @@
     </file>
     <file name='schemasInternals'>
      <summary>internal interfaces for XML Schemas</summary>
-     <description>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not garanteed to be API or ABI stable ! </description>
+     <description>internal interfaces for the XML Schemas handling and schema validity checking The Schemas development is a Work In Progress. Some of those interfaces are not guaranteed to be API or ABI stable ! </description>
      <author>Daniel Veillard </author>
      <exports symbol='XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION' type='macro'/>
      <exports symbol='XML_SCHEMAS_FINAL_DEFAULT_EXTENSION' type='macro'/>
@@ -7743,7 +7743,7 @@
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
       <info>parse an HTML in-memory document and build a tree.</info>
       <return type='htmlDocPtr' info='the resulting document tree'/>
-      <arg name='cur' type='xmlChar *' info='a pointer to an array of xmlChar'/>
+      <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
       <arg name='encoding' type='const char *' info='a free form C string describing the HTML document encoding, or NULL'/>
     </function>
     <function name='htmlParseDocument' file='HTMLparser' module='HTMLparser'>
@@ -7823,7 +7823,7 @@
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
       <info>Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</info>
       <return type='htmlDocPtr' info='the resulting document tree unless SAX is NULL or the document is not well formed.'/>
-      <arg name='cur' type='xmlChar *' info='a pointer to an array of xmlChar'/>
+      <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
       <arg name='encoding' type='const char *' info='a free form C string describing the HTML document encoding, or NULL'/>
       <arg name='sax' type='htmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='userData' type='void *' info='if using SAX, this pointer will be provided on callbacks.'/>
@@ -9245,7 +9245,7 @@
     </function>
     <function name='xmlCtxtGetLastError' file='xmlerror' module='error'>
       <info>Get the last parsing error registered.</info>
-      <return type='xmlErrorPtr' info='NULL if no error occured or a pointer to the error'/>
+      <return type='xmlErrorPtr' info='NULL if no error occurred or a pointer to the error'/>
       <arg name='ctx' type='void *' info='an XML parser context'/>
     </function>
     <function name='xmlCtxtReadDoc' file='parser' module='parser'>
@@ -9504,11 +9504,11 @@
     </function>
     <function name='xmlDictCreate' file='dict' module='dict'>
       <info>Create a new dictionary</info>
-      <return type='xmlDictPtr' info='the newly created dictionary, or NULL if an error occured.'/>
+      <return type='xmlDictPtr' info='the newly created dictionary, or NULL if an error occurred.'/>
     </function>
     <function name='xmlDictCreateSub' file='dict' module='dict'>
       <info>Create a new dictionary, inheriting strings from the read-only dictionary @sub. On lookup, strings are first searched in the new dictionary, then in @sub, and if not found are created in the new dictionary.</info>
-      <return type='xmlDictPtr' info='the newly created dictionary, or NULL if an error occured.'/>
+      <return type='xmlDictPtr' info='the newly created dictionary, or NULL if an error occurred.'/>
       <arg name='sub' type='xmlDictPtr' info='an existing dictionary'/>
     </function>
     <function name='xmlDictExists' file='dict' module='dict'>
@@ -10233,7 +10233,7 @@
     </function>
     <function name='xmlGetLastError' file='xmlerror' module='error'>
       <info>Get the last global error registered. This is per thread if compiled with thread support.</info>
-      <return type='xmlErrorPtr' info='NULL if no error occured or a pointer to the error'/>
+      <return type='xmlErrorPtr' info='NULL if no error occurred or a pointer to the error'/>
     </function>
     <function name='xmlGetLineNo' file='tree' module='tree'>
       <info>Get line number of @node. Try to override the limitation of lines being store in 16 bits ints if XML_PARSE_BIG_LINES parser option was used</info>
@@ -10362,12 +10362,12 @@
     </function>
     <function name='xmlHashCreate' file='hash' module='hash'>
       <info>Create a new xmlHashTablePtr.</info>
-      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occured.'/>
+      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occurred.'/>
       <arg name='size' type='int' info='the size of the hash table'/>
     </function>
     <function name='xmlHashCreateDict' file='hash' module='hash'>
       <info>Create a new xmlHashTablePtr which will use @dict as the internal dictionary</info>
-      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occured.'/>
+      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occurred.'/>
       <arg name='size' type='int' info='the size of the hash table'/>
       <arg name='dict' type='xmlDictPtr' info='a dictionary to use for the hash'/>
     </function>
@@ -10877,13 +10877,13 @@
     </function>
     <function name='xmlListRemoveFirst' file='list' module='list'>
       <info>Remove the first instance associated to data in the list</info>
-      <return type='int' info='1 if a deallocation occured, or 0 if not found'/>
+      <return type='int' info='1 if a deallocation occurred, or 0 if not found'/>
       <arg name='l' type='xmlListPtr' info='a list'/>
       <arg name='data' type='void *' info='list data'/>
     </function>
     <function name='xmlListRemoveLast' file='list' module='list'>
       <info>Remove the last instance associated to data in the list</info>
-      <return type='int' info='1 if a deallocation occured, or 0 if not found'/>
+      <return type='int' info='1 if a deallocation occurred, or 0 if not found'/>
       <arg name='l' type='xmlListPtr' info='a list'/>
       <arg name='data' type='void *' info='list data'/>
     </function>
@@ -14453,7 +14453,7 @@
     </function>
     <function name='xmlSplitQName2' file='tree' module='tree'>
       <info>parse an XML qualified name string  [NS 5] QName ::= (Prefix &apos;:&apos;)? LocalPart  [NS 6] Prefix ::= NCName  [NS 7] LocalPart ::= NCName</info>
-      <return type='xmlChar *' info='NULL if not a QName, otherwise the local part, and prefix is updated to get the Prefix if any.'/>
+      <return type='xmlChar *' info='NULL if the name doesn&apos;t have a prefix. Otherwise, returns the local part, and prefix is updated to get the Prefix. Both the return value and the prefix must be freed by the caller.'/>
       <arg name='name' type='const xmlChar *' info='the full QName'/>
       <arg name='prefix' type='xmlChar **' info='a xmlChar **'/>
     </function>
@@ -14519,7 +14519,7 @@
     </function>
     <function name='xmlStrcat' file='xmlstring' module='xmlstring'>
       <info>a strcat for array of xmlChar&apos;s. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of &apos;0&apos;.</info>
-      <return type='xmlChar *' info='a new xmlChar * containing the concatenated string.'/>
+      <return type='xmlChar *' info='a new xmlChar * containing the concatenated string. The original @cur is reallocated and should not be freed.'/>
       <arg name='cur' type='xmlChar *' info='the original xmlChar * array'/>
       <arg name='add' type='const xmlChar *' info='the xmlChar * array added'/>
     </function>
@@ -14637,7 +14637,7 @@
     </function>
     <function name='xmlStrncat' file='xmlstring' module='xmlstring'>
       <info>a strncat for array of xmlChar&apos;s, it will extend @cur with the len first bytes of @add. Note that if @len &lt; 0 then this is an API error and NULL will be returned.</info>
-      <return type='xmlChar *' info='a new xmlChar *, the original @cur is reallocated if needed and should not be freed'/>
+      <return type='xmlChar *' info='a new xmlChar *, the original @cur is reallocated and should not be freed.'/>
       <arg name='cur' type='xmlChar *' info='the original xmlChar * array'/>
       <arg name='add' type='const xmlChar *' info='the xmlChar * array added'/>
       <arg name='len' type='int' info='the length of @add'/>
@@ -14828,7 +14828,7 @@
       <arg name='arg' type='void *' info='the user argument'/>
       <arg name='msg' type='const char *' info='the message'/>
       <arg name='severity' type='xmlParserSeverities' info='the severity of the error'/>
-      <arg name='locator' type='xmlTextReaderLocatorPtr' info='a locator indicating where the error occured'/>
+      <arg name='locator' type='xmlTextReaderLocatorPtr' info='a locator indicating where the error occurred'/>
     </functype>
     <function name='xmlTextReaderExpand' file='xmlreader' module='xmlreader'>
       <cond>defined(LIBXML_READER_ENABLED)</cond>
@@ -15043,7 +15043,7 @@
     <function name='xmlTextReaderPreservePattern' file='xmlreader' module='xmlreader'>
       <cond>defined(LIBXML_READER_ENABLED) &amp;&amp; defined(LIBXML_PATTERN_ENABLED)</cond>
       <info>This tells the XML Reader to preserve all nodes matched by the pattern. The caller must also use xmlTextReaderCurrentDoc() to keep an handle on the resulting document once parsing has finished</info>
-      <return type='int' info='a positive number in case of success and -1 in case of error'/>
+      <return type='int' info='a non-negative number in case of success and -1 in case of error'/>
       <arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
       <arg name='pattern' type='const xmlChar *' info='an XPath subset pattern'/>
       <arg name='namespaces' type='const xmlChar **' info='the prefix definitions, array of [URI, prefix] or NULL'/>
@@ -16932,7 +16932,7 @@
       <arg name='pos' type='int' info='the position of the desired UTF8 char (in chars)'/>
     </function>
     <function name='xmlUTF8Strsize' file='xmlstring' module='xmlstring'>
-      <info>storage size of an UTF8 string the behaviour is not garanteed if the input string is not UTF-8</info>
+      <info>storage size of an UTF8 string the behaviour is not guaranteed if the input string is not UTF-8</info>
       <return type='int' info='the storage size of the first &apos;len&apos; characters of ARRAY'/>
       <arg name='utf' type='const xmlChar *' info='a sequence of UTF-8 encoded bytes'/>
       <arg name='len' type='int' info='the number of characters in the array'/>
@@ -17561,7 +17561,7 @@
     </function>
     <function name='xmlXPathEvalExpression' file='xpath' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
-      <info>Evaluate the XPath expression in the given context.</info>
+      <info>Alias for xmlXPathEval().</info>
       <return type='xmlXPathObjectPtr' info='the xmlXPathObjectPtr resulting from the evaluation or NULL. the caller has to free the object.'/>
       <arg name='str' type='const xmlChar *' info='the XPath expression'/>
       <arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
@@ -18200,7 +18200,7 @@
     </function>
     <function name='xmlXPathRoundFunction' file='xpathInternals' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
-      <info>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is even is returned.</info>
+      <info>Implement the round() XPath function number round(number) The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPath Parser context'/>
       <arg name='nargs' type='int' info='the number of arguments'/>
@@ -18495,7 +18495,7 @@
     </function>
     <function name='xmlXPtrRangeToFunction' file='xpointer' module='xpointer'>
       <cond>defined(LIBXML_XPTR_ENABLED)</cond>
-      <info>Implement the range-to() XPointer function</info>
+      <info>Implement the range-to() XPointer function  Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/>
       <arg name='nargs' type='int' info='the number of args'/>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index 6dce37f..935d4f7 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -8185,7 +8185,9 @@
       <ref name='htmlIsScriptAttribute'/>
       <ref name='htmlNewDoc'/>
       <ref name='htmlNewDocNoDtD'/>
+      <ref name='htmlParseDoc'/>
       <ref name='htmlReadDoc'/>
+      <ref name='htmlSAXParseDoc'/>
       <ref name='htmlSetMetaEncoding'/>
       <ref name='htmlTagLookup'/>
       <ref name='ignorableWhitespace'/>
@@ -9171,8 +9173,6 @@
       <ref name='docbSAXParseDoc'/>
       <ref name='entityDecl'/>
       <ref name='entityDeclSAXFunc'/>
-      <ref name='htmlParseDoc'/>
-      <ref name='htmlSAXParseDoc'/>
       <ref name='xmlBuildQName'/>
       <ref name='xmlCopyChar'/>
       <ref name='xmlCopyCharMultiByte'/>
@@ -14535,6 +14535,9 @@
         <word name='AegeanNumbers'>
           <ref name='xmlUCSIsAegeanNumbers'/>
         </word>
+        <word name='Alias'>
+          <ref name='xmlXPathEvalExpression'/>
+        </word>
         <word name='All'>
           <ref name='_xmlSchema'/>
           <ref name='_xmlSchemaType'/>
@@ -14774,6 +14777,7 @@
         </word>
         <word name='Both'>
           <ref name='XML_SUBSTITUTE_BOTH'/>
+          <ref name='xmlSplitQName2'/>
           <ref name='xmlStreamPush'/>
           <ref name='xmlStreamPushAttr'/>
           <ref name='xmlStreamPushNode'/>
@@ -15758,7 +15762,6 @@
         <word name='Evaluate'>
           <ref name='xmlXPathCompiledEval'/>
           <ref name='xmlXPathEval'/>
-          <ref name='xmlXPathEvalExpression'/>
           <ref name='xmlXPathEvalPredicate'/>
           <ref name='xmlXPathEvaluatePredicateResult'/>
           <ref name='xmlXPathNodeEval'/>
@@ -16936,6 +16939,7 @@
           <ref name='_xmlSchemaElement'/>
           <ref name='_xmlSchemaFacet'/>
           <ref name='_xmlSchemaType'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='Obtain'>
           <ref name='xmlTextReaderLocatorBaseURI'/>
@@ -16976,6 +16980,7 @@
           <ref name='xmlXPathContextSetCache'/>
         </word>
         <word name='Otherwise'>
+          <ref name='xmlSplitQName2'/>
           <ref name='xmlStreamPush'/>
           <ref name='xmlStreamPushAttr'/>
         </word>
@@ -22023,6 +22028,7 @@
           <ref name='xmlNodeListGetRawString'/>
           <ref name='xmlPatternMatch'/>
           <ref name='xmlRemoveProp'/>
+          <ref name='xmlSplitQName2'/>
           <ref name='xmlUTF8Strlen'/>
           <ref name='xmlValidateRoot'/>
           <ref name='xmlXPathLeading'/>
@@ -22607,7 +22613,6 @@
           <ref name='xmlNodeGetBase'/>
           <ref name='xmlParseBalancedChunkMemoryRecover'/>
           <ref name='xmlTextWriterFullEndElement'/>
-          <ref name='xmlXPathRoundFunction'/>
         </word>
         <word name='event'>
           <ref name='xmlSchemaSAXPlug'/>
@@ -23390,9 +23395,6 @@
         <word name='gYearMonth'>
           <ref name='xmlSchemaGetCanonValue'/>
         </word>
-        <word name='garanteed'>
-          <ref name='xmlUTF8Strsize'/>
-        </word>
         <word name='garbage'>
           <ref name='xmlGcMemGet'/>
           <ref name='xmlGcMemSetup'/>
@@ -23594,6 +23596,7 @@
         <word name='guaranteed'>
           <ref name='xmlModuleOpen'/>
           <ref name='xmlModuleSymbol'/>
+          <ref name='xmlUTF8Strsize'/>
         </word>
         <word name='guess'>
           <ref name='xmlCleanupParser'/>
@@ -23615,6 +23618,7 @@
           <ref name='xmlParseElementContentDecl'/>
           <ref name='xmlParsePEReference'/>
           <ref name='xmlParserHandlePEReference'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='handlers'>
           <ref name='xlinkSetDefaultHandler'/>
@@ -24191,6 +24195,7 @@
         <word name='infinity'>
           <ref name='xmlXPathCeilingFunction'/>
           <ref name='xmlXPathFloorFunction'/>
+          <ref name='xmlXPathRoundFunction'/>
           <ref name='xmlXPathStringFunction'/>
         </word>
         <word name='info'>
@@ -25058,6 +25063,7 @@
           <ref name='xmlSetFeature'/>
           <ref name='xmlUTF8Strloc'/>
           <ref name='xmlXPtrLocationSetAdd'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='locations'>
           <ref name='_xmlLocationSet'/>
@@ -25733,7 +25739,6 @@
           <ref name='xmlSchemaSAXPlug'/>
           <ref name='xmlSetBufferAllocationScheme'/>
           <ref name='xmlShellPwd'/>
-          <ref name='xmlStrncat'/>
           <ref name='xmlTextReaderCurrentDoc'/>
           <ref name='xmlValidCtxtNormalizeAttributeValue'/>
           <ref name='xmlValidNormalizeAttributeValue'/>
@@ -25881,6 +25886,7 @@
         <word name='non-negative'>
           <ref name='xmlC14NDocSaveTo'/>
           <ref name='xmlC14NExecute'/>
+          <ref name='xmlTextReaderPreservePattern'/>
         </word>
         <word name='non-normative'>
           <ref name='xmlDetectCharEncoding'/>
@@ -26088,7 +26094,13 @@
           <ref name='xmlParseComment'/>
           <ref name='xmlParseMarkupDecl'/>
         </word>
-        <word name='occured'>
+        <word name='occurences'>
+          <ref name='xmlAutomataNewCountTrans'/>
+          <ref name='xmlAutomataNewCountTrans2'/>
+          <ref name='xmlAutomataNewOnceTrans'/>
+          <ref name='xmlAutomataNewOnceTrans2'/>
+        </word>
+        <word name='occurred'>
           <ref name='xmlCtxtGetLastError'/>
           <ref name='xmlDictCreate'/>
           <ref name='xmlDictCreateSub'/>
@@ -26097,17 +26109,9 @@
           <ref name='xmlHashCreateDict'/>
           <ref name='xmlListRemoveFirst'/>
           <ref name='xmlListRemoveLast'/>
-          <ref name='xmlTextReaderErrorFunc'/>
-        </word>
-        <word name='occurences'>
-          <ref name='xmlAutomataNewCountTrans'/>
-          <ref name='xmlAutomataNewCountTrans2'/>
-          <ref name='xmlAutomataNewOnceTrans'/>
-          <ref name='xmlAutomataNewOnceTrans2'/>
-        </word>
-        <word name='occurred'>
           <ref name='xmlMemStrdupLoc'/>
           <ref name='xmlMemoryStrdup'/>
+          <ref name='xmlTextReaderErrorFunc'/>
         </word>
         <word name='occurrence'>
           <ref name='xmlStrcasestr'/>
@@ -27467,6 +27471,9 @@
           <ref name='INPUT_CHUNK'/>
           <ref name='xmlAutomataCompile'/>
         </word>
+        <word name='real'>
+          <ref name='xmlXPtrRangeToFunction'/>
+        </word>
         <word name='realloc'>
           <ref name='_xmlBuffer'/>
           <ref name='xmlGcMemGet'/>
@@ -27479,6 +27486,7 @@
         </word>
         <word name='reallocated'>
           <ref name='xmlReallocFunc'/>
+          <ref name='xmlStrcat'/>
           <ref name='xmlStrncat'/>
         </word>
         <word name='really'>
@@ -28968,6 +28976,7 @@
           <ref name='xmlNodeSetContent'/>
           <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlTextWriterWriteRawLen'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='specialized'>
           <ref name='_xmlDOMWrapCtxt'/>
@@ -29153,6 +29162,7 @@
           <ref name='xmlValidNormalizeAttributeValue'/>
           <ref name='xmlValidateDocumentFinal'/>
           <ref name='xmlValidateDtdFinal'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='steps'>
           <ref name='xmlNormalizeURIPath'/>
@@ -31941,6 +31951,9 @@
         <word name='xmlXPathError'>
           <ref name='err'/>
         </word>
+        <word name='xmlXPathEval'>
+          <ref name='xmlXPathEvalExpression'/>
+        </word>
         <word name='xmlXPathEvalPredicate'>
           <ref name='xmlXPtrEvalRangePredicate'/>
         </word>
@@ -32015,6 +32028,7 @@
         <word name='xpath'>
           <ref name='xmlShellPrintXPathError'/>
           <ref name='xmlShellPrintXPathResult'/>
+          <ref name='xmlXPtrRangeToFunction'/>
         </word>
         <word name='xpointer'>
           <ref name='XINCLUDE_PARSE_XPOINTER'/>
diff --git a/doc/libxml2.xsa b/doc/libxml2.xsa
index 0d4b8fe..f575ff0 100644
--- a/doc/libxml2.xsa
+++ b/doc/libxml2.xsa
@@ -8,73 +8,24 @@
   </vendor>
   <product id="libxml2">
     <name>libxml2</name>
-    <version>v2.9.3</version>
-    <last-release> Nov 20 2015</last-release>
+    <version>v2.9.6</version>
+    <last-release> Oct 06 2017</last-release>
     <info-url>http://xmlsoft.org/</info-url>
-    <changes>   - Security:
-  CVE-2015-8242 Buffer overead with HTML parser in push mode (Hugh Davenport),
-  CVE-2015-7500 Fix memory access error due to incorrect entities boundaries (Daniel Veillard),
-  CVE-2015-7499-2 Detect incoherency on GROW (Daniel Veillard),
-  CVE-2015-7499-1 Add xmlHaltParser() to stop the parser (Daniel Veillard),
-  CVE-2015-5312 Another entity expansion issue (David Drysdale),
-  CVE-2015-7497 Avoid an heap buffer overflow in xmlDictComputeFastQKey (David Drysdale),
-  CVE-2015-7498 Avoid processing entities after encoding conversion failures (Daniel Veillard),
-  CVE-2015-8035 Fix XZ compression support loop (Daniel Veillard),
-  CVE-2015-7942-2 Fix an error in previous Conditional section patch (Daniel Veillard),
-  CVE-2015-7942 Another variation of overflow in Conditional sections (Daniel Veillard),
-  CVE-2015-1819 Enforce the reader to run in constant memory (Daniel Veillard)
-  CVE-2015-7941_2 Cleanup conditional section error handling (Daniel Veillard),
-  CVE-2015-7941_1 Stop parsing on entities boundaries errors (Daniel Veillard),
-  
-   - Documentation:
-  Correct spelling of "calling" (Alex Henrie),
-  Fix a small error in xmllint --format description (Fabien Degomme),
-  Avoid XSS on the search of xmlsoft.org (Daniel Veillard)
-  
-   - Portability:
-  threads: use forward declarations only for glibc (Michael Heimpold),
-  Update Win32 configure.js to search for configure.ac (Daniel Veillard)
+    <changes>   - Portability:
+  Change preprocessor OS tests to __linux__ (Nick Wellnhofer)
   
    - Bug Fixes:
-  Bug on creating new stream from entity (Daniel Veillard),
-  Fix some loop issues embedding NEXT (Daniel Veillard),
-  Do not print error context when there is none (Daniel Veillard),
-  Avoid extra processing of MarkupDecl when EOF (Hugh Davenport),
-  Fix parsing short unclosed comment uninitialized access (Daniel Veillard),
-  Add missing Null check in xmlParseExternalEntityPrivate (Gaurav Gupta),
-  Fix a bug in CData error handling in the push parser (Daniel Veillard),
-  Fix a bug on name parsing at the end of current input buffer (Daniel Veillard),
-  Fix the spurious ID already defined error (Daniel Veillard),
-  Fix previous change to node sort order (Nick Wellnhofer),
-  Fix a self assignment issue raised by clang (Scott Graham),
-  Fail parsing early on if encoding conversion failed (Daniel Veillard),
-  Do not process encoding values if the declaration if broken (Daniel Veillard),
-  Silence clang's -Wunknown-attribute (Michael Catanzaro),
-  xmlMemUsed is not thread-safe (Martin von Gagern),
-  Fix support for except in nameclasses (Daniel Veillard),
-  Fix order of root nodes (Nick Wellnhofer),
-  Allow attributes on descendant-or-self axis (Nick Wellnhofer),
-  Fix the fix to Windows locking (Steve Nairn),
-  Fix timsort invariant loop re: Envisage article (Christopher Swenson),
-  Don't add IDs in xmlSetTreeDoc (Nick Wellnhofer),
-  Account for ID attributes in xmlSetTreeDoc (Nick Wellnhofer),
-  Remove various unused value assignments (Philip Withnall),
-  Fix missing entities after CVE-2014-3660 fix (Daniel Veillard),
-  Revert "Missing initialization for the catalog module" (Daniel Veillard)
-  
-   - Improvements:
-  Reuse xmlHaltParser() where it makes sense (Daniel Veillard),
-  xmlStopParser reset errNo (Daniel Veillard),
-  Reenable xz support by default (Daniel Veillard),
-  Recover unescaped less-than character in HTML recovery parsing (Daniel Veillard),
-  Allow HTML serializer to output HTML5 DOCTYPE (Shaun McCance),
-  Regression test for bug #695699 (Nick Wellnhofer),
-  Add a couple of XPath tests (Nick Wellnhofer),
-  Add Python 3 rpm subpackage (Tomas Radej),
-  libxml2-config.cmake.in: update include directories (Samuel Martin),
-  Adding example from bugs 738805 to regression tests (Daniel Veillard)
-  
-   - Cleanups:
+  Fix XPath stack frame logic (Nick Wellnhofer),
+  Report undefined XPath variable error message (Nick Wellnhofer),
+  Fix regression with librsvg (Nick Wellnhofer),
+  Handle more invalid entity values in recovery mode (Nick Wellnhofer),
+  Fix structured validation errors (Nick Wellnhofer),
+  Fix memory leak in LZMA decompressor (Nick Wellnhofer),
+  Set memory limit for LZMA decompression (Nick Wellnhofer),
+  Handle illegal entity values in recovery mode (Nick Wellnhofer),
+  Fix debug dump of streaming XPath expressions (Nick Wellnhofer),
+  Fix memory leak in nanoftp (Nick Wellnhofer),
+  Fix memory leaks in SAX1 parser (Nick Wellnhofer)
   
 
 </changes>
diff --git a/doc/news.html b/doc/news.html
index 0c692c8..5346d32 100644
--- a/doc/news.html
+++ b/doc/news.html
@@ -8,7 +8,191 @@
 H3 {font-family: Verdana,Arial,Helvetica}
 A:link, A:visited, A:active { text-decoration: underline }
 </style><title>Releases</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1>The XML C parser and toolkit of Gnome</h1><h2>Releases</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Main Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a href="index.html">Home</a></li><li><a href="html/index.html">Reference Manual</a></li><li><a href="intro.html">Introduction</a></li><li><a href="FAQ.html">FAQ</a></li><li><a href="docs.html" style="font-weight:bold">Developer Menu</a></li><li><a href="bugs.html">Reporting bugs and getting help</a></li><li><a href="help.html">How to help</a></li><li><a href="downloads.html">Downloads</a></li><li><a href="news.html">Releases</a></li><li><a href="XMLinfo.html">XML</a></li><li><a href="XSLT.html">XSLT</a></li><li><a href="xmldtd.html">Validation &amp; DTDs</a></li><li><a href="encoding.html">Encodings support</a></li><li><a href="catalog.html">Catalog support</a></li><li><a href="namespaces.html">Namespaces</a></li><li><a href="contribs.html">Contributions</a></li><li><a href="examples/index.html" style="font-weight:bold">Code Examples</a></li><li><a href="html/index.html" style="font-weight:bold">API Menu</a></li><li><a href="guidelines.html">XML Guidelines</a></li><li><a href="ChangeLog.html">Recent Changes</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://opencsw.org/packages/libxml2">Solaris binaries</a></li><li><a href="http://www.explain.com.au/oss/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://lxml.de/">lxml Python bindings</a></li><li><a href="http://cpan.uwinnipeg.ca/dist/XML-LibXML">Perl bindings</a></li><li><a href="http://libxmlplusplus.sourceforge.net/">C++ bindings</a></li><li><a href="http://www.zend.com/php5/articles/php5-xmlphp.php#Heading4">PHP bindings</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://libxml.rubyforge.org/">Ruby bindings</a></li><li><a href="http://tclxml.sourceforge.net/">Tcl bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><p>The <a href="ChangeLog.html">change log</a> describes the recents commits
-to the <a href="http://git.gnome.org/browse/libxml2/">GIT</a> code base.</p><p>Here is the list of public releases:</p><h3>2.9.4: May 23 2016</h3><ul>
+to the <a href="http://git.gnome.org/browse/libxml2/">GIT</a> code base.</p><p>Here is the list of public releases:</p><h3>2.9.7: Nov 02 2017</h3><ul>
+  <li>Documentation:<br />
+  xmlcatalog: refresh man page wrt. quering system catalog easily (Jan Pokorný)<br />
+  </li>
+
+  <li>Portability:<br />
+  Fix deprecated Travis compiler flag (Nick Wellnhofer),<br />
+  Add declaration for DllMain (J. Peter Mugaas),<br />
+  Fix preprocessor conditional in threads.h (J. Peter Mugaas),<br />
+  Fix pointer comparison warnings on 64-bit Windows (J. Peter Mugaas),<br />
+  Fix macro redefinition warning (J. Peter Mugaas),<br />
+  Default to native threads on MinGW-w64 (Nick Wellnhofer),<br />
+  Simplify Windows IO functions (Nick Wellnhofer),<br />
+  Fix runtest on Windows (Nick Wellnhofer),<br />
+  socklen_t is always int on Windows (Nick Wellnhofer),<br />
+  Don't redefine socket error codes on Windows (Nick Wellnhofer),<br />
+  Fix pointer/int cast warnings on 64-bit Windows (Nick Wellnhofer),<br />
+  Fix Windows compiler warnings in xmlCanonicPath (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Bug Fixes:<br />
+  xmlcatalog: restore ability to query system catalog easily (Jan Pokorný),<br />
+  Fix comparison of nodesets to strings (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Improvements:<br />
+  Add Makefile rules to rebuild HTML man pages (Nick Wellnhofer),<br />
+  Fix mixed decls and code in timsort.h (Nick Wellnhofer),<br />
+  Rework handling of return values in thread tests (Nick Wellnhofer),<br />
+  Fix unused variable warnings in testrecurse (Nick Wellnhofer),<br />
+  Fix -Wimplicit-fallthrough warnings (J. Peter Mugaas),<br />
+  Upgrade timsort.h to latest revision (Nick Wellnhofer),<br />
+  Increase warning level to /W3 under MSVC (Nick Wellnhofer),<br />
+  Fix a couple of warnings in dict.c and threads.c (Nick Wellnhofer),<br />
+  Update .gitignore for Windows (Nick Wellnhofer),<br />
+  Fix unused variable warnings in nanohttp.c (Nick Wellnhofer),<br />
+  Fix the Windows header mess (Nick Wellnhofer),<br />
+  Don't include winsock2.h in xmllint.c (Nick Wellnhofer),<br />
+  Remove generated file python/setup.py from version control (Nick Wellnhofer),<br />
+  Use __linux__ macro in generated code (Nick Wellnhofer)<br />
+  </li>
+
+</ul><h3>v2.9.6: Oct 06 2017</h3><ul>
+  <li>Portability:<br />
+  Change preprocessor OS tests to __linux__ (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Bug Fixes:<br />
+  Fix XPath stack frame logic (Nick Wellnhofer),<br />
+  Report undefined XPath variable error message (Nick Wellnhofer),<br />
+  Fix regression with librsvg (Nick Wellnhofer),<br />
+  Handle more invalid entity values in recovery mode (Nick Wellnhofer),<br />
+  Fix structured validation errors (Nick Wellnhofer),<br />
+  Fix memory leak in LZMA decompressor (Nick Wellnhofer),<br />
+  Set memory limit for LZMA decompression (Nick Wellnhofer),<br />
+  Handle illegal entity values in recovery mode (Nick Wellnhofer),<br />
+  Fix debug dump of streaming XPath expressions (Nick Wellnhofer),<br />
+  Fix memory leak in nanoftp (Nick Wellnhofer),<br />
+  Fix memory leaks in SAX1 parser (Nick Wellnhofer)<br />
+  </li>
+</ul><h3>v2.9.5: Sep 04 2017</h3><ul>
+
+  <li>Security:<br />
+  Detect infinite recursion in parameter entities (Nick Wellnhofer),<br />
+  Fix handling of parameter-entity references (Nick Wellnhofer),<br />
+  Disallow namespace nodes in XPointer ranges (Nick Wellnhofer),<br />
+  Fix XPointer paths beginning with range-to (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Documentation:<br />
+  Documentation fixes (Nick Wellnhofer),<br />
+  Spelling and grammar fixes (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Portability:<br />
+  Adding README.zOS to list of extra files for the release (Daniel Veillard),<br />
+  Description of work needed to compile on zOS (Stéphane Michaut),<br />
+  Porting libxml2 on zOS encoding of code (Stéphane Michaut),<br />
+  small changes for OS/400 (Patrick Monnerat),<br />
+  relaxng.c, xmlschemas.c: Fix build on pre-C99 compilers (Chun-wei Fan)<br />
+  </li>
+
+  <li>Bug Fixes:<br />
+  Problem resolving relative URIs (Daniel Veillard),<br />
+  Fix unwanted warnings when switching encodings (Nick Wellnhofer),<br />
+  Fix signature of xmlSchemaAugmentImportedIDC (Daniel Veillard),<br />
+  Heap-buffer-overflow read of size 1 in xmlFAParsePosCharGroup (David Kilzer),<br />
+  Fix NULL pointer deref in xmlFAParseCharClassEsc (Nick Wellnhofer),<br />
+  Fix infinite loops with push parser in recovery mode (Nick Wellnhofer),<br />
+  Send xmllint usage error to stderr (Nick Wellnhofer),<br />
+  Fix NULL deref in xmlParseExternalEntityPrivate (Nick Wellnhofer),<br />
+  Make sure not to call IS_BLANK_CH when parsing the DTD (Nick Wellnhofer),<br />
+  Fix xmlHaltParser (Nick Wellnhofer),<br />
+  Fix pathological performance when outputting charrefs (Nick Wellnhofer),<br />
+  Fix invalid-source-encoding warnings in testWriter.c (Nick Wellnhofer),<br />
+  Fix duplicate SAX callbacks for entity content (David Kilzer),<br />
+  Treat URIs with scheme as absolute in C14N (Nick Wellnhofer),<br />
+  Fix copy-paste errors in error messages (Nick Wellnhofer),<br />
+  Fix sanity check in htmlParseNameComplex (Nick Wellnhofer),<br />
+  Fix potential infinite loop in xmlStringLenDecodeEntities (Nick Wellnhofer),<br />
+  Reset parser input pointers on encoding failure (Nick Wellnhofer),<br />
+  Fix memory leak in xmlParseEntityDecl error path (Nick Wellnhofer),<br />
+  Fix xmlBuildRelativeURI for URIs starting with './' (Nick Wellnhofer),<br />
+  Fix type confusion in xmlValidateOneNamespace (Nick Wellnhofer),<br />
+  Fix memory leak in xmlStringLenGetNodeList (Nick Wellnhofer),<br />
+  Fix NULL pointer deref in xmlDumpElementContent (Daniel Veillard),<br />
+  Fix memory leak in xmlBufAttrSerializeTxtContent (Nick Wellnhofer),<br />
+  Stop parser on unsupported encodings (Nick Wellnhofer),<br />
+  Check for integer overflow in memory debug code (Nick Wellnhofer),<br />
+  Fix buffer size checks in xmlSnprintfElementContent (Nick Wellnhofer),<br />
+  Avoid reparsing in xmlParseStartTag2 (Nick Wellnhofer),<br />
+  Fix undefined behavior in xmlRegExecPushStringInternal (Nick Wellnhofer),<br />
+  Check XPath exponents for overflow (Nick Wellnhofer),<br />
+  Check for overflow in xmlXPathIsPositionalPredicate (Nick Wellnhofer),<br />
+  Fix spurious error message (Nick Wellnhofer),<br />
+  Fix memory leak in xmlCanonicPath (Nick Wellnhofer),<br />
+  Fix memory leak in xmlXPathCompareNodeSetValue (Nick Wellnhofer),<br />
+  Fix memory leak in pattern error path (Nick Wellnhofer),<br />
+  Fix memory leak in parser error path (Nick Wellnhofer),<br />
+  Fix memory leaks in XPointer error paths (Nick Wellnhofer),<br />
+  Fix memory leak in xmlXPathNodeSetMergeAndClear (Nick Wellnhofer),<br />
+  Fix memory leak in XPath filter optimizations (Nick Wellnhofer),<br />
+  Fix memory leaks in XPath error paths (Nick Wellnhofer),<br />
+  Do not leak the new CData node if adding fails (David Tardon),<br />
+  Prevent unwanted external entity reference (Neel Mehta),<br />
+  Increase buffer space for port in HTTP redirect support (Daniel Veillard),<br />
+  Fix more NULL pointer derefs in xpointer.c (Nick Wellnhofer),<br />
+  Avoid function/data pointer conversion in xpath.c (Nick Wellnhofer),<br />
+  Fix format string warnings (Nick Wellnhofer),<br />
+  Disallow namespace nodes in XPointer points (Nick Wellnhofer),<br />
+  Fix comparison with root node in xmlXPathCmpNodes (Nick Wellnhofer),<br />
+  Fix attribute decoding during XML schema validation (Alex Henrie),<br />
+  Fix NULL pointer deref in XPointer range-to (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Improvements:<br />
+  Updating the spec file to reflect Fedora 24 (Daniel Veillard),<br />
+  Add const in five places to move 1 KiB to .rdata (Bruce Dawson),<br />
+  Fix missing part of comment for function xmlXPathEvalExpression() (Daniel Veillard),<br />
+  Get rid of "blanks wrapper" for parameter entities (Nick Wellnhofer),<br />
+  Simplify handling of parameter entity references (Nick Wellnhofer),<br />
+  Deduplicate code in encoding.c (Nick Wellnhofer),<br />
+  Make HTML parser functions take const pointers (Nick Wellnhofer),<br />
+  Build test programs only when needed (Nick Wellnhofer),<br />
+  Fix doc/examples/index.py (Nick Wellnhofer),<br />
+  Fix compiler warnings in threads.c (Nick Wellnhofer),<br />
+  Fix empty-body warning in nanohttp.c (Nick Wellnhofer),<br />
+  Fix cast-align warnings (Nick Wellnhofer),<br />
+  Fix unused-parameter warnings (Nick Wellnhofer),<br />
+  Rework entity boundary checks (Nick Wellnhofer),<br />
+  Don't switch encoding for internal parameter entities (Nick Wellnhofer),<br />
+  Merge duplicate code paths handling PE references (Nick Wellnhofer),<br />
+  Test SAX2 callbacks with entity substitution (Nick Wellnhofer),<br />
+  Support catalog and threads tests under --without-sax1 (Nick Wellnhofer),<br />
+  Misc fixes for 'make tests' (Nick Wellnhofer),<br />
+  Initialize keepBlanks in HTML parser (Nick Wellnhofer),<br />
+  Add test cases for bug 758518 (David Kilzer),<br />
+  Fix compiler warning in htmlParseElementInternal (Nick Wellnhofer),<br />
+  Remove useless check in xmlParseAttributeListDecl (Nick Wellnhofer),<br />
+  Allow zero sized memory input buffers (Nick Wellnhofer),<br />
+  Add TODO comment in xmlSwitchEncoding (Nick Wellnhofer),<br />
+  Check for integer overflow in xmlXPathFormatNumber (Nick Wellnhofer),<br />
+  Make Travis print UBSan stacktraces (Nick Wellnhofer),<br />
+  Add .travis.yml (Nick Wellnhofer),<br />
+  Fix expected error output in Python tests (Nick Wellnhofer),<br />
+  Simplify control flow in xmlParseStartTag2 (Nick Wellnhofer),<br />
+  Disable LeakSanitizer when running API tests (Nick Wellnhofer),<br />
+  Avoid out-of-bound array access in API tests (Nick Wellnhofer),<br />
+  Avoid spurious UBSan errors in parser.c (Nick Wellnhofer),<br />
+  Parse small XPath numbers more accurately (Nick Wellnhofer),<br />
+  Rework XPath rounding functions (Nick Wellnhofer),<br />
+  Fix white space in test output (Nick Wellnhofer),<br />
+  Fix axis traversal from attribute and namespace nodes (Nick Wellnhofer),<br />
+  Check for trailing characters in XPath expressions earlier (Nick Wellnhofer),<br />
+  Rework final handling of XPath results (Nick Wellnhofer),<br />
+  Make xmlXPathEvalExpression call xmlXPathEval (Nick Wellnhofer),<br />
+  Remove unused variables (Nick Wellnhofer),<br />
+  Don't print generic error messages in XPath tests (Nick Wellnhofer)<br />
+  </li>
+
+  <li>Cleanups:<br />
+  Fix a couple of misleading indentation errors (Daniel Veillard),<br />
+  Remove unnecessary calls to xmlPopInput (Nick Wellnhofer)<br />
+  </li>
+</ul><h3>2.9.4: May 23 2016</h3><ul>
   <li>Security:<br />
   More format string warnings with possible format string vulnerability (David Kilzer),<br />
   Avoid building recursive entities (Daniel Veillard),<br />
@@ -1368,7 +1552,7 @@
     Hendricks), aliasing bug exposed by gcc4 on s390, xmlTextReaderNext bug
     (Rob Richards), Schemas decimal type fixes (William Brack),
     xmlByteConsumed static buffer (Ben Maurer).</li>
-  <li>improvement: speedup parsing comments and DTDs, dictionnary support for
+  <li>improvement: speedup parsing comments and DTDs, dictionary support for
     hash tables, Schemas Identity constraints (Kasimier), streaming XPath
     subset, xmlTextReaderReadString added (Bjorn Reese), Schemas canonical
     values handling (Kasimier), add xmlTextReaderByteConsumed (Aron
@@ -1558,7 +1742,7 @@
     URI on SYSTEM lookup failure, XInclude parse flags inheritance (William),
     XInclude and XPointer fixes for entities (William), XML parser bug
     reported by Holger Rauch, nanohttp fd leak (William),  regexps char
-    groups '-' handling (William), dictionnary reference counting problems,
+    groups '-' handling (William), dictionary reference counting problems,
     do not close stderr.</li>
   <li>performance patches from Petr Pajas</li>
   <li>Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey)</li>
@@ -1613,14 +1797,14 @@
     Fleck), doc (Sven Zimmerman), I/O example.</li>
   <li>Python bindings: fixes (William), enum support (Stéphane Bidoul),
     structured error reporting (Stéphane Bidoul)</li>
-  <li>XInclude: various fixes for conformance, problem related to dictionnary
+  <li>XInclude: various fixes for conformance, problem related to dictionary
     references (William &amp; me), recursion (William)</li>
   <li>xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred
     Mickautsch),</li>
   <li>xmlSchemas: normalizedString datatype (John Belmonte)</li>
   <li>code cleanup for strings functions (William)</li>
   <li>Windows: compiler patches (Mark Vakoc)</li>
-  <li>Parser optimizations, a few new XPath and dictionnary APIs for future
+  <li>Parser optimizations, a few new XPath and dictionary APIs for future
     XSLT optimizations.</li>
 </ul><h3>2.6.4: Dec 24 2003</h3><ul>
   <li>Windows build fixes (Igor Zlatkovic)</li>
@@ -1705,8 +1889,8 @@
     of change</li>
   <li>Increased the library modularity, far more options can be stripped out,
     a --with-minimum configuration will weight around 160KBytes</li>
-  <li>Use per parser and per document dictionnary, allocate names and small
-    text nodes from the dictionnary</li>
+  <li>Use per parser and per document dictionary, allocate names and small
+    text nodes from the dictionary</li>
   <li>Switch to a SAX2 like parser rewrote most of the XML parser core,
     provides namespace resolution and defaulted attributes, minimize memory
     allocations and copies, namespace checking and specific error handling,
@@ -1753,7 +1937,7 @@
     (William), xmlCleanupParser (Marc Liyanage), CDATA output (William), HTTP
     error handling.</li>
   <li>xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for compat
-    testing,  --nodict for building without tree dictionnary, --nocdata to
+    testing,  --nodict for building without tree dictionary, --nocdata to
     replace CDATA by text, --nsclean to remove surperfluous  namespace
     declarations</li>
   <li>added xml2-config --libtool-libs option from Kevin P. Fleming</li>
diff --git a/doc/symbols.xml b/doc/symbols.xml
index ec275e7..99aea71 100644
--- a/doc/symbols.xml
+++ b/doc/symbols.xml
@@ -1765,4 +1765,7 @@
     <symbol file="xpath">xmlXPathNodeEval</symbol>
     <symbol file="xpath">xmlXPathSetContextNode</symbol>
   </release>
+  <release version="2.9.8">
+    <symbol file="hash">xmlHashDefaultDeallocator</symbol>
+  </release>
 </symbols>
diff --git a/doc/xml.html b/doc/xml.html
index d035934..b902869 100644
--- a/doc/xml.html
+++ b/doc/xml.html
@@ -532,7 +532,7 @@
 is still open. Be sure to specify that the bug is for the package libxml2.</p>
 
 <p>For small problems you can try to get help on IRC, the #xml channel on
-irc.gnome.org (port 6667) usually have a few person subscribed which may help
+irc.gnome.org (port 6667) usually has a few people subscribed which may help
 (but there is no guarantee and if a real issue is raised it should go on the
 mailing-list for archival).</p>
 
@@ -709,6 +709,196 @@
 
 <p>Here is the list of public releases:</p>
 
+<h3>2.9.7: Nov 02 2017</h3>
+<ul>
+  <li>Documentation:<br/>
+  xmlcatalog: refresh man page wrt. quering system catalog easily (Jan Pokorný)<br/>
+  </li>
+
+  <li>Portability:<br/>
+  Fix deprecated Travis compiler flag (Nick Wellnhofer),<br/>
+  Add declaration for DllMain (J. Peter Mugaas),<br/>
+  Fix preprocessor conditional in threads.h (J. Peter Mugaas),<br/>
+  Fix pointer comparison warnings on 64-bit Windows (J. Peter Mugaas),<br/>
+  Fix macro redefinition warning (J. Peter Mugaas),<br/>
+  Default to native threads on MinGW-w64 (Nick Wellnhofer),<br/>
+  Simplify Windows IO functions (Nick Wellnhofer),<br/>
+  Fix runtest on Windows (Nick Wellnhofer),<br/>
+  socklen_t is always int on Windows (Nick Wellnhofer),<br/>
+  Don't redefine socket error codes on Windows (Nick Wellnhofer),<br/>
+  Fix pointer/int cast warnings on 64-bit Windows (Nick Wellnhofer),<br/>
+  Fix Windows compiler warnings in xmlCanonicPath (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Bug Fixes:<br/>
+  xmlcatalog: restore ability to query system catalog easily (Jan Pokorný),<br/>
+  Fix comparison of nodesets to strings (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Improvements:<br/>
+  Add Makefile rules to rebuild HTML man pages (Nick Wellnhofer),<br/>
+  Fix mixed decls and code in timsort.h (Nick Wellnhofer),<br/>
+  Rework handling of return values in thread tests (Nick Wellnhofer),<br/>
+  Fix unused variable warnings in testrecurse (Nick Wellnhofer),<br/>
+  Fix -Wimplicit-fallthrough warnings (J. Peter Mugaas),<br/>
+  Upgrade timsort.h to latest revision (Nick Wellnhofer),<br/>
+  Increase warning level to /W3 under MSVC (Nick Wellnhofer),<br/>
+  Fix a couple of warnings in dict.c and threads.c (Nick Wellnhofer),<br/>
+  Update .gitignore for Windows (Nick Wellnhofer),<br/>
+  Fix unused variable warnings in nanohttp.c (Nick Wellnhofer),<br/>
+  Fix the Windows header mess (Nick Wellnhofer),<br/>
+  Don't include winsock2.h in xmllint.c (Nick Wellnhofer),<br/>
+  Remove generated file python/setup.py from version control (Nick Wellnhofer),<br/>
+  Use __linux__ macro in generated code (Nick Wellnhofer)<br/>
+  </li>
+
+</ul>
+<h3>v2.9.6: Oct 06 2017</h3>
+<ul>
+  <li>Portability:<br/>
+  Change preprocessor OS tests to __linux__ (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Bug Fixes:<br/>
+  Fix XPath stack frame logic (Nick Wellnhofer),<br/>
+  Report undefined XPath variable error message (Nick Wellnhofer),<br/>
+  Fix regression with librsvg (Nick Wellnhofer),<br/>
+  Handle more invalid entity values in recovery mode (Nick Wellnhofer),<br/>
+  Fix structured validation errors (Nick Wellnhofer),<br/>
+  Fix memory leak in LZMA decompressor (Nick Wellnhofer),<br/>
+  Set memory limit for LZMA decompression (Nick Wellnhofer),<br/>
+  Handle illegal entity values in recovery mode (Nick Wellnhofer),<br/>
+  Fix debug dump of streaming XPath expressions (Nick Wellnhofer),<br/>
+  Fix memory leak in nanoftp (Nick Wellnhofer),<br/>
+  Fix memory leaks in SAX1 parser (Nick Wellnhofer)<br/>
+  </li>
+</ul>
+<h3>v2.9.5: Sep 04 2017</h3>
+<ul>
+
+  <li>Security:<br/>
+  Detect infinite recursion in parameter entities (Nick Wellnhofer),<br/>
+  Fix handling of parameter-entity references (Nick Wellnhofer),<br/>
+  Disallow namespace nodes in XPointer ranges (Nick Wellnhofer),<br/>
+  Fix XPointer paths beginning with range-to (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Documentation:<br/>
+  Documentation fixes (Nick Wellnhofer),<br/>
+  Spelling and grammar fixes (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Portability:<br/>
+  Adding README.zOS to list of extra files for the release (Daniel Veillard),<br/>
+  Description of work needed to compile on zOS (Stéphane Michaut),<br/>
+  Porting libxml2 on zOS encoding of code (Stéphane Michaut),<br/>
+  small changes for OS/400 (Patrick Monnerat),<br/>
+  relaxng.c, xmlschemas.c: Fix build on pre-C99 compilers (Chun-wei Fan)<br/>
+  </li>
+
+  <li>Bug Fixes:<br/>
+  Problem resolving relative URIs (Daniel Veillard),<br/>
+  Fix unwanted warnings when switching encodings (Nick Wellnhofer),<br/>
+  Fix signature of xmlSchemaAugmentImportedIDC (Daniel Veillard),<br/>
+  Heap-buffer-overflow read of size 1 in xmlFAParsePosCharGroup (David Kilzer),<br/>
+  Fix NULL pointer deref in xmlFAParseCharClassEsc (Nick Wellnhofer),<br/>
+  Fix infinite loops with push parser in recovery mode (Nick Wellnhofer),<br/>
+  Send xmllint usage error to stderr (Nick Wellnhofer),<br/>
+  Fix NULL deref in xmlParseExternalEntityPrivate (Nick Wellnhofer),<br/>
+  Make sure not to call IS_BLANK_CH when parsing the DTD (Nick Wellnhofer),<br/>
+  Fix xmlHaltParser (Nick Wellnhofer),<br/>
+  Fix pathological performance when outputting charrefs (Nick Wellnhofer),<br/>
+  Fix invalid-source-encoding warnings in testWriter.c (Nick Wellnhofer),<br/>
+  Fix duplicate SAX callbacks for entity content (David Kilzer),<br/>
+  Treat URIs with scheme as absolute in C14N (Nick Wellnhofer),<br/>
+  Fix copy-paste errors in error messages (Nick Wellnhofer),<br/>
+  Fix sanity check in htmlParseNameComplex (Nick Wellnhofer),<br/>
+  Fix potential infinite loop in xmlStringLenDecodeEntities (Nick Wellnhofer),<br/>
+  Reset parser input pointers on encoding failure (Nick Wellnhofer),<br/>
+  Fix memory leak in xmlParseEntityDecl error path (Nick Wellnhofer),<br/>
+  Fix xmlBuildRelativeURI for URIs starting with './' (Nick Wellnhofer),<br/>
+  Fix type confusion in xmlValidateOneNamespace (Nick Wellnhofer),<br/>
+  Fix memory leak in xmlStringLenGetNodeList (Nick Wellnhofer),<br/>
+  Fix NULL pointer deref in xmlDumpElementContent (Daniel Veillard),<br/>
+  Fix memory leak in xmlBufAttrSerializeTxtContent (Nick Wellnhofer),<br/>
+  Stop parser on unsupported encodings (Nick Wellnhofer),<br/>
+  Check for integer overflow in memory debug code (Nick Wellnhofer),<br/>
+  Fix buffer size checks in xmlSnprintfElementContent (Nick Wellnhofer),<br/>
+  Avoid reparsing in xmlParseStartTag2 (Nick Wellnhofer),<br/>
+  Fix undefined behavior in xmlRegExecPushStringInternal (Nick Wellnhofer),<br/>
+  Check XPath exponents for overflow (Nick Wellnhofer),<br/>
+  Check for overflow in xmlXPathIsPositionalPredicate (Nick Wellnhofer),<br/>
+  Fix spurious error message (Nick Wellnhofer),<br/>
+  Fix memory leak in xmlCanonicPath (Nick Wellnhofer),<br/>
+  Fix memory leak in xmlXPathCompareNodeSetValue (Nick Wellnhofer),<br/>
+  Fix memory leak in pattern error path (Nick Wellnhofer),<br/>
+  Fix memory leak in parser error path (Nick Wellnhofer),<br/>
+  Fix memory leaks in XPointer error paths (Nick Wellnhofer),<br/>
+  Fix memory leak in xmlXPathNodeSetMergeAndClear (Nick Wellnhofer),<br/>
+  Fix memory leak in XPath filter optimizations (Nick Wellnhofer),<br/>
+  Fix memory leaks in XPath error paths (Nick Wellnhofer),<br/>
+  Do not leak the new CData node if adding fails (David Tardon),<br/>
+  Prevent unwanted external entity reference (Neel Mehta),<br/>
+  Increase buffer space for port in HTTP redirect support (Daniel Veillard),<br/>
+  Fix more NULL pointer derefs in xpointer.c (Nick Wellnhofer),<br/>
+  Avoid function/data pointer conversion in xpath.c (Nick Wellnhofer),<br/>
+  Fix format string warnings (Nick Wellnhofer),<br/>
+  Disallow namespace nodes in XPointer points (Nick Wellnhofer),<br/>
+  Fix comparison with root node in xmlXPathCmpNodes (Nick Wellnhofer),<br/>
+  Fix attribute decoding during XML schema validation (Alex Henrie),<br/>
+  Fix NULL pointer deref in XPointer range-to (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Improvements:<br/>
+  Updating the spec file to reflect Fedora 24 (Daniel Veillard),<br/>
+  Add const in five places to move 1 KiB to .rdata (Bruce Dawson),<br/>
+  Fix missing part of comment for function xmlXPathEvalExpression() (Daniel Veillard),<br/>
+  Get rid of "blanks wrapper" for parameter entities (Nick Wellnhofer),<br/>
+  Simplify handling of parameter entity references (Nick Wellnhofer),<br/>
+  Deduplicate code in encoding.c (Nick Wellnhofer),<br/>
+  Make HTML parser functions take const pointers (Nick Wellnhofer),<br/>
+  Build test programs only when needed (Nick Wellnhofer),<br/>
+  Fix doc/examples/index.py (Nick Wellnhofer),<br/>
+  Fix compiler warnings in threads.c (Nick Wellnhofer),<br/>
+  Fix empty-body warning in nanohttp.c (Nick Wellnhofer),<br/>
+  Fix cast-align warnings (Nick Wellnhofer),<br/>
+  Fix unused-parameter warnings (Nick Wellnhofer),<br/>
+  Rework entity boundary checks (Nick Wellnhofer),<br/>
+  Don't switch encoding for internal parameter entities (Nick Wellnhofer),<br/>
+  Merge duplicate code paths handling PE references (Nick Wellnhofer),<br/>
+  Test SAX2 callbacks with entity substitution (Nick Wellnhofer),<br/>
+  Support catalog and threads tests under --without-sax1 (Nick Wellnhofer),<br/>
+  Misc fixes for 'make tests' (Nick Wellnhofer),<br/>
+  Initialize keepBlanks in HTML parser (Nick Wellnhofer),<br/>
+  Add test cases for bug 758518 (David Kilzer),<br/>
+  Fix compiler warning in htmlParseElementInternal (Nick Wellnhofer),<br/>
+  Remove useless check in xmlParseAttributeListDecl (Nick Wellnhofer),<br/>
+  Allow zero sized memory input buffers (Nick Wellnhofer),<br/>
+  Add TODO comment in xmlSwitchEncoding (Nick Wellnhofer),<br/>
+  Check for integer overflow in xmlXPathFormatNumber (Nick Wellnhofer),<br/>
+  Make Travis print UBSan stacktraces (Nick Wellnhofer),<br/>
+  Add .travis.yml (Nick Wellnhofer),<br/>
+  Fix expected error output in Python tests (Nick Wellnhofer),<br/>
+  Simplify control flow in xmlParseStartTag2 (Nick Wellnhofer),<br/>
+  Disable LeakSanitizer when running API tests (Nick Wellnhofer),<br/>
+  Avoid out-of-bound array access in API tests (Nick Wellnhofer),<br/>
+  Avoid spurious UBSan errors in parser.c (Nick Wellnhofer),<br/>
+  Parse small XPath numbers more accurately (Nick Wellnhofer),<br/>
+  Rework XPath rounding functions (Nick Wellnhofer),<br/>
+  Fix white space in test output (Nick Wellnhofer),<br/>
+  Fix axis traversal from attribute and namespace nodes (Nick Wellnhofer),<br/>
+  Check for trailing characters in XPath expressions earlier (Nick Wellnhofer),<br/>
+  Rework final handling of XPath results (Nick Wellnhofer),<br/>
+  Make xmlXPathEvalExpression call xmlXPathEval (Nick Wellnhofer),<br/>
+  Remove unused variables (Nick Wellnhofer),<br/>
+  Don't print generic error messages in XPath tests (Nick Wellnhofer)<br/>
+  </li>
+
+  <li>Cleanups:<br/>
+  Fix a couple of misleading indentation errors (Daniel Veillard),<br/>
+  Remove unnecessary calls to xmlPopInput (Nick Wellnhofer)<br/>
+  </li>
+</ul>
 <h3>2.9.4: May 23 2016</h3>
 <ul>
   <li>Security:<br/>
@@ -2141,7 +2331,7 @@
     Hendricks), aliasing bug exposed by gcc4 on s390, xmlTextReaderNext bug
     (Rob Richards), Schemas decimal type fixes (William Brack),
     xmlByteConsumed static buffer (Ben Maurer).</li>
-  <li>improvement: speedup parsing comments and DTDs, dictionnary support for
+  <li>improvement: speedup parsing comments and DTDs, dictionary support for
     hash tables, Schemas Identity constraints (Kasimier), streaming XPath
     subset, xmlTextReaderReadString added (Bjorn Reese), Schemas canonical
     values handling (Kasimier), add xmlTextReaderByteConsumed (Aron
@@ -2361,7 +2551,7 @@
     URI on SYSTEM lookup failure, XInclude parse flags inheritance (William),
     XInclude and XPointer fixes for entities (William), XML parser bug
     reported by Holger Rauch, nanohttp fd leak (William),  regexps char
-    groups '-' handling (William), dictionnary reference counting problems,
+    groups '-' handling (William), dictionary reference counting problems,
     do not close stderr.</li>
   <li>performance patches from Petr Pajas</li>
   <li>Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey)</li>
@@ -2425,14 +2615,14 @@
     Fleck), doc (Sven Zimmerman), I/O example.</li>
   <li>Python bindings: fixes (William), enum support (Stéphane Bidoul),
     structured error reporting (Stéphane Bidoul)</li>
-  <li>XInclude: various fixes for conformance, problem related to dictionnary
+  <li>XInclude: various fixes for conformance, problem related to dictionary
     references (William &amp; me), recursion (William)</li>
   <li>xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred
     Mickautsch),</li>
   <li>xmlSchemas: normalizedString datatype (John Belmonte)</li>
   <li>code cleanup for strings functions (William)</li>
   <li>Windows: compiler patches (Mark Vakoc)</li>
-  <li>Parser optimizations, a few new XPath and dictionnary APIs for future
+  <li>Parser optimizations, a few new XPath and dictionary APIs for future
     XSLT optimizations.</li>
 </ul>
 
@@ -2532,8 +2722,8 @@
     of change</li>
   <li>Increased the library modularity, far more options can be stripped out,
     a --with-minimum configuration will weight around 160KBytes</li>
-  <li>Use per parser and per document dictionnary, allocate names and small
-    text nodes from the dictionnary</li>
+  <li>Use per parser and per document dictionary, allocate names and small
+    text nodes from the dictionary</li>
   <li>Switch to a SAX2 like parser rewrote most of the XML parser core,
     provides namespace resolution and defaulted attributes, minimize memory
     allocations and copies, namespace checking and specific error handling,
@@ -2580,7 +2770,7 @@
     (William), xmlCleanupParser (Marc Liyanage), CDATA output (William), HTTP
     error handling.</li>
   <li>xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for compat
-    testing,  --nodict for building without tree dictionnary, --nocdata to
+    testing,  --nodict for building without tree dictionary, --nocdata to
     replace CDATA by text, --nsclean to remove surperfluous  namespace
     declarations</li>
   <li>added xml2-config --libtool-libs option from Kevin P. Fleming</li>
diff --git a/doc/xmlcatalog.1 b/doc/xmlcatalog.1
index b4a6b22..2fbfaf2 100644
--- a/doc/xmlcatalog.1
+++ b/doc/xmlcatalog.1
@@ -1,7 +1,7 @@
 '\" t
 .\"     Title: xmlcatalog
 .\"    Author: John Fleck <jfleck@inkstain.net>
-.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
 .\"      Date: $Date$
 .\"    Manual: xmlcatalog Manual
 .\"    Source: libxml2
@@ -34,7 +34,6 @@
 \fBxmlcatalog\fR [\fB\-\-sgml\fR | \fB\-\-shell\fR | \fB\-\-create\fR | \fB\-\-del\ \fR\fB\fIVALUE(S)\fR\fR | [\ \fB\-\-add\ \fR\fB\fITYPE\fR\fR\fB\ \fR\fB\fIORIG\fR\fR\fB\ \fR\fB\fIREPLACE\fR\fR\fB\ \fR\ |\ \fB\-\-add\ \fR\fB\fIFILENAME\fR\fR] | \fB\-\-noout\fR | \fB\-\-no\-super\-update\fR | [\fB\-v\fR\ |\ \fB\-\-verbose\fR]] {\fICATALOGFILE\fR} {\fIENTITIES\fR...}
 .SH "DESCRIPTION"
 .PP
-
 \fBxmlcatalog\fR
 is a command line application allowing users to monitor and manipulate
 XML
@@ -50,7 +49,6 @@
 files\&.
 .SH "OPTIONS"
 .PP
-
 \fBxmlcatalog\fR
 accepts the following options (in alphabetical order):
 .PP
@@ -155,6 +153,19 @@
 .RS 4
 Output debugging information\&.
 .RE
+.PP
+Invoking
+\fBxmlcatalog\fR
+non\-interactively without a designated action (imposed with options like
+\fB\-\-add\fR) will result in a lookup of the catalog entry for
+\fIENTITIES\fR
+in the catalog denoted with
+\fICATALOGFILE\fR\&. The corresponding entries will be output to the command line\&. This mode of operation, together with
+\fB\-\-shell\fR
+mode and non\-modifying (i\&.e\&. without
+\fB\-\-noout\fR) direct actions, allows for a special shortcut of the void
+\fICATALOGFILE\fR
+specification (possibly expressed as "" in the shell environment) appointing the default system catalog\&. That simplifies the handling when its exact location is irrelevant but the respective built\-in still needs to be consulted\&.
 .SH "SHELL COMMANDS"
 .PP
 Invoking
@@ -213,7 +224,7 @@
 .PP
 \fBpublic \fR\fB\fIPUBLIC\-ID\fR\fR
 .RS 4
-Execute a Formal Public Identifier look\-up of the catalog entry for
+Execute a Formal Public Identifier lookup of the catalog entry for
 \fIPUBLIC\-ID\fR\&. The corresponding entry will be output to the command line\&.
 .RE
 .PP
@@ -224,7 +235,7 @@
 .PP
 \fBsystem \fR\fB\fISYSTEM\-ID\fR\fR
 .RS 4
-Execute a Formal Public Identifier look\-up of the catalog entry for
+Execute a Formal Public Identifier lookup of the catalog entry for
 \fISYSTEM\-ID\fR\&. The corresponding entry will be output to the command line\&.
 .RE
 .SH "ENVIRONMENT"
@@ -240,7 +251,6 @@
 .RE
 .SH "DIAGNOSTICS"
 .PP
-
 \fBxmlcatalog\fR
 return codes provide information that can be used when calling it from scripts\&.
 .PP
diff --git a/doc/xmlcatalog_man.html b/doc/xmlcatalog_man.html
index d7b02ba..f72cd47 100644
--- a/doc/xmlcatalog_man.html
+++ b/doc/xmlcatalog_man.html
@@ -1,101 +1,140 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets V1.61.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="id2431614"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212; Command line tool to parse and manipulate <span class="acronym">XML</span> or
-      <span class="acronym">SGML</span> catalog files.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><tt class="command">xmlcatalog</tt>  [[--shell] |  [--create] |  [--add <i class="replaceable"><tt>type</tt></i>
-	  <i class="replaceable"><tt>orig</tt></i> <i class="replaceable"><tt>replace</tt></i>] |  [--del <i class="replaceable"><tt>values</tt></i>] |  [--noout] |  [--verbose]] [<tt class="option"><i class="replaceable"><tt>catalogfile</tt></i></tt>] [<tt class="option"><i class="replaceable"><tt>entities</tt></i></tt>]</p></div></div><div class="refsect1" lang="en"><a name="introduction"></a><h2>Introduction</h2><p>
-      <span class="application">xmlcatalog</span> is a command line application
-      allowing users to monitor and manipulate <span class="acronym">XML</span> and
-      <span class="acronym">SGML</span> catalogs. It is included in
-      <span class="application">libxml2</span>.
-    </p><p>
-      Its functions can be invoked from a single command from the command line,
-      or it can perform multiple functions in interactive mode. It can operate
-      on both <span class="acronym">XML</span> and <span class="acronym">SGML</span> files.
-    </p></div><div class="refsect1" lang="en"><a name="cloptions"></a><h2>Command Line Options</h2><div class="variablelist"><dl><dt><span class="term"><tt class="option">--shell</tt> <i class="replaceable"><tt>filename</tt></i></span></dt><dd>
-	    Run a shell
-	    allowing interactive queries on catalog file
-	    <i class="replaceable"><tt>filename</tt></i>.
-	  </dd><dt><span class="term"><tt class="option">--create</tt> <i class="replaceable"><tt>filename</tt></i></span></dt><dd>
-	    Create a new
-	    <span class="acronym">XML</span> catalog. Outputs to stdout, ignoring
-	    <i class="replaceable"><tt>filename</tt></i> unless <tt class="option">--noout</tt> is
-	    used, in which case it creates a new catalog file
-	    <i class="replaceable"><tt>filename</tt></i>.
-	  </dd><dt><span class="term"><tt class="option">--add</tt> <i class="replaceable"><tt>'type'</tt></i> <i class="replaceable"><tt>'orig'</tt></i> <i class="replaceable"><tt>'replace'</tt></i> <i class="replaceable"><tt>filename</tt></i></span></dt><dd><p>
-	    Add an entry to catalog file
-	    <tt class="filename">filename</tt>. <i class="replaceable"><tt>type</tt></i>
-	    indicates the type of entry. Possible types are 'public', 'system', 'uri',
-	    'rewriteSystem', 'rewriteURI', 'delegatePublic', 'delegateSystem',
-	    'delegateURI' and 'nextCatalog'. <i class="replaceable"><tt>'orig'</tt></i> is the original
-	    reference to be replaced, and <i class="replaceable"><tt>'replace'</tt></i>
-	    is the <span class="acronym">URI</span> of the replacement entity to be
-	    used. The <tt class="option">--add</tt> option will not overwrite
-	    <i class="replaceable"><tt>filename</tt></i>, outputing to stdout, unless
-	    <tt class="option">--noout</tt> is used. The <tt class="option">--add</tt> will
-	    always take three parameters even if some of the
-	    <span class="acronym">XML</span> catalog constructs will have only a single
-	    argument.
-
-	  </p><p>
-	    If the <tt class="option">--add</tt> option is used following the
-	    <tt class="option">--sgml</tt> option, only a single argument, a
-	    <i class="replaceable"><tt>filename</tt></i>, is used. This is used to add
-	    the name of a catalog file to an <span class="acronym">SGML</span>
-	    supercatalog, a file that contains references to other included
-	    <span class="acronym">SGML</span> catalog files.
-	  </p></dd><dt><span class="term"><tt class="option">--del</tt> <i class="replaceable"><tt>'values'</tt></i> <i class="replaceable"><tt>filename</tt></i></span></dt><dd>
-	    Remove entries from the catalog file
-	    <i class="replaceable"><tt>filename</tt></i> matching
-	    <i class="replaceable"><tt>'values'</tt></i>. The <tt class="option">--del</tt> option
-	    will not overwrite <i class="replaceable"><tt>filename</tt></i>, outputing to
-	    stdout, unless <tt class="option">--noout</tt> is used.
-	  </dd><dt><span class="term"><tt class="option">--noout</tt></span></dt><dd>
-	    Save output to the named file rather than
-	    outputing to stdout.
-	  </dd><dt><span class="term"><tt class="option">--sgml</tt></span></dt><dd>
-	    Uses SGML Super catalogs for --add and --del options
-	  </dd><dt><span class="term"><tt class="option">-v</tt> or <tt class="option">--verbose</tt></span></dt><dd>
-	    output debugging
-	    information.
-	  </dd></dl></div></div><div class="refsect1" lang="en"><a name="shell"></a><h2>Shell Commands</h2><p>Invoking <span class="application">xmlcatalog</span> with the
-      <tt class="option">--shell</tt> <i class="replaceable"><tt>filename</tt></i> option opens
-    a command line shell allowing interactive access to the catalog file
-      identified by <i class="replaceable"><tt>filename</tt></i>. Invoking the shell
-    provides a command line prompt after which commands can be entered.
-    </p><div class="variablelist"><dl><dt><span class="term"><tt class="option">public</tt> <i class="replaceable"><tt>'PublicID'</tt></i></span></dt><dd>
-	    Execute a
-	    public identifier lookup of the catalog entry for
-	    <i class="replaceable"><tt>'PublicID'</tt></i>. The corresponding entry will be
-	    output to the command line.
-	  </dd><dt><span class="term"><tt class="option">system</tt> <i class="replaceable"><tt>'SystemID'</tt></i></span></dt><dd>
-	    Execute a
-	    public identifier lookup of the catalog entry for
-	    <i class="replaceable"><tt>'SystemID'</tt></i>. The corresponding entry will be
-	    output to the command line.
-	  </dd><dt><span class="term"><tt class="option">add </tt> <i class="replaceable"><tt>'type'</tt></i> <i class="replaceable"><tt>'orig'</tt></i> <i class="replaceable"><tt>'replace'</tt></i></span></dt><dd>
-	    Add an entry to the catalog
-	    file. <i class="replaceable"><tt>type</tt></i> indicates the type of
-	    entry. Possible types are 'public', 'system', 'uri', 'rewriteSystem', 'rewriteURI',
-	    'delegatePublic', 'delegateSystem', 'delegateURI' and 'nextCatalog'. <i class="replaceable"><tt>'orig'</tt></i>
-	    is the original reference to  be replaced, and
-	    <i class="replaceable"><tt>'replace'</tt></i> is the <span class="acronym">URI</span> of the
-	    replacement entity to be used.
-	  </dd><dt><span class="term"><tt class="option">del</tt> <i class="replaceable"><tt>'values'</tt></i></span></dt><dd>
-	    Remove the
-	    catalog entry corresponding to <i class="replaceable"><tt>'values'</tt></i>.
-	  </dd><dt><span class="term"><tt class="option">dump</tt></span></dt><dd>
-	    Print the current catalog.
-	  </dd><dt><span class="term"><tt class="option">debug</tt></span></dt><dd>
-	    Print debugging statements showing the steps
-	    <span class="application">xmlcatalog</span> is executing.
-	  </dd><dt><span class="term"><tt class="option">quiet</tt></span></dt><dd>
-	    Stop printing debugging statements.
-	  </dd><dt><span class="term"><tt class="option">exit</tt></span></dt><dd>
-	    Quit the shell.
-	  </dd></dl></div></div><div class="refsect1" lang="en"><a name="return"></a><h2>Return values</h2><p><span class="application">xmlcatalog</span>'s return codes provide
-    information that can be used when calling it from scripts.</p><p>0: normal</p><p>1: Failed to remove an entry from the catalog</p><p>2: Failed to save to the catalog, check file permissions</p><p>3: Failed to add an entry to the catalog</p><p>4: Failed to lookup and entry in the catalog</p></div><div class="refsect1" lang="en"><h2>Catalogs</h2><p>Catalog behavior can be changed by redirecting
-     queries to the user's own set of catalogs. This can be done by setting the
-     <tt class="varname">XML_CATALOG_FILES</tt> environment variable to a list of
-     catalogs. An empty one should deactivate loading the default
-      <tt class="filename">/etc/xml/catalog</tt> default catalog.</p></div><div class="refsect1" lang="en"><h2>References</h2><p><a href="http://www.xmlsoft.org/" target="_top">libxml web page</a></p><p><a href="http://www.xmlsoft.org/catalog.html" target="_top"><span class="application">libxml</span>
-    catalog support web page:</a></p><p><a href="http://www.jclark.com/sp/catalog.htm" target="_top">James Clark's
-    <span class="acronym">SGML</span> catalog page:</a></p><p><a href="http://www.oasis-open.org/committees/entity/spec.html" target="_top"><span class="acronym">OASIS</span>
-    <span class="acronym">XML</span> catalog specification: </a></p></div></div></body></html>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm45940765506544"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212; 
+		Command line tool to parse and manipulate <acronym class="acronym">XML</acronym>
+		or <acronym class="acronym">SGML</acronym> catalog files.
+	</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmlcatalog</code>  [ <code class="option">--sgml</code>  |   <code class="option">--shell</code>  |   <code class="option">--create</code>  |   <code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code>  |   
+			[ 
+					<code class="option">--add
+					 <em class="replaceable"><code>TYPE</code></em>
+					 <em class="replaceable"><code>ORIG</code></em>
+					 <em class="replaceable"><code>REPLACE</code></em>
+					</code>
+				  |   <code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code> ]		
+		  |   <code class="option">--noout</code>  |   <code class="option">--no-super-update</code>  |   
+			[ <code class="option">-v</code>  |   <code class="option">--verbose</code> ]
+		 ] {<em class="replaceable"><code>CATALOGFILE</code></em>} {<em class="replaceable"><code>ENTITIES</code></em>...}</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
+		<span class="command"><strong>xmlcatalog</strong></span> is a command line application allowing users to monitor and
+		manipulate <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> catalogs. It
+		is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.
+	</p><p>
+		Its functions can be invoked from a single command from the command line,
+		or it can perform multiple functions in interactive mode. It can operate
+		on both <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> files.
+	</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
+		<span class="command"><strong>xmlcatalog</strong></span> accepts the following options (in alphabetical order):
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
+		<code class="option">--add
+		 <em class="replaceable"><code>TYPE</code></em>
+		 <em class="replaceable"><code>ORIG</code></em>
+		 <em class="replaceable"><code>REPLACE</code></em>
+		</code>
+	</span></dt><dd><p>
+			Add an entry to <code class="filename">CATALOGFILE</code>. <em class="replaceable"><code>TYPE</code></em>
+			indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
+			reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
+			is the <acronym class="acronym">URI</acronym> of the replacement entity to be
+			used. The <code class="option">--add</code> option will not overwrite
+			<code class="filename">CATALOGFILE</code>, outputting
+			to <code class="filename">stdout</code>, unless
+			<code class="option">--noout</code> is used. The <code class="option">--add</code> will
+			always take three parameters even if some of the <acronym class="acronym">XML</acronym>
+			catalog constructs will have only a single argument.
+		</p></dd><dt><span class="term"><code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code></span></dt><dd><p>
+			If the <code class="option">--add</code> option is used following
+			the <code class="option">--sgml</code> option, only a single argument,
+			a <em class="replaceable"><code>FILENAME</code></em>, is used. This is used to add
+			the name of a catalog file to an <acronym class="acronym">SGML</acronym> supercatalog,
+			a file that contains references to other included <acronym class="acronym">SGML</acronym>
+			catalog files.
+		</p></dd><dt><span class="term"><code class="option">--create</code></span></dt><dd><p>
+			Create a new <acronym class="acronym">XML</acronym> catalog. Outputs
+			to <code class="filename">stdout</code>,
+			ignoring <em class="replaceable"><code>filename</code></em> unless <code class="option">--noout</code> is
+			used, in which case it creates a new catalog
+			file <em class="replaceable"><code>filename</code></em>.
+		</p></dd><dt><span class="term"><code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
+			Remove entries from <em class="replaceable"><code>CATALOGFILE</code></em>
+			matching <em class="replaceable"><code>VALUE(S)</code></em>. The <code class="option">--del</code>
+			option will not overwrite <em class="replaceable"><code>CATALOGFILE</code></em>,
+			outputting to <code class="filename">stdout</code>,
+			unless <code class="option">--noout</code> is used.
+		</p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
+			Save output to the named file rather than outputting
+			to <code class="filename">stdout</code>.
+		</p></dd><dt><span class="term"><code class="option">--no-super-update</code></span></dt><dd><p>
+			Do not update the <acronym class="acronym">SGML</acronym> super catalog.
+		</p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
+			Run a shell allowing interactive queries on catalog
+			file <em class="replaceable"><code>CATALOGFILE</code></em>. For the set of available
+			commands see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>.
+		</p></dd><dt><span class="term"><code class="option">--sgml</code></span></dt><dd><p>
+			Uses <acronym class="acronym">SGML</acronym> super catalogs for <code class="option">--add</code>
+			and <code class="option">--del</code> options.
+		</p></dd><dt><span class="term"><code class="option">-v</code>, </span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>Output debugging information.</p></dd></dl></div><p>
+		Invoking <span class="command"><strong>xmlcatalog</strong></span> non-interactively without a designated action
+		(imposed with options like <code class="option">--add</code>) will result in a lookup
+		of the catalog entry for <em class="replaceable"><code>ENTITIES</code></em> in the
+		catalog denoted with <em class="replaceable"><code>CATALOGFILE</code></em>. The
+		corresponding entries will be output to the command line. This mode of
+		operation, together with <code class="option">--shell</code> mode and non-modifying
+		(i.e. without <code class="option">--noout</code>) direct actions, allows for
+		a special shortcut of the void <em class="replaceable"><code>CATALOGFILE</code></em>
+		specification (possibly expressed as "" in the shell
+		environment) appointing the default system catalog. That simplifies the
+		handling when its exact location is irrelevant but the respective built-in
+		still needs to be consulted.
+	</p></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
+		Invoking <span class="command"><strong>xmlcatalog</strong></span> with
+		the <code class="option">--shell <em class="replaceable"><code>CATALOGFILE</code></em></code> option opens
+		a command line shell allowing interactive access to the catalog file
+		identified by <em class="replaceable"><code>CATALOGFILE</code></em>. Invoking the shell
+		provides a command line prompt after which the following commands (described in
+		alphabetical order) can be entered.
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
+		<code class="option">add
+		 <em class="replaceable"><code>TYPE</code></em>
+		 <em class="replaceable"><code>ORIG</code></em>
+		 <em class="replaceable"><code>REPLACE</code></em>
+		</code>
+	</span></dt><dd><p>
+			Add an entry to the catalog file. <em class="replaceable"><code>TYPE</code></em>
+			indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
+			reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
+			is the <acronym class="acronym">URI</acronym> of the replacement entity to be
+			used. The <code class="option">--add</code> option will not overwrite
+			<code class="filename">CATALOGFILE</code>, outputting
+			to <code class="filename">stdout</code>, unless
+			<code class="option">--noout</code> is used. The <code class="option">--add</code> will
+			always take three parameters even if some of the <acronym class="acronym">XML</acronym>
+			catalog constructs will have only a single argument.
+		</p></dd><dt><span class="term"><code class="option">debug</code></span></dt><dd><p>
+			Print debugging statements showing the steps <span class="command"><strong>xmlcatalog</strong></span> is executing.
+		</p></dd><dt><span class="term"><code class="option">del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
+			Remove the catalog entry corresponding to <em class="replaceable"><code>VALUE(S)</code></em>.
+		</p></dd><dt><span class="term"><code class="option">dump</code></span></dt><dd><p>Print the current catalog.</p></dd><dt><span class="term"><code class="option">exit</code></span></dt><dd><p>Quit the shell.</p></dd><dt><span class="term"><code class="option">public <em class="replaceable"><code>PUBLIC-ID</code></em></code></span></dt><dd><p>
+			Execute a Formal Public Identifier lookup of the catalog entry
+			for <em class="replaceable"><code>PUBLIC-ID</code></em>. The corresponding entry will be
+			output to the command line.
+		</p></dd><dt><span class="term"><code class="option">quiet</code></span></dt><dd><p>Stop printing debugging statements.</p></dd><dt><span class="term"><code class="option">system <em class="replaceable"><code>SYSTEM-ID</code></em></code></span></dt><dd><p>
+			Execute a Formal Public Identifier lookup of the catalog entry
+			for <em class="replaceable"><code>SYSTEM-ID</code></em>. The corresponding entry will be
+			output to the command line.
+		</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
+			queries to the user's own set of catalogs. This can be done by setting
+			the <code class="envar">XML_CATALOG_FILES</code> environment variable to a list
+			of catalogs. An empty one should deactivate loading the
+			default <code class="filename">/etc/xml/catalog</code> catalog.
+		</p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
+		<span class="command"><strong>xmlcatalog</strong></span> return codes provide information that can be used when
+		calling it from scripts.
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Failed to remove an entry from the catalog</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Failed to save to the catalog, check file permissions</p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Failed to add an entry to the catalog</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Failed to look up an entry in the catalog</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
+	</p><p>
+		More information can be found at
+		</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="http://www.xmlsoft.org/" target="_top">http://www.xmlsoft.org/</a>
+				</p></li><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> catalog support web page
+					at <a class="ulink" href="http://www.xmlsoft.org/catalog.html" target="_top">http://www.xmlsoft.org/catalog.html</a>
+				</p></li><li class="listitem"><p>James Clark's <acronym class="acronym">SGML</acronym> catalog
+					page <a class="ulink" href="http://www.jclark.com/sp/catalog.htm" target="_top">http://www.jclark.com/sp/catalog.htm</a>
+				</p></li><li class="listitem"><p><acronym class="acronym">OASIS</acronym> <acronym class="acronym">XML</acronym> catalog specification
+					<a class="ulink" href="http://www.oasis-open.org/committees/entity/spec.html" target="_top">http://www.oasis-open.org/committees/entity/spec.html</a>
+				</p></li></ul></div><p>
+	</p></div></div></body></html>
diff --git a/doc/xmlcatalog_man.xml b/doc/xmlcatalog_man.xml
index 049ed8f..b3ce8b2 100644
--- a/doc/xmlcatalog_man.xml
+++ b/doc/xmlcatalog_man.xml
@@ -230,6 +230,21 @@
 		</varlistentry>
 	
 	</variablelist>
+
+	<para>
+		Invoking &xmlcatalog; non-interactively without a designated action
+		(imposed with options like <option>--add</option>) will result in a lookup
+		of the catalog entry for <replaceable>ENTITIES</replaceable> in the
+		catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
+		corresponding entries will be output to the command line. This mode of
+		operation, together with <option>--shell</option> mode and non-modifying
+		(i.e. without <option>--noout</option>) direct actions, allows for
+		a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
+		specification (possibly expressed as &quot;&quot; in the shell
+		environment) appointing the default system catalog. That simplifies the
+		handling when its exact location is irrelevant but the respective built-in
+		still needs to be consulted.
+	</para>
 </refsect1>
 
 <refsect1 id="shell">
@@ -315,7 +330,7 @@
 	<term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
 	<listitem>
 		<para>
-			Execute a Formal Public Identifier look-up of the catalog entry
+			Execute a Formal Public Identifier lookup of the catalog entry
 			for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
 			output to the command line.
 		</para>
@@ -333,7 +348,7 @@
 	<term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
 	<listitem>
 		<para>
-			Execute a Formal Public Identifier look-up of the catalog entry
+			Execute a Formal Public Identifier lookup of the catalog entry
 			for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
 			output to the command line.
 		</para>
diff --git a/doc/xmllint.html b/doc/xmllint.html
index 0a55877..5fc52c5 100644
--- a/doc/xmllint.html
+++ b/doc/xmllint.html
@@ -1,175 +1,162 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets V1.61.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="id2876302"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <span class="acronym">XML</span> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><tt class="command">xmllint</tt>  [[--version] |  [--debug] |  [--shell] |  [--debugent] |  [--copy] |  [--recover] |  [--noent] |  [--noout] |  [--nonet] |  [--htmlout] |  [--nowrap] |  [--valid] |  [--postvalid] |  [--dtdvalid <i class="replaceable"><tt>URL</tt></i>] |  [--dtdvalidfpi <i class="replaceable"><tt>FPI</tt></i>] |  [--timing] |  [--output <i class="replaceable"><tt>file</tt></i>] |  [--repeat] |  [--insert] |  [--compress] |  [--html] |  [--xmlout] |  [--push] |  [--memory] |  [--maxmem <i class="replaceable"><tt>nbbytes</tt></i>] |  [--nowarning] |  [--noblanks] |  [--nocdata] |  [--format] |  [--encode <i class="replaceable"><tt>encoding</tt></i>] |  [--dropdtd] |  [--nsclean] |  [--testIO] |  [--catalogs] |  [--nocatalogs] |  [--auto] |  [--xinclude] |  [--noxincludenode] |  [--loaddtd] |  [--dtdattr] |  [--stream] |  [--walker] |  [--pattern <i class="replaceable"><tt>patternvalue</tt></i>] |  [--chkregister] |  [--relaxng] |  [--schema] |  [--c14n]] [<tt class="option"><i class="replaceable"><tt>xmlfile</tt></i></tt>]</p></div></div><div class="refsect1" lang="en"><a name="introduction"></a><h2>Introduction</h2><p>
-      The xmllint program parses one or more XML files, specified on the
-      command line as <i class="replaceable"><tt>xmlfile</tt></i>. It prints various
-      types of output, depending upon the options selected. It is useful for
-      detecting errors both in <span class="acronym">XML</span> code and in the
-      <span class="acronym">XML</span> parser itself.
-    </p><p>
-      It is included in <span class="application">libxml2</span>.
-    </p></div><div class="refsect1" lang="en"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><tt class="option">--version</tt></span></dt><dd>
-	    Display the version of
-	    <span class="application">libxml2</span> used.
-	  </dd><dt><span class="term"><tt class="option">--debug</tt></span></dt><dd>
-	    Parse a file and output an annotated tree of the
-	    in-memory version of the document.
-	  </dd><dt><span class="term"><tt class="option">--shell</tt></span></dt><dd>
-	    Run a navigating shell. Details on available commands in shell mode
-	    are below.
-	  </dd><dt><span class="term"><tt class="option">--debugent</tt></span></dt><dd>
-	    Debug the entities defined in the document.
-	  </dd><dt><span class="term"><tt class="option">--copy</tt> </span></dt><dd>
-	    Test the internal copy implementation.
-	  </dd><dt><span class="term"><tt class="option">--recover</tt></span></dt><dd>
-	    Output any parsable portions of an invalid
-	    document.
-	  </dd><dt><span class="term"><tt class="option">--noent</tt></span></dt><dd>
-	    Substitute entity values for entity
-	    references. By default, <span class="application">xmllint</span> leaves entity
-	    references in place.
-	  </dd><dt><span class="term"><tt class="option">--nocdata</tt></span></dt><dd>
-	    Substitute CDATA section by equivalent text nodes.
-	  </dd><dt><span class="term"><tt class="option">--nsclean</tt></span></dt><dd>
-	    Remove redundant namespace declarations.
-	  </dd><dt><span class="term"><tt class="option">--noout</tt></span></dt><dd>
-	    Suppress output. By default,
-	    <span class="application">xmllint</span> outputs the result tree.
-	  </dd><dt><span class="term"><tt class="option">--htmlout</tt></span></dt><dd>
-	    Output results as an <span class="acronym">HTML</span>
-	    file. This causes <span class="application">xmllint</span> to output
-	    the necessary <span class="acronym">HTML</span> tags surrounding the result tree
-	    output so the results can be displayed in a browser. 
-	  </dd><dt><span class="term"><tt class="option">--nowrap </tt></span></dt><dd>
-	    Do not output HTML doc wrapper.
-	  </dd><dt><span class="term"><tt class="option">--valid </tt></span></dt><dd>
-	    Determine if the document is a valid instance
-	    of the included Document Type Definition (<span class="acronym">DTD</span>). A
-	    <span class="acronym">DTD</span> to be validated against also can be specified at
-	    the command line using the <tt class="option">--dtdvalid</tt> option. By default,
-	    <span class="application">xmllint</span> also checks to determine if the
-	    document is well-formed.
-	  </dd><dt><span class="term"><tt class="option">--postvalid</tt></span></dt><dd>
-	    Validate after parsing is completed.
-	  </dd><dt><span class="term"> <tt class="option">--dtdvalid</tt> <i class="replaceable"><tt>URL</tt></i></span></dt><dd>
-	    Use the
-      <span class="acronym">DTD</span> specified by <i class="replaceable"><tt>URL</tt></i> for
-      validation.
-	  </dd><dt><span class="term"> <tt class="option">--dtdvalidfpi</tt> <i class="replaceable"><tt>FPI</tt></i></span></dt><dd>
-	    Use the
-      <span class="acronym">DTD</span> specified by the Public Identifier
-      <i class="replaceable"><tt>FPI</tt></i> for validation, note that this
-      will require a Catalog exporting that Public Identifier to work.
-	  </dd><dt><span class="term"><tt class="option">--timing</tt></span></dt><dd>
-	    Output information about the time it takes
-	    <span class="application">xmllint</span> to perform the various steps.
-	  </dd><dt><span class="term"><tt class="option">--output</tt> <i class="replaceable"><tt>file</tt></i></span></dt><dd>Define a file path where xmllint will save the result of
-	  parsing. Usually the programs build a tree and save it on stdout, with
-	  this option the result XML instance will be saved onto a file.</dd><dt><span class="term"><tt class="option">--repeat</tt></span></dt><dd>
-	    Repeat 100 times, for timing or profiling.
-	  </dd><dt><span class="term"><tt class="option">--insert</tt></span></dt><dd>
-	    Test for valid insertions.
-	  </dd><dt><span class="term"><tt class="option">--compress</tt></span></dt><dd>
-	    Turn on gzip compression of output.
-	  </dd><dt><span class="term"><tt class="option">--html</tt></span></dt><dd>
-	    Use the <span class="acronym">HTML</span> parser.
-	  </dd><dt><span class="term"><tt class="option">--xmlout</tt></span></dt><dd>Used in conjunction with <tt class="option">--html</tt>. Usually
-  when HTML is parsed the document is saved with the HTML serializer, but with
-  this option the resulting document is saved with the XML serializer. This is
-  primarily used to generate XHTML from HTML input.</dd><dt><span class="term"><tt class="option">--push</tt></span></dt><dd>
-	    Use the push mode of the parser.
-	  </dd><dt><span class="term"><tt class="option">--memory</tt></span></dt><dd>
-	   Parse from memory.
-	  </dd><dt><span class="term"><tt class="option">--maxmem</tt> <i class="replaceable"><tt>nnbytes</tt></i></span></dt><dd>Test the parser memory
-  support. <i class="replaceable"><tt>nnbytes</tt></i> is the maximum number of bytes the
-  library is allowed to allocate. This can also be used to make sure batch
-  processing of XML files will not exhaust the virtual memory of the server
-  running them.</dd><dt><span class="term"><tt class="option">--nowarning</tt></span></dt><dd>
-	   Do not emit warnings from the parser and/or validator.
-	  </dd><dt><span class="term"><tt class="option">--noblanks</tt></span></dt><dd>
-	   Drop ignorable blank spaces.
-	  </dd><dt><span class="term"><tt class="option">--format</tt></span></dt><dd>
-	   Reformat and reindent the output. The $XMLLINT_INDENT
-	   environment variable controls the indentation (default 
-	   value is two spaces "  ").
-	  </dd><dt><span class="term"><tt class="option">--testIO</tt></span></dt><dd>
-	   Test user input/output support.
-	  </dd><dt><span class="term"><tt class="option">--encode</tt> <i class="replaceable"><tt>encoding</tt></i></span></dt><dd>
-	   Output in the given encoding.
-	  </dd><dt><span class="term"><tt class="option">--catalogs</tt></span></dt><dd>
-	   Use the catalogs from $SGML_CATALOG_FILES. Otherwise /etc/xml/catalog
-	   is used by default.
-	  </dd><dt><span class="term"><tt class="option">--nocatalogs</tt></span></dt><dd>
-	   Do not use any catalogs.
-	  </dd><dt><span class="term"><tt class="option">--auto</tt></span></dt><dd>
-	   Generate a small document for testing purposes.
-	  </dd><dt><span class="term"><tt class="option">--xinclude</tt></span></dt><dd>
-	   Do XInclude processing.
-	  </dd><dt><span class="term"><tt class="option">--noxincludenode</tt></span></dt><dd>
-	   Do XInclude processing but do not generate XInclude start and end
-	   nodes.
-	  </dd><dt><span class="term"><tt class="option">--loaddtd</tt></span></dt><dd>
-	   Fetch external DTD.
-	  </dd><dt><span class="term"><tt class="option">--dtdattr</tt></span></dt><dd>
-	   Fetch external DTD and populate the tree with inherited attributes.
-	  </dd><dt><span class="term"><tt class="option">--dropdtd</tt></span></dt><dd>
-	    Remove <span class="acronym">DTD</span> from output.
-	  </dd><dt><span class="term"><tt class="option">--stream</tt></span></dt><dd>Use streaming API - useful when  used  in combination with
-              --relaxng or --valid options for validation of files that are
-	    too large to be held in memory.</dd><dt><span class="term"><tt class="option">--walker</tt></span></dt><dd>Test the walker module, which is a reader interface but for a
-  document tree, instead of using the reader API on an unparsed document it
-  works on a existing in-memory tree. Used in debugging.</dd><dt><span class="term"><tt class="option">--chkregister</tt></span></dt><dd>Turn on node registration. Useful for developers testing
-	  libxml2 node tracking code.</dd><dt><span class="term"><tt class="option">--pattern</tt> <i class="replaceable"><tt>patternvalue</tt></i></span></dt><dd>Used to exercise the pattern recognition engine, which can be
-	  used with the reader interface to the parser. It allows to select some
-	  nodes in the document based on an XPath (subset) expression. Used for
-	  debugging.</dd><dt><span class="term"><tt class="option">--relaxng</tt> <i class="replaceable"><tt>schema</tt></i></span></dt><dd>Use RelaxNG file named <i class="replaceable"><tt>schema</tt></i> for
-	  validation.</dd><dt><span class="term"><tt class="option">--schema</tt> <i class="replaceable"><tt>schema</tt></i></span></dt><dd>Use a W3C XML Schema file named <i class="replaceable"><tt>schema</tt></i> for validation.</dd><dt><span class="term">
-      <tt class="option">--c14n</tt></span></dt><dd>Use the W3C XML Canonicalisation (C14N) to
-serialize the result of parsing to stdout. It keeps comments in
-the result.</dd></dl></div></div><div class="refsect1" lang="en"><a name="shell"></a><h2>Shell</h2><p>
-      <span class="application">xmllint</span> offers an interactive shell mode
-      invoked with the <tt class="option">--shell</tt> command. Available commands in
-      shell mode include:
-    </p><div class="variablelist"><dl><dt><span class="term"><tt class="option">base</tt></span></dt><dd>
-	    display XML base of the node
-	  </dd><dt><span class="term"><tt class="option">bye</tt></span></dt><dd>
-	    leave shell
-	  </dd><dt><span class="term"><tt class="option">cat <i class="replaceable"><tt>node</tt></i></tt></span></dt><dd>
-	    Display node if given or current node.
-	  </dd><dt><span class="term"><tt class="option">cd <i class="replaceable"><tt>path</tt></i></tt></span></dt><dd>
-	    Change the current node to <i class="replaceable"><tt>path</tt></i> (if given
-	    and unique) or root if no argument given.
-	  </dd><dt><span class="term"><tt class="option">dir <i class="replaceable"><tt>path</tt></i></tt></span></dt><dd>
-	    Dumps information about the node (namespace, attributes, content).
-	  </dd><dt><span class="term"><tt class="option">du <i class="replaceable"><tt>path</tt></i></tt></span></dt><dd>
-	    Show the structure of the subtree under path or the current node.
-	  </dd><dt><span class="term"><tt class="option">exit</tt></span></dt><dd>
-	    Leave the shell.
-	  </dd><dt><span class="term"><tt class="option">help</tt></span></dt><dd>
-	    Show this help.
-	  </dd><dt><span class="term"><tt class="option">free</tt></span></dt><dd>
-	    Display memory usage.
-	  </dd><dt><span class="term"><tt class="option">load <i class="replaceable"><tt>name</tt></i></tt></span></dt><dd>
-	    Load a new document with the given name.
-	  </dd><dt><span class="term"><tt class="option">ls <i class="replaceable"><tt>path</tt></i></tt></span></dt><dd>
-	    List contents of <i class="replaceable"><tt>path</tt></i> (if given) or the
-	    current directory.
-	  </dd><dt><span class="term"><tt class="option">pwd</tt></span></dt><dd>
-	    Display the path to the current node.
-	  </dd><dt><span class="term"><tt class="option">quit</tt></span></dt><dd>
-	    Leave the shell.
-	  </dd><dt><span class="term"><tt class="option">save <i class="replaceable"><tt>name</tt></i></tt></span></dt><dd>
-	    Saves the current document to <i class="replaceable"><tt>name</tt></i> if
-	    given or to the original name.
-	  </dd><dt><span class="term"><tt class="option">validate</tt></span></dt><dd>
-	    Check the document for error.
-	  </dd><dt><span class="term"><tt class="option">write <i class="replaceable"><tt>name</tt></i></tt></span></dt><dd>
-	    Write the current node to the given filename.
-	  </dd></dl></div></div><div class="refsect1" lang="en"><h2>Catalogs</h2><p>Catalog behavior can be changed by redirecting
-     queries to the user's own set of catalogs. This can be done by setting the
-     <tt class="varname">XML_CATALOG_FILES</tt> environment variable to a list of
-     catalogs. An empty one should deactivate loading the default
-      <tt class="filename">/etc/xml/catalog</tt> default catalog.</p></div><div class="refsect1" lang="en"><h2>Debugging Catalogs</h2><p>Setting the environment variable <tt class="varname">XML_DEBUG_CATALOG</tt>
-    using the command <b class="command">"export XML_DEBUG_CATALOG="</b>
-    outputs debugging information related to catalog operations.</p></div><div class="refsect1" lang="en"><h2>Error Return Codes</h2><p>On the completion of execution, <span class="application">Xmllint</span>
-    returns the following error codes:</p><div class="variablelist"><dl><dt><span class="term">0</span></dt><dd>No error</dd><dt><span class="term">1</span></dt><dd>Unclassified</dd><dt><span class="term">2</span></dt><dd>Error in DTD</dd><dt><span class="term">3</span></dt><dd>Validation error</dd><dt><span class="term">4</span></dt><dd>Validation error</dd><dt><span class="term">5</span></dt><dd>Error in schema compilation</dd><dt><span class="term">6</span></dt><dd>Error writing output</dd><dt><span class="term">7</span></dt><dd>Error in pattern (generated when
-	  [<span class="optional">--pattern</span>] option is used)</dd><dt><span class="term">8</span></dt><dd>Error in Reader registration (generated when
-	  [<span class="optional">--chkregister</span>] option is used)</dd><dt><span class="term">9</span></dt><dd>Out of memory error</dd></dl></div></div></div></body></html>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code>  [ <code class="option">--version</code>  |   <code class="option">--debug</code>  |   <code class="option">--shell</code>  |   <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code>  |   <code class="option">--debugent</code>  |   <code class="option">--copy</code>  |   <code class="option">--recover</code>  |   <code class="option">--noent</code>  |   <code class="option">--noout</code>  |   <code class="option">--nonet</code>  |   <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code>  |   <code class="option">--load-trace</code>  |   <code class="option">--htmlout</code>  |   <code class="option">--nowrap</code>  |   <code class="option">--valid</code>  |   <code class="option">--postvalid</code>  |   <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code>  |   <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code>  |   <code class="option">--timing</code>  |   <code class="option">--output <em class="replaceable"><code>FILE</code></em></code>  |   <code class="option">--repeat</code>  |   <code class="option">--insert</code>  |   <code class="option">--compress</code>  |   <code class="option">--html</code>  |   <code class="option">--xmlout</code>  |   <code class="option">--push</code>  |   <code class="option">--memory</code>  |   <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code>  |   <code class="option">--nowarning</code>  |   <code class="option">--noblanks</code>  |   <code class="option">--nocdata</code>  |   <code class="option">--format</code>  |   <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code>  |   <code class="option">--dropdtd</code>  |   <code class="option">--nsclean</code>  |   <code class="option">--testIO</code>  |   <code class="option">--catalogs</code>  |   <code class="option">--nocatalogs</code>  |   <code class="option">--auto</code>  |   <code class="option">--xinclude</code>  |   <code class="option">--noxincludenode</code>  |   <code class="option">--loaddtd</code>  |   <code class="option">--dtdattr</code>  |   <code class="option">--stream</code>  |   <code class="option">--walker</code>  |   <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code>  |   <code class="option">--chkregister</code>  |   <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--c14n</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>...  |   - }</p></div><div class="cmdsynopsis"><p><code class="command">xmllint</code>   <code class="option">--help</code> </p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
+		The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
+		specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
+		(or the standard input if the filename provided
+		is <span class="bold"><strong>-</strong></span> ). It prints various types of
+		output, depending upon the options selected. It is useful for detecting
+		errors both in <acronym class="acronym">XML</acronym> code and in
+		the <acronym class="acronym">XML</acronym> parser itself.
+	</p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
+		<span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
+			Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
+			Otherwise <acronym class="acronym">XML</acronym> catalogs starting
+			from <code class="filename">/etc/xml/catalog</code> are used by default.
+		</p></dd><dt><span class="term"><code class="option">--chkregister</code></span></dt><dd><p>
+			Turn on node registration. Useful for developers testing <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> node tracking code.
+		</p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
+			Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
+		</p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code></span></dt><dd><p>
+			Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
+			serialize the result of parsing to <code class="filename">stdout</code>.
+			It keeps comments in the result.
+		</p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
+			Use the <acronym class="acronym">DTD</acronym> specified by
+			an <em class="replaceable"><code>URL</code></em> for validation.
+		</p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
+			Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
+			Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
+			will require a catalog exporting that Formal Public Identifier to work.
+		</p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
+			Parse a file and output an annotated tree of the
+			in-memory version of the document.
+		</p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
+			Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
+			inherited attributes.
+		</p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
+			Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
+			environment variable controls the indentation. The default value is two
+			spaces "  ").
+		</p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd><p>Print out a short usage summary for <span class="command"><strong>xmllint</strong></span>.</p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
+			Output results as an <acronym class="acronym">HTML</acronym> file. This
+			causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
+			tags surrounding the result tree output so the results can be
+			displayed/viewed in a browser.
+		</p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
+			Display all the documents loaded during the processing
+			to <code class="filename">stderr</code>.
+		</p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
+			Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
+			is the maximum number of bytes the library is allowed to allocate.
+			This can also be used to make sure batch processing
+			of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
+			of the server running them.
+		</p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
+			Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
+			leaves entity references in place.
+		</p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
+			Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
+		</p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
+			Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
+		</p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
+			Do XInclude processing but do not generate XInclude start and end nodes.
+		</p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
+			Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
+			Usually the programs build a tree and save it
+			on <code class="filename">stdout</code>, with this option
+			the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
+		</p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
+			Use the (space- or colon-separated) list of filesystem paths specified
+			by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
+			entities. Enclose space-separated lists by quotation marks.
+		</p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
+			Used to exercise the pattern recognition engine, which can be used
+			with the reader interface to the parser. It allows to select some
+			nodes in the document based on an XPath (subset) expression. Used
+			for debugging.
+		</p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
+			Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
+			for validation.
+		</p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
+			Use a W3C <acronym class="acronym">XML</acronym> Schema file
+			named <em class="replaceable"><code>SCHEMA</code></em> for validation.
+		</p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
+			Run a navigating shell. Details on available commands in shell mode
+			are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>).
+		</p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
+			Run an XPath expression given as argument and print the
+			result. In case of a nodeset result, each node in the
+			node set is serialized in full in the output. In case
+			of an empty node set the "XPath set is empty" result
+			will be shown and an error exit code will be returned.
+		</p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
+			Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
+			with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
+			for validation of files that are too large to be held in memory.
+		</p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
+			Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
+			various steps.
+		</p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
+			Determine if the document is a valid instance of the included
+			Document Type Definition (<acronym class="acronym">DTD</acronym>).
+			A <acronym class="acronym">DTD</acronym> to be validated against also can be
+			specified at the command line using the <code class="option">--dtdvalid</code>
+			option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
+			document is well-formed.
+		</p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
+			Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
+		</p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
+			Test the walker module, which is a reader interface but for a
+			document tree, instead of using the reader <acronym class="acronym">API</acronym> on
+			an unparsed document it works on an existing in-memory tree. Used for
+			debugging.
+		</p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
+			Used in conjunction with <code class="option">--html</code>. Usually
+			when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
+			the <acronym class="acronym">HTML</acronym> serializer. But with this option the
+			resulting document is saved with the <acronym class="acronym">XML</acronym>
+			serializer. This is primarily used to
+			generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
+		</p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
+		<span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
+		the <code class="option">--shell</code> command. Available commands in shell mode
+		include (in alphabetical order):
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+			Change the current node to the given path (if unique) or root if no
+			argument is given.
+		</p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+			Dumps information about the node (namespace, attributes, content).
+		</p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+			Show the structure of the subtree under the given path or the current node.
+		</p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>free</strong></span></span></dt><dd><p>Display memory usage.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
+			Save the current document to the given filename or to the original name.
+		</p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
+			queries to the user's own set of catalogs. This can be done by setting
+			the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
+			of catalogs. An empty one should deactivate loading the
+			default <code class="filename">/etc/sgml/catalog</code> catalog.
+		</p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
+			queries to the user's own set of catalogs. This can be done by setting
+			the <code class="envar">XML_CATALOG_FILES</code> environment variable to a list
+			of catalogs. An empty one should deactivate loading the
+			default <code class="filename">/etc/xml/catalog</code> catalog.
+		</p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
+			to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
+			command outputs debugging information related to catalog operations.
+		</p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
+			controls the indentation. The default value is two spaces "  ".
+		</p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
+		<span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
+		calling it from scripts.
+	</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
+			Error in pattern (generated when <code class="option">--pattern</code> option is used)
+		</p></dd><dt><span class="term"><span class="errorcode">8</span></span></dt><dd><p>
+			Error in Reader registration (generated
+			when <code class="option">--chkregister</code> option is used)
+		</p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
+	</p><p>
+		More information can be found at
+		</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="http://www.xmlsoft.org/" target="_top">http://www.xmlsoft.org/</a>
+				</p></li><li class="listitem"><p>W3C <acronym class="acronym">XSLT</acronym> page <a class="ulink" href="http://www.w3.org/TR/xslt" target="_top">http://www.w3.org/TR/xslt</a>
+				</p></li></ul></div><p>
+	</p></div></div></body></html>
diff --git a/elfgcchack.h b/elfgcchack.h
index 8c52884..5ac93bf 100644
--- a/elfgcchack.h
+++ b/elfgcchack.h
@@ -11,7 +11,7 @@
 #ifdef IN_LIBXML
 #ifdef __GNUC__
 #ifdef PIC
-#ifdef linux
+#ifdef __linux__
 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
 
 #include "libxml/c14n.h"
diff --git a/encoding.c b/encoding.c
index e49c7f8..de7b511 100644
--- a/encoding.c
+++ b/encoding.c
@@ -110,6 +110,9 @@
   if (conv == NULL)
     return NULL;
 
+  conv->pivot_source = conv->pivot_buf;
+  conv->pivot_target = conv->pivot_buf;
+
   conv->uconv = ucnv_open(name, &status);
   if (U_FAILURE(status))
     goto error;
@@ -354,8 +357,14 @@
 {
     int len;
 
-    if ((out == NULL) || (inb == NULL) || (outlen == NULL) || (inlenb == NULL))
+    if ((out == NULL) || (outlen == NULL) || (inlenb == NULL))
 	return(-1);
+    if (inb == NULL) {
+        /* inb == NULL means output is initialized. */
+        *outlen = 0;
+        *inlenb = 0;
+        return(0);
+    }
     if (*outlen > *inlenb) {
 	len = *inlenb;
     } else {
@@ -1844,6 +1853,7 @@
  * @outlen:  the length of @out
  * @in:  a pointer to an array of ISO Latin 1 chars
  * @inlen:  the length of @in
+ * @flush: if true, indicates end of input
  *
  * Returns 0 if success, or
  *     -1 by lack of space, or
@@ -1857,7 +1867,7 @@
  */
 static int
 xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
-                const unsigned char *in, int *inlen) {
+                const unsigned char *in, int *inlen, int flush) {
     const char *ucv_in = (const char *) in;
     char *ucv_out = (char *) out;
     UErrorCode err = U_ZERO_ERROR;
@@ -1867,33 +1877,31 @@
         return(-1);
     }
 
-    /*
-     * TODO(jungshik)
-     * 1. is ucnv_convert(To|From)Algorithmic better?
-     * 2. had we better use an explicit pivot buffer?
-     * 3. error returned comes from 'fromUnicode' only even
-     *    when toUnicode is true !
-     */
     if (toUnicode) {
         /* encoding => UTF-16 => UTF-8 */
         ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
-                       &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
-                       0, TRUE, &err);
+                       &ucv_in, ucv_in + *inlen, cd->pivot_buf,
+                       &cd->pivot_source, &cd->pivot_target,
+                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
     } else {
         /* UTF-8 => UTF-16 => encoding */
         ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
-                       &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
-                       0, TRUE, &err);
+                       &ucv_in, ucv_in + *inlen, cd->pivot_buf,
+                       &cd->pivot_source, &cd->pivot_target,
+                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
     }
     *inlen = ucv_in - (const char*) in;
     *outlen = ucv_out - (char *) out;
-    if (U_SUCCESS(err))
+    if (U_SUCCESS(err)) {
+        /* reset pivot buf if this is the last call for input (flush==TRUE) */
+        if (flush)
+            cd->pivot_source = cd->pivot_target = cd->pivot_buf;
         return 0;
+    }
     if (err == U_BUFFER_OVERFLOW_ERROR)
         return -1;
     if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
         return -2;
-    /* if (err == U_TRUNCATED_CHAR_FOUND) */
     return -3;
 }
 #endif /* LIBXML_ICU_ENABLED */
@@ -1904,6 +1912,64 @@
  *									*
  ************************************************************************/
 
+static int
+xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
+                 int *outlen, const unsigned char *in, int *inlen, int flush) {
+    int ret;
+    (void)flush;
+
+    if (handler->input != NULL) {
+        ret = handler->input(out, outlen, in, inlen);
+    }
+#ifdef LIBXML_ICONV_ENABLED
+    else if (handler->iconv_in != NULL) {
+        ret = xmlIconvWrapper(handler->iconv_in, out, outlen, in, inlen);
+    }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+    else if (handler->uconv_in != NULL) {
+        ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen,
+                              flush);
+    }
+#endif /* LIBXML_ICU_ENABLED */
+    else {
+        *outlen = 0;
+        *inlen = 0;
+        ret = -2;
+    }
+
+    return(ret);
+}
+
+/* Returns -4 if no output function was found. */
+static int
+xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
+                  int *outlen, const unsigned char *in, int *inlen) {
+    int ret;
+
+    if (handler->output != NULL) {
+        ret = handler->output(out, outlen, in, inlen);
+    }
+#ifdef LIBXML_ICONV_ENABLED
+    else if (handler->iconv_out != NULL) {
+        ret = xmlIconvWrapper(handler->iconv_out, out, outlen, in, inlen);
+    }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+    else if (handler->uconv_out != NULL) {
+        ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen,
+                              TRUE);
+    }
+#endif /* LIBXML_ICU_ENABLED */
+    else {
+        *outlen = 0;
+        *inlen = 0;
+        ret = -4;
+    }
+
+    return(ret);
+}
+
 /**
  * xmlCharEncFirstLineInt:
  * @handler:	char enconding transformation data structure
@@ -1922,7 +1988,7 @@
 int
 xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
                        xmlBufferPtr in, int len) {
-    int ret = -2;
+    int ret;
     int written;
     int toconv;
 
@@ -1953,33 +2019,13 @@
 	written = out->size - out->use - 1;
     }
 
-    if (handler->input != NULL) {
-	ret = handler->input(&out->content[out->use], &written,
-	                     in->content, &toconv);
-	xmlBufferShrink(in, toconv);
-	out->use += written;
-	out->content[out->use] = 0;
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (handler->iconv_in != NULL) {
-	ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
-	                      &written, in->content, &toconv);
-	xmlBufferShrink(in, toconv);
-	out->use += written;
-	out->content[out->use] = 0;
-	if (ret == -1) ret = -3;
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (handler->uconv_in != NULL) {
-	ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
-	                      &written, in->content, &toconv);
-	xmlBufferShrink(in, toconv);
-	out->use += written;
-	out->content[out->use] = 0;
-	if (ret == -1) ret = -3;
-    }
-#endif /* LIBXML_ICU_ENABLED */
+    ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
+                           in->content, &toconv, 0);
+    xmlBufferShrink(in, toconv);
+    out->use += written;
+    out->content[out->use] = 0;
+    if (ret == -1) ret = -3;
+
 #ifdef DEBUG_ENCODING
     switch (ret) {
         case 0:
@@ -2049,7 +2095,7 @@
 int
 xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
 {
-    int ret = -2;
+    int ret;
     size_t written;
     size_t toconv;
     int c_in;
@@ -2091,32 +2137,13 @@
 
     c_in = toconv;
     c_out = written;
-    if (input->encoder->input != NULL) {
-        ret = input->encoder->input(xmlBufEnd(out), &c_out,
-                                    xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (input->encoder->iconv_in != NULL) {
-        ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (input->encoder->uconv_in != NULL) {
-        ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICU_ENABLED */
+    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
+                           xmlBufContent(in), &c_in, 0);
+    xmlBufShrink(in, c_in);
+    xmlBufAddLen(out, c_out);
+    if (ret == -1)
+        ret = -3;
+
     switch (ret) {
         case 0:
 #ifdef DEBUG_ENCODING
@@ -2175,7 +2202,7 @@
 int
 xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
 {
-    int ret = -2;
+    int ret;
     size_t written;
     size_t toconv;
     int c_in;
@@ -2208,32 +2235,13 @@
 
     c_in = toconv;
     c_out = written;
-    if (input->encoder->input != NULL) {
-        ret = input->encoder->input(xmlBufEnd(out), &c_out,
-                                    xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (input->encoder->iconv_in != NULL) {
-        ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (input->encoder->uconv_in != NULL) {
-        ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICU_ENABLED */
+    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
+                           xmlBufContent(in), &c_in, flush);
+    xmlBufShrink(in, c_in);
+    xmlBufAddLen(out, c_out);
+    if (ret == -1)
+        ret = -3;
+
     switch (ret) {
         case 0:
 #ifdef DEBUG_ENCODING
@@ -2294,7 +2302,7 @@
 xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
                  xmlBufferPtr in)
 {
-    int ret = -2;
+    int ret;
     int written;
     int toconv;
 
@@ -2313,35 +2321,14 @@
         xmlBufferGrow(out, out->size + toconv * 2);
         written = out->size - out->use - 1;
     }
-    if (handler->input != NULL) {
-        ret = handler->input(&out->content[out->use], &written,
-                             in->content, &toconv);
-        xmlBufferShrink(in, toconv);
-        out->use += written;
-        out->content[out->use] = 0;
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (handler->iconv_in != NULL) {
-        ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
-                              &written, in->content, &toconv);
-        xmlBufferShrink(in, toconv);
-        out->use += written;
-        out->content[out->use] = 0;
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (handler->uconv_in != NULL) {
-        ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
-                              &written, in->content, &toconv);
-        xmlBufferShrink(in, toconv);
-        out->use += written;
-        out->content[out->use] = 0;
-        if (ret == -1)
-            ret = -3;
-    }
-#endif /* LIBXML_ICU_ENABLED */
+    ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
+                           in->content, &toconv, 1);
+    xmlBufferShrink(in, toconv);
+    out->use += written;
+    out->content[out->use] = 0;
+    if (ret == -1)
+        ret = -3;
+
     switch (ret) {
         case 0:
 #ifdef DEBUG_ENCODING
@@ -2405,7 +2392,7 @@
 int
 xmlCharEncOutput(xmlOutputBufferPtr output, int init)
 {
-    int ret = -2;
+    int ret;
     size_t written;
     size_t writtentot = 0;
     size_t toconv;
@@ -2413,7 +2400,6 @@
     int c_out;
     xmlBufPtr in;
     xmlBufPtr out;
-    int charref_len = 0;
 
     if ((output == NULL) || (output->encoder == NULL) ||
         (output->buffer == NULL) || (output->conv == NULL))
@@ -2433,26 +2419,10 @@
     if (init) {
         c_in = 0;
         c_out = written;
-        if (output->encoder->output != NULL) {
-            ret = output->encoder->output(xmlBufEnd(out), &c_out,
-                                          NULL, &c_in);
-            if (ret > 0) /* Gennady: check return value */
-                xmlBufAddLen(out, c_out);
-        }
-#ifdef LIBXML_ICONV_ENABLED
-        else if (output->encoder->iconv_out != NULL) {
-            ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
-                                  &c_out, NULL, &c_in);
-            xmlBufAddLen(out, c_out);
-        }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-        else if (output->encoder->uconv_out != NULL) {
-            ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
-                                  &c_out, NULL, &c_in);
-            xmlBufAddLen(out, c_out);
-        }
-#endif /* LIBXML_ICU_ENABLED */
+        /* TODO: Check return value. */
+        xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
+                          NULL, &c_in);
+        xmlBufAddLen(out, c_out);
 #ifdef DEBUG_ENCODING
 	xmlGenericError(xmlGenericErrorContext,
 		"initialized encoder\n");
@@ -2477,57 +2447,17 @@
 
     c_in = toconv;
     c_out = written;
-    if (output->encoder->output != NULL) {
-        ret = output->encoder->output(xmlBufEnd(out), &c_out,
-                                      xmlBufContent(in), &c_in);
+    ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
+                            xmlBufContent(in), &c_in);
+    xmlBufShrink(in, c_in);
+    xmlBufAddLen(out, c_out);
+    writtentot += c_out;
+    if (ret == -1) {
         if (c_out > 0) {
-            xmlBufShrink(in, c_in);
-            xmlBufAddLen(out, c_out);
-            writtentot += c_out;
+            /* Can be a limitation of iconv or uconv */
+            goto retry;
         }
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (output->encoder->iconv_out != NULL) {
-        ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        writtentot += c_out;
-        if (ret == -1) {
-            if (c_out > 0) {
-                /*
-                 * Can be a limitation of iconv
-                 */
-                charref_len = 0;
-                goto retry;
-            }
-            ret = -3;
-        }
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (output->encoder->uconv_out != NULL) {
-        ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
-                              &c_out, xmlBufContent(in), &c_in);
-        xmlBufShrink(in, c_in);
-        xmlBufAddLen(out, c_out);
-        writtentot += c_out;
-        if (ret == -1) {
-            if (c_out > 0) {
-                /*
-                 * Can be a limitation of uconv
-                 */
-                charref_len = 0;
-                goto retry;
-            }
-            ret = -3;
-        }
-    }
-#endif /* LIBXML_ICU_ENABLED */
-    else {
-        xmlEncodingErr(XML_I18N_NO_OUTPUT,
-                       "xmlCharEncOutFunc: no output function !\n", NULL);
-        return(-1);
+        ret = -3;
     }
 
     if (ret >= 0) output += ret;
@@ -2555,47 +2485,44 @@
 	            c_in, c_out, (int) xmlBufUse(in));
 #endif
 	    break;
+        case -4:
+            xmlEncodingErr(XML_I18N_NO_OUTPUT,
+                           "xmlCharEncOutFunc: no output function !\n", NULL);
+            ret = -1;
+            break;
         case -2: {
+	    xmlChar charref[20];
 	    int len = (int) xmlBufUse(in);
             xmlChar *content = xmlBufContent(in);
-	    int cur;
+	    int cur, charrefLen;
 
 	    cur = xmlGetUTF8Char(content, &len);
-	    if ((charref_len != 0) && (c_out < charref_len)) {
-		/*
-		 * We attempted to insert a character reference and failed.
-		 * Undo what was written and skip the remaining charref.
-		 */
-                xmlBufErase(out, c_out);
-		writtentot -= c_out;
-		xmlBufShrink(in, charref_len - c_out);
-		charref_len = 0;
-
-		ret = -1;
+	    if (cur <= 0)
                 break;
-	    } else if (cur > 0) {
-		xmlChar charref[20];
 
 #ifdef DEBUG_ENCODING
-		xmlGenericError(xmlGenericErrorContext,
-			"handling output conversion error\n");
-		xmlGenericError(xmlGenericErrorContext,
-			"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-			content[0], content[1],
-			content[2], content[3]);
+            xmlGenericError(xmlGenericErrorContext,
+                    "handling output conversion error\n");
+            xmlGenericError(xmlGenericErrorContext,
+                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+                    content[0], content[1],
+                    content[2], content[3]);
 #endif
-		/*
-		 * Removes the UTF8 sequence, and replace it by a charref
-		 * and continue the transcoding phase, hoping the error
-		 * did not mangle the encoder state.
-		 */
-		charref_len = snprintf((char *) &charref[0], sizeof(charref),
-				 "&#%d;", cur);
-		xmlBufShrink(in, len);
-		xmlBufAddHead(in, charref, -1);
+            /*
+             * Removes the UTF8 sequence, and replace it by a charref
+             * and continue the transcoding phase, hoping the error
+             * did not mangle the encoder state.
+             */
+            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
+                             "&#%d;", cur);
+            xmlBufShrink(in, len);
+            xmlBufGrow(out, charrefLen * 4);
+            c_out = xmlBufAvail(out) - 1;
+            c_in = charrefLen;
+            ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
+                                    charref, &c_in);
 
-		goto retry;
-	    } else {
+	    if ((ret < 0) || (c_in != charrefLen)) {
 		char buf[50];
 
 		snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
@@ -2607,8 +2534,12 @@
 			       buf);
 		if (xmlBufGetAllocationScheme(in) != XML_BUFFER_ALLOC_IMMUTABLE)
 		    content[0] = ' ';
+                break;
 	    }
-	    break;
+
+            xmlBufAddLen(out, c_out);
+            writtentot += c_out;
+            goto retry;
 	}
     }
     return(ret);
@@ -2636,12 +2567,11 @@
 int
 xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
                   xmlBufferPtr in) {
-    int ret = -2;
+    int ret;
     int written;
     int writtentot = 0;
     int toconv;
     int output = 0;
-    int charref_len = 0;
 
     if (handler == NULL) return(-1);
     if (out == NULL) return(-1);
@@ -2658,31 +2588,11 @@
      */
     if (in == NULL) {
         toconv = 0;
-	if (handler->output != NULL) {
-	    ret = handler->output(&out->content[out->use], &written,
-				  NULL, &toconv);
-	    if (ret >= 0) { /* Gennady: check return value */
-		out->use += written;
-		out->content[out->use] = 0;
-	    }
-	}
-#ifdef LIBXML_ICONV_ENABLED
-	else if (handler->iconv_out != NULL) {
-	    ret = xmlIconvWrapper(handler->iconv_out, &out->content[out->use],
-				  &written, NULL, &toconv);
-	    out->use += written;
-	    out->content[out->use] = 0;
-	}
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-	else if (handler->uconv_out != NULL) {
-	    ret = xmlUconvWrapper(handler->uconv_out, 0,
-                              &out->content[out->use],
-				              &written, NULL, &toconv);
-	    out->use += written;
-	    out->content[out->use] = 0;
-	}
-#endif /* LIBXML_ICU_ENABLED */
+        /* TODO: Check return value. */
+        xmlEncOutputChunk(handler, &out->content[out->use], &written,
+                          NULL, &toconv);
+        out->use += written;
+        out->content[out->use] = 0;
 #ifdef DEBUG_ENCODING
 	xmlGenericError(xmlGenericErrorContext,
 		"initialized encoder\n");
@@ -2700,61 +2610,18 @@
         xmlBufferGrow(out, toconv * 4);
 	written = out->size - out->use - 1;
     }
-    if (handler->output != NULL) {
-	ret = handler->output(&out->content[out->use], &written,
-	                      in->content, &toconv);
-	if (written > 0) {
-	    xmlBufferShrink(in, toconv);
-	    out->use += written;
-	    writtentot += written;
-	}
-	out->content[out->use] = 0;
-    }
-#ifdef LIBXML_ICONV_ENABLED
-    else if (handler->iconv_out != NULL) {
-	ret = xmlIconvWrapper(handler->iconv_out, &out->content[out->use],
-	                      &written, in->content, &toconv);
-	xmlBufferShrink(in, toconv);
-	out->use += written;
-	writtentot += written;
-	out->content[out->use] = 0;
-	if (ret == -1) {
-	    if (written > 0) {
-		/*
-		 * Can be a limitation of iconv
-		 */
-                charref_len = 0;
-		goto retry;
-	    }
-	    ret = -3;
-	}
-    }
-#endif /* LIBXML_ICONV_ENABLED */
-#ifdef LIBXML_ICU_ENABLED
-    else if (handler->uconv_out != NULL) {
-	ret = xmlUconvWrapper(handler->uconv_out, 0,
-                              &out->content[out->use],
-	                      &written, in->content, &toconv);
-	xmlBufferShrink(in, toconv);
-	out->use += written;
-	writtentot += written;
-	out->content[out->use] = 0;
-	if (ret == -1) {
-	    if (written > 0) {
-		/*
-		 * Can be a limitation of iconv
-		 */
-                charref_len = 0;
-		goto retry;
-	    }
-	    ret = -3;
-	}
-    }
-#endif /* LIBXML_ICU_ENABLED */
-    else {
-	xmlEncodingErr(XML_I18N_NO_OUTPUT,
-		       "xmlCharEncOutFunc: no output function !\n", NULL);
-	return(-1);
+    ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
+                            in->content, &toconv);
+    xmlBufferShrink(in, toconv);
+    out->use += written;
+    writtentot += written;
+    out->content[out->use] = 0;
+    if (ret == -1) {
+        if (written > 0) {
+            /* Can be a limitation of iconv or uconv */
+            goto retry;
+        }
+        ret = -3;
     }
 
     if (ret >= 0) output += ret;
@@ -2782,47 +2649,44 @@
 	            toconv, written, in->use);
 #endif
 	    break;
+        case -4:
+	    xmlEncodingErr(XML_I18N_NO_OUTPUT,
+		           "xmlCharEncOutFunc: no output function !\n", NULL);
+	    ret = -1;
+            break;
         case -2: {
+	    xmlChar charref[20];
 	    int len = in->use;
 	    const xmlChar *utf = (const xmlChar *) in->content;
-	    int cur;
+	    int cur, charrefLen;
 
 	    cur = xmlGetUTF8Char(utf, &len);
-	    if ((charref_len != 0) && (written < charref_len)) {
-		/*
-		 * We attempted to insert a character reference and failed.
-		 * Undo what was written and skip the remaining charref.
-		 */
-		out->use -= written;
-		writtentot -= written;
-		xmlBufferShrink(in, charref_len - written);
-		charref_len = 0;
-
-		ret = -1;
+	    if (cur <= 0)
                 break;
-	    } else if (cur > 0) {
-		xmlChar charref[20];
 
 #ifdef DEBUG_ENCODING
-		xmlGenericError(xmlGenericErrorContext,
-			"handling output conversion error\n");
-		xmlGenericError(xmlGenericErrorContext,
-			"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-			in->content[0], in->content[1],
-			in->content[2], in->content[3]);
+            xmlGenericError(xmlGenericErrorContext,
+                    "handling output conversion error\n");
+            xmlGenericError(xmlGenericErrorContext,
+                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+                    in->content[0], in->content[1],
+                    in->content[2], in->content[3]);
 #endif
-		/*
-		 * Removes the UTF8 sequence, and replace it by a charref
-		 * and continue the transcoding phase, hoping the error
-		 * did not mangle the encoder state.
-		 */
-		charref_len = snprintf((char *) &charref[0], sizeof(charref),
-				 "&#%d;", cur);
-		xmlBufferShrink(in, len);
-		xmlBufferAddHead(in, charref, -1);
+            /*
+             * Removes the UTF8 sequence, and replace it by a charref
+             * and continue the transcoding phase, hoping the error
+             * did not mangle the encoder state.
+             */
+            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
+                             "&#%d;", cur);
+            xmlBufferShrink(in, len);
+            xmlBufferGrow(out, charrefLen * 4);
+	    written = out->size - out->use - 1;
+            toconv = charrefLen;
+            ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
+                                    charref, &toconv);
 
-		goto retry;
-	    } else {
+	    if ((ret < 0) || (toconv != charrefLen)) {
 		char buf[50];
 
 		snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
@@ -2834,8 +2698,13 @@
 			       buf);
 		if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
 		    in->content[0] = ' ';
+	        break;
 	    }
-	    break;
+
+            out->use += written;
+            writtentot += written;
+            out->content[out->use] = 0;
+            goto retry;
 	}
     }
     return(ret);
@@ -2954,54 +2823,20 @@
 
 	    int ret;
 
-	    if (handler->output != NULL) {
-	        do {
-		    toconv = in->end - cur;
-		    written = 32000;
-		    ret = handler->output(&convbuf[0], &written,
-				      cur, &toconv);
-		    if (ret == -1) return(-1);
-		    unused += written;
-		    cur += toconv;
-		} while (ret == -2);
-#ifdef LIBXML_ICONV_ENABLED
-	    } else if (handler->iconv_out != NULL) {
-	        do {
-		    toconv = in->end - cur;
-		    written = 32000;
-		    ret = xmlIconvWrapper(handler->iconv_out, &convbuf[0],
-	                      &written, cur, &toconv);
-		    if (ret < 0) {
-		        if (written > 0)
-			    ret = -2;
-			else
-			    return(-1);
-		    }
-		    unused += written;
-		    cur += toconv;
-		} while (ret == -2);
-#endif
-#ifdef LIBXML_ICU_ENABLED
-	    } else if (handler->uconv_out != NULL) {
-	        do {
-		    toconv = in->end - cur;
-		    written = 32000;
-		    ret = xmlUconvWrapper(handler->uconv_out, 0, &convbuf[0],
-	                      &written, cur, &toconv);
-		    if (ret < 0) {
-		        if (written > 0)
-			    ret = -2;
-			else
-			    return(-1);
-		    }
-		    unused += written;
-		    cur += toconv;
-		} while (ret == -2);
-#endif
-            } else {
-	        /* could not find a converter */
-	        return(-1);
-	    }
+            do {
+                toconv = in->end - cur;
+                written = 32000;
+                ret = xmlEncOutputChunk(handler, &convbuf[0], &written,
+                                        cur, &toconv);
+                if (ret < 0) {
+                    if (written > 0)
+                        ret = -2;
+                    else
+                        return(-1);
+                }
+                unused += written;
+                cur += toconv;
+            } while (ret == -2);
 	}
 	if (in->buf->rawconsumed < unused)
 	    return(-1);
diff --git a/entities.c b/entities.c
index 64808ff..43549bc 100644
--- a/entities.c
+++ b/entities.c
@@ -6,6 +6,11 @@
  * daniel@veillard.com
  */
 
+/* To avoid EBCDIC trouble when parsing on zOS */
+#if defined(__MVS__)
+#pragma convert("ISO8859-1")
+#endif
+
 #define IN_LIBXML
 #include "libxml.h"
 
@@ -880,10 +885,9 @@
  * Deallocate the memory used by an entities in the hash table.
  */
 static void
-xmlFreeEntityWrapper(xmlEntityPtr entity,
-	               const xmlChar *name ATTRIBUTE_UNUSED) {
+xmlFreeEntityWrapper(void *entity, const xmlChar *name ATTRIBUTE_UNUSED) {
     if (entity != NULL)
-	xmlFreeEntity(entity);
+	xmlFreeEntity((xmlEntityPtr) entity);
 }
 
 /**
@@ -894,7 +898,7 @@
  */
 void
 xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
-    xmlHashFree(table, (xmlHashDeallocator) xmlFreeEntityWrapper);
+    xmlHashFree(table, xmlFreeEntityWrapper);
 }
 
 #ifdef LIBXML_TREE_ENABLED
@@ -906,8 +910,9 @@
  *
  * Returns the new xmlEntitiesPtr or NULL in case of error.
  */
-static xmlEntityPtr
-xmlCopyEntity(xmlEntityPtr ent) {
+static void *
+xmlCopyEntity(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlEntityPtr ent = (xmlEntityPtr) payload;
     xmlEntityPtr cur;
 
     cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
@@ -944,7 +949,7 @@
  */
 xmlEntitiesTablePtr
 xmlCopyEntitiesTable(xmlEntitiesTablePtr table) {
-    return(xmlHashCopy(table, (xmlHashCopier) xmlCopyEntity));
+    return(xmlHashCopy(table, xmlCopyEntity));
 }
 #endif /* LIBXML_TREE_ENABLED */
 
@@ -1085,8 +1090,9 @@
  * When using the hash table scan function, arguments need to be reversed
  */
 static void
-xmlDumpEntityDeclScan(xmlEntityPtr ent, xmlBufferPtr buf) {
-    xmlDumpEntityDecl(buf, ent);
+xmlDumpEntityDeclScan(void *ent, void *buf,
+                      const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlDumpEntityDecl((xmlBufferPtr) buf, (xmlEntityPtr) ent);
 }
 
 /**
@@ -1098,7 +1104,7 @@
  */
 void
 xmlDumpEntitiesTable(xmlBufferPtr buf, xmlEntitiesTablePtr table) {
-    xmlHashScan(table, (xmlHashScanner)xmlDumpEntityDeclScan, buf);
+    xmlHashScan(table, xmlDumpEntityDeclScan, buf);
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
 #define bottom_entities
diff --git a/error.c b/error.c
index 9606f13..50e9e6f 100644
--- a/error.c
+++ b/error.c
@@ -853,7 +853,7 @@
  * Get the last global error registered. This is per thread if compiled
  * with thread support.
  *
- * Returns NULL if no error occured or a pointer to the error
+ * Returns NULL if no error occurred or a pointer to the error
  */
 xmlErrorPtr
 xmlGetLastError(void)
@@ -910,7 +910,7 @@
  *
  * Get the last parsing error registered.
  *
- * Returns NULL if no error occured or a pointer to the error
+ * Returns NULL if no error occurred or a pointer to the error
  */
 xmlErrorPtr
 xmlCtxtGetLastError(void *ctx)
diff --git a/example/Makefile.am b/example/Makefile.am
index 488ee6e..49bca39 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS	= gjobread
+check_PROGRAMS = gjobread
 
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)/include
 AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS)
diff --git a/example/gjobread.c b/example/gjobread.c
index d3f6d57..a435ca4 100644
--- a/example/gjobread.c
+++ b/example/gjobread.c
@@ -177,7 +177,7 @@
 
 
 static gJobPtr
-parseGjobFile(char *filename) {
+parseGjobFile(char *filename ATTRIBUTE_UNUSED) {
     xmlDocPtr doc;
     gJobPtr ret;
     jobPtr curjob;
diff --git a/genUnicode.py b/genUnicode.py
index 56e4e9b..4487eeb 100755
--- a/genUnicode.py
+++ b/genUnicode.py
@@ -267,14 +267,14 @@
 } xmlUnicodeRange;
 
 typedef struct {
-    xmlUnicodeRange *table;
+    const xmlUnicodeRange *table;
     int		    numentries;
 } xmlUnicodeNameTable;
 
 
 static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname);
 
-static xmlUnicodeRange xmlUnicodeBlocks[] = {
+static const xmlUnicodeRange xmlUnicodeBlocks[] = {
 """ % (webpage, date, sources));
 
 flag = 0
diff --git a/gentest.py b/gentest.py
index f178620..e4a8932 100755
--- a/gentest.py
+++ b/gentest.py
@@ -782,6 +782,24 @@
 	test.write("        %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i))
 	i = i + 1;
 
+    # add checks to avoid out-of-bounds array access
+    i = 0;
+    for arg in t_args:
+        (nam, type, rtype, crtype, info) = arg;
+        # assume that "size", "len", and "start" parameters apply to either
+        # the nearest preceding or following char pointer
+        if type == "int" and (nam == "size" or nam == "len" or nam == "start"):
+            for j in range(i - 1, -1, -1) + range(i + 1, len(t_args)):
+                (bnam, btype) = t_args[j][:2]
+                if btype == "const_char_ptr" or btype == "const_xmlChar_ptr":
+                    test.write(
+                        "        if ((%s != NULL) &&\n"
+                        "            (%s > (int) strlen((const char *) %s) + 1))\n"
+                        "            continue;\n"
+                        % (bnam, nam, bnam))
+                    break
+	i = i + 1;
+
     # do the call, and clanup the result
     if extra_pre_call.has_key(name):
 	test.write("        %s\n"% (extra_pre_call[name]))
diff --git a/globals.c b/globals.c
index e351b03..20b4308 100644
--- a/globals.c
+++ b/globals.c
@@ -92,7 +92,7 @@
  *
  * The variable holding the libxml free() implementation
  */
-xmlFreeFunc xmlFree = (xmlFreeFunc) free;
+xmlFreeFunc xmlFree = free;
 /**
  * xmlMalloc:
  * @size:  the size requested in bytes
@@ -101,7 +101,7 @@
  *
  * Returns a pointer to the newly allocated block or NULL in case of error
  */
-xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
+xmlMallocFunc xmlMalloc = malloc;
 /**
  * xmlMallocAtomic:
  * @size:  the size requested in bytes
@@ -112,7 +112,7 @@
  *
  * Returns a pointer to the newly allocated block or NULL in case of error
  */
-xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
+xmlMallocFunc xmlMallocAtomic = malloc;
 /**
  * xmlRealloc:
  * @mem: an already allocated block of memory
@@ -122,7 +122,19 @@
  *
  * Returns a pointer to the newly reallocated block or NULL in case of error
  */
-xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
+xmlReallocFunc xmlRealloc = realloc;
+/**
+ * xmlPosixStrdup
+ * @cur:  the input char *
+ *
+ * a strdup implementation with a type signature matching POSIX
+ *
+ * Returns a new xmlChar * or NULL
+ */
+static char *
+xmlPosixStrdup(const char *cur) {
+    return((char*) xmlCharStrdup(cur));
+}
 /**
  * xmlMemStrdup:
  * @str: a zero terminated string
@@ -131,7 +143,7 @@
  *
  * Returns the copy of the string or NULL in case of error
  */
-xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
+xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
 
 #include <libxml/threads.h>
diff --git a/hash.c b/hash.c
index f9a2017..b0b4abc 100644
--- a/hash.c
+++ b/hash.c
@@ -168,7 +168,7 @@
  *
  * Create a new xmlHashTablePtr.
  *
- * Returns the newly created object, or NULL if an error occured.
+ * Returns the newly created object, or NULL if an error occurred.
  */
 xmlHashTablePtr
 xmlHashCreate(int size) {
@@ -202,7 +202,7 @@
  *
  * Create a new xmlHashTablePtr which will use @dict as the internal dictionary
  *
- * Returns the newly created object, or NULL if an error occured.
+ * Returns the newly created object, or NULL if an error occurred.
  */
 xmlHashTablePtr
 xmlHashCreateDict(int size, xmlDictPtr dict) {
@@ -361,6 +361,18 @@
 }
 
 /**
+ * xmlHashDefaultDeallocator:
+ * @entry: the hash table entry
+ * @name: the entry's name
+ *
+ * Free a hash table entry with xmlFree.
+ */
+void
+xmlHashDefaultDeallocator(void *entry, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlFree(entry);
+}
+
+/**
  * xmlHashAddEntry:
  * @table: the hash table
  * @name: the name of the userdata
@@ -912,8 +924,11 @@
 xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
 	     const xmlChar *name2, const xmlChar *name3,
 	     xmlHashScanner f, void *data) {
-    xmlHashScanFull3 (table, name, name2, name3,
-		      (xmlHashScannerFull) f, data);
+    stubData stubdata;
+    stubdata.data = data;
+    stubdata.hashscanner = f;
+    xmlHashScanFull3(table, name, name2, name3, stubHashScannerFull,
+                     &stubdata);
 }
 
 /**
diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h
index 551186c..1d4fec2 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -115,12 +115,12 @@
 XMLPUBFUN int XMLCALL
 			htmlParseDocument(htmlParserCtxtPtr ctxt);
 XMLPUBFUN htmlDocPtr XMLCALL
-			htmlSAXParseDoc	(xmlChar *cur,
+			htmlSAXParseDoc	(const xmlChar *cur,
 					 const char *encoding,
 					 htmlSAXHandlerPtr sax,
 					 void *userData);
 XMLPUBFUN htmlDocPtr XMLCALL
-			htmlParseDoc	(xmlChar *cur,
+			htmlParseDoc	(const xmlChar *cur,
 					 const char *encoding);
 XMLPUBFUN htmlDocPtr XMLCALL
 			htmlSAXParseFile(const char *filename,
diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h
index 7967cc6..c875af6 100644
--- a/include/libxml/encoding.h
+++ b/include/libxml/encoding.h
@@ -129,9 +129,14 @@
  * If iconv is supported, there are two extra fields.
  */
 #ifdef LIBXML_ICU_ENABLED
+/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
+#define ICU_PIVOT_BUF_SIZE 1024
 struct _uconv_t {
   UConverter *uconv; /* for conversion between an encoding and UTF-16 */
   UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
+  UChar      pivot_buf[ICU_PIVOT_BUF_SIZE];
+  UChar      *pivot_source;
+  UChar      *pivot_target;
 };
 typedef struct _uconv_t uconv_t;
 #endif
diff --git a/include/libxml/hash.h b/include/libxml/hash.h
index dc8ab7e..6352874 100644
--- a/include/libxml/hash.h
+++ b/include/libxml/hash.h
@@ -66,7 +66,7 @@
  *
  * Callback to free data from a hash.
  */
-typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
+typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
 /**
  * xmlHashCopier:
  * @payload:  the data in the hash
@@ -76,7 +76,7 @@
  *
  * Returns a copy of the data or NULL in case of error.
  */
-typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
+typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);
 /**
  * xmlHashScanner:
  * @payload:  the data in the hash
@@ -85,7 +85,7 @@
  *
  * Callback when scanning data in a hash with the simple scanner.
  */
-typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name);
+typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);
 /**
  * xmlHashScannerFull:
  * @payload:  the data in the hash
@@ -111,6 +111,9 @@
 XMLPUBFUN void XMLCALL
 			xmlHashFree	(xmlHashTablePtr table,
 					 xmlHashDeallocator f);
+XMLPUBFUN void XMLCALL
+			xmlHashDefaultDeallocator(void *entry,
+					 const xmlChar *name);
 
 /*
  * Add a new entry to the hash table.
diff --git a/include/libxml/list.h b/include/libxml/list.h
index 0504e0c..3211c75 100644
--- a/include/libxml/list.h
+++ b/include/libxml/list.h
@@ -49,7 +49,7 @@
  *
  * Returns 0 to stop walking the list, 1 otherwise.
  */
-typedef int (*xmlListWalker) (const void *data, const void *user);
+typedef int (*xmlListWalker) (const void *data, void *user);
 
 /* Creation/Deletion */
 XMLPUBFUN xmlListPtr XMLCALL
@@ -110,11 +110,11 @@
 XMLPUBFUN void XMLCALL
 		xmlListWalk		(xmlListPtr l,
 					 xmlListWalker walker,
-					 const void *user);
+					 void *user);
 XMLPUBFUN void XMLCALL
 		xmlListReverseWalk	(xmlListPtr l,
 					 xmlListWalker walker,
-					 const void *user);
+					 void *user);
 XMLPUBFUN void XMLCALL
 		xmlListMerge		(xmlListPtr l1,
 					 xmlListPtr l2);
diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h
index abb4bf7..7335faf 100644
--- a/include/libxml/nanoftp.h
+++ b/include/libxml/nanoftp.h
@@ -16,7 +16,7 @@
 #ifdef LIBXML_FTP_ENABLED
 
 /* Needed for portability to Windows 64 bits */
-#if defined(__MINGW32__) || defined(_WIN32_WCE)
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include <winsock2.h>
 #else
 /**
diff --git a/include/libxml/schemasInternals.h b/include/libxml/schemasInternals.h
index c7cf552..6fb7113 100644
--- a/include/libxml/schemasInternals.h
+++ b/include/libxml/schemasInternals.h
@@ -3,7 +3,7 @@
  * Description: internal interfaces for the XML Schemas handling
  *              and schema validity checking
  *		The Schemas development is a Work In Progress.
- *              Some of those interfaces are not garanteed to be API or ABI stable !
+ *              Some of those interfaces are not guaranteed to be API or ABI stable !
  *
  * Copy: See Copyright for the status of this software.
  *
diff --git a/include/libxml/threads.h b/include/libxml/threads.h
index d31f16a..9969ae7 100644
--- a/include/libxml/threads.h
+++ b/include/libxml/threads.h
@@ -72,8 +72,13 @@
 XMLPUBFUN xmlGlobalStatePtr XMLCALL
 			xmlGetGlobalState(void);
 
-#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
-int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved);
+#ifdef HAVE_PTHREAD_H
+#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#if defined(LIBXML_STATIC_FOR_DLL)
+int XMLCALL
+xmlDllMain(void *hinstDLL, unsigned long fdwReason,
+           void *lpvReserved);
+#endif
 #endif
 
 #ifdef __cplusplus
diff --git a/include/libxml/xmlreader.h b/include/libxml/xmlreader.h
index 2c99e3a..e8a8bcc 100644
--- a/include/libxml/xmlreader.h
+++ b/include/libxml/xmlreader.h
@@ -393,7 +393,7 @@
  * @arg: the user argument
  * @msg: the message
  * @severity: the severity of the error
- * @locator: a locator indicating where the error occured
+ * @locator: a locator indicating where the error occurred
  *
  * Signature of an error callback from a reader parser
  */
diff --git a/include/libxml/xmlversion.h b/include/libxml/xmlversion.h
index c8163c6..eb18ea0 100644
--- a/include/libxml/xmlversion.h
+++ b/include/libxml/xmlversion.h
@@ -286,9 +286,14 @@
  * LIBXML_ICU_ENABLED:
  *
  * Whether icu support is available
+ *
+ * This is disabled when libxml2 is built for the VNDK.
+ * libicuuc.so isn't available in the VNDK.
  */
-#if 1
+#ifndef __ANDROID_VNDK__
 #define LIBXML_ICU_ENABLED
+#else
+#undef LIBXML_ICU_ENABLED
 #endif
 
 /**
diff --git a/include/win32config.h b/include/win32config.h
index 40cf7df..8596755 100644
--- a/include/win32config.h
+++ b/include/win32config.h
@@ -10,7 +10,6 @@
 
 #if defined(_WIN32_WCE)
 #undef HAVE_ERRNO_H
-#include <windows.h>
 #include "wincecompat.h"
 #else
 #define HAVE_SYS_STAT_H
@@ -29,10 +28,6 @@
 #define ICONV_CONST const
 #endif
 
-#ifdef NEED_SOCKETS
-#include <wsockcompat.h>
-#endif
-
 /*
  * Windows platforms may define except 
  */
diff --git a/include/wsockcompat.h b/include/wsockcompat.h
index e6a1a99..0484ee3 100644
--- a/include/wsockcompat.h
+++ b/include/wsockcompat.h
@@ -8,7 +8,7 @@
 #ifdef _WIN32_WCE
 #include <winsock.h>
 #else
-#undef HAVE_ERRNO_H
+#include <errno.h>
 #include <winsock2.h>
 
 /* the following is a workaround a problem for 'inline' keyword in said
@@ -27,60 +27,23 @@
 #endif
 #endif
 
-#if defined( __MINGW32__ ) || defined( _MSC_VER )
-/* Include <errno.h> here to ensure that it doesn't get included later
- * (e.g. by iconv.h) and overwrites the definition of EWOULDBLOCK. */
-#include <errno.h>
-#undef EWOULDBLOCK
+#undef XML_SOCKLEN_T
+#define XML_SOCKLEN_T int
+
+#ifndef ECONNRESET
+#define ECONNRESET WSAECONNRESET
 #endif
-
-#if !defined SOCKLEN_T
-#define SOCKLEN_T int
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
 #endif
-
-#define EWOULDBLOCK             WSAEWOULDBLOCK
-#define ESHUTDOWN               WSAESHUTDOWN
-
-#if (!defined(_MSC_VER) || (_MSC_VER < 1600))
-#define EINPROGRESS             WSAEINPROGRESS
-#define EALREADY                WSAEALREADY
-#define ENOTSOCK                WSAENOTSOCK
-#define EDESTADDRREQ            WSAEDESTADDRREQ
-#define EMSGSIZE                WSAEMSGSIZE
-#define EPROTOTYPE              WSAEPROTOTYPE
-#define ENOPROTOOPT             WSAENOPROTOOPT
-#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
-#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
-#define EOPNOTSUPP              WSAEOPNOTSUPP
-#define EPFNOSUPPORT            WSAEPFNOSUPPORT
-#define EAFNOSUPPORT            WSAEAFNOSUPPORT
-#define EADDRINUSE              WSAEADDRINUSE
-#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
-#define ENETDOWN                WSAENETDOWN
-#define ENETUNREACH             WSAENETUNREACH
-#define ENETRESET               WSAENETRESET
-#define ECONNABORTED            WSAECONNABORTED
-#define ECONNRESET              WSAECONNRESET
-#define ENOBUFS                 WSAENOBUFS
-#define EISCONN                 WSAEISCONN
-#define ENOTCONN                WSAENOTCONN
-#define ETOOMANYREFS            WSAETOOMANYREFS
-#define ETIMEDOUT               WSAETIMEDOUT
-#define ECONNREFUSED            WSAECONNREFUSED
-#define ELOOP                   WSAELOOP
-#define EHOSTDOWN               WSAEHOSTDOWN
-#define EHOSTUNREACH            WSAEHOSTUNREACH
-#define EPROCLIM                WSAEPROCLIM
-#define EUSERS                  WSAEUSERS
-#define EDQUOT                  WSAEDQUOT
-#define ESTALE                  WSAESTALE
-#define EREMOTE                 WSAEREMOTE
-/* These cause conflicts with the codes from errno.h. Since they are 
-   not used in the relevant code (nanoftp, nanohttp), we can leave 
-   them disabled.
-#define ENAMETOOLONG            WSAENAMETOOLONG
-#define ENOTEMPTY               WSAENOTEMPTY
-*/
-#endif /* _MSC_VER */
+#ifndef EINTR
+#define EINTR WSAEINTR
+#endif
+#ifndef ESHUTDOWN
+#define ESHUTDOWN WSAESHUTDOWN
+#endif
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
 
 #endif /* __XML_WSOCKCOMPAT_H__ */
diff --git a/libxml.h b/libxml.h
index 88e515f..2efa704 100644
--- a/libxml.h
+++ b/libxml.h
@@ -96,12 +96,12 @@
 #endif
 
 XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg);
-int xmlNop(void);
+int xmlInputReadCallbackNop(void *context, char *buffer, int len);
 
 #ifdef IN_LIBXML
 #ifdef __GNUC__
 #ifdef PIC
-#ifdef linux
+#ifdef __linux__
 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
 #include "elfgcchack.h"
 #endif
@@ -109,7 +109,7 @@
 #endif
 #endif
 #endif
-#if !defined(PIC) && !defined(NOLIBTOOL)
+#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
 #  define LIBXML_STATIC
 #endif
 #endif /* ! __XML_LIBXML_H__ */
diff --git a/libxml.m4 b/libxml.m4
index 68cd824..2d7a6f5 100644
--- a/libxml.m4
+++ b/libxml.m4
@@ -170,7 +170,7 @@
           echo "*** If you have an old version installed, it is best to remove it, although"
           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
         [ echo "*** The test program failed to compile or link. See the file config.log for the"
-          echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
+          echo "*** exact error that occurred. This usually means LIBXML was incorrectly installed"
           echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
           echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
           CPPFLAGS="$ac_save_CPPFLAGS"
diff --git a/libxml.spec.in b/libxml.spec.in
index 9029a18..d5f5ccb 100644
--- a/libxml.spec.in
+++ b/libxml.spec.in
@@ -57,12 +57,15 @@
 Static library for libxml2 provided for specific uses or shaving a few
 microseconds when parsing, do not link to them for generic purpose packages.
 
-%package python
+%package -n python-%{name}
+%{?python_provide:%python_provide python-%{name}}
 Summary: Python bindings for the libxml2 library
 Group: Development/Libraries
 Requires: libxml2 = %{version}-%{release}
+Obsoletes: %{name}-python < %{version}-%{release}
+Provides: %{name}-python = %{version}-%{release}
 
-%description python
+%description -n python-%{name}
 The libxml2-python package contains a Python 2 module that permits applications
 written in the Python programming language, version 2, to use the interface
 supplied by the libxml2 library to manipulate XML files.
@@ -73,12 +76,14 @@
 at parse time or later once the document has been modified.
 
 %if 0%{?with_python3}
-%package python3
+%package -n python3-%{name}
 Summary: Python 3 bindings for the libxml2 library
 Group: Development/Libraries
 Requires: libxml2 = %{version}-%{release}
+Obsoletes: %{name}-python3 < %{version}-%{release}
+Provides: %{name}-python3 = %{version}-%{release}
 
-%description python3
+%description -n python3-%{name}
 The libxml2-python3 package contains a Python 3 module that permits
 applications written in the Python programming language, version 3, to use the
 interface supplied by the libxml2 library to manipulate XML files.
@@ -92,10 +97,16 @@
 %prep
 %setup -q
 
+mkdir py3doc
+cp doc/*.py py3doc
+sed -i 's|#!/usr/bin/python |#!%{__python3} |' py3doc/*.py
+
 %build
 %configure
 make %{_smp_mflags}
 
+find doc -type f -exec chmod 0644 \{\} \;
+
 %install
 rm -fr %{buildroot}
 
@@ -165,7 +176,7 @@
 
 %{_libdir}/*a
 
-%files python
+%files -n python-%{name}
 %defattr(-, root, root)
 
 %{_libdir}/python2*/site-packages/libxml2.py*
@@ -178,18 +189,16 @@
 %doc doc/python.html
 
 %if 0%{?with_python3}
-%files python3
+%files -n python3-%{name}
 %defattr(-, root, root)
 
 %{_libdir}/python3*/site-packages/libxml2.py*
 %{_libdir}/python3*/site-packages/drv_libxml2.py*
-%{_libdir}/python3*/site-packages/__pycache__/libxml2.cpython-34.py*
-%{_libdir}/python3*/site-packages/__pycache__/drv_libxml2.cpython-34.py*
+%{_libdir}/python3*/site-packages/__pycache__/*py*
 %{_libdir}/python3*/site-packages/libxml2mod*
 %doc python/TODO
 %doc python/libxml2class.txt
-%doc python/tests/*.py
-%doc doc/*.py
+%doc py3doc/*.py
 %doc doc/python.html
 %endif # with_python3
 
diff --git a/list.c b/list.c
index d33d928..24da6b1 100644
--- a/list.c
+++ b/list.c
@@ -347,7 +347,7 @@
  *
  * Remove the first instance associated to data in the list
  *
- * Returns 1 if a deallocation occured, or 0 if not found
+ * Returns 1 if a deallocation occurred, or 0 if not found
  */
 int
 xmlListRemoveFirst(xmlListPtr l, void *data)
@@ -372,7 +372,7 @@
  *
  * Remove the last instance associated to data in the list
  *
- * Returns 1 if a deallocation occured, or 0 if not found
+ * Returns 1 if a deallocation occurred, or 0 if not found
  */
 int
 xmlListRemoveLast(xmlListPtr l, void *data)
@@ -673,7 +673,7 @@
  * apply the walker function to it
  */
 void
-xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
+xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user) {
     xmlLinkPtr lk;
 
     if ((l == NULL) || (walker == NULL))
@@ -694,7 +694,7 @@
  * apply the walker function to it
  */
 void
-xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
+xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, void *user) {
     xmlLinkPtr lk;
 
     if ((l == NULL) || (walker == NULL))
diff --git a/nanoftp.c b/nanoftp.c
index 2135ab9..54fa026 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -12,8 +12,6 @@
 #define HAVE_NETINET_IN_H
 #define HAVE_NETDB_H
 #define HAVE_SYS_TIME_H
-#else /* TESTING */
-#define NEED_SOCKETS
 #endif /* TESTING */
 
 #define IN_LIBXML
@@ -77,14 +75,8 @@
 #endif
 
 
-#if defined(__MINGW32__) || defined(_WIN32_WCE)
-#ifndef _WINSOCKAPI_
-#define _WINSOCKAPI_
-#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include <wsockcompat.h>
-#include <winsock2.h>
-#undef XML_SOCKLEN_T
-#define XML_SOCKLEN_T unsigned int
 #endif
 
 /**
@@ -511,6 +503,8 @@
     if (ctxt->hostname != NULL) xmlFree(ctxt->hostname);
     if (ctxt->protocol != NULL) xmlFree(ctxt->protocol);
     if (ctxt->path != NULL) xmlFree(ctxt->path);
+    if (ctxt->user != NULL) xmlFree(ctxt->user);
+    if (ctxt->passwd != NULL) xmlFree(ctxt->passwd);
     ctxt->passive = 1;
     if (ctxt->controlFd != INVALID_SOCKET) closesocket(ctxt->controlFd);
     ctxt->controlFd = INVALID_SOCKET;
@@ -907,7 +901,7 @@
 	    __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed");
 	    return (-1);
 	}
-	if (tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) {
+	if ((size_t)tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) {
 	    if (result)
 		freeaddrinfo (result);
 	    __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch");
@@ -1042,6 +1036,7 @@
 		case 2:
 		    if (proxyPasswd == NULL)
 			break;
+                    /* Falls through. */
 		case 3:
 		    if (proxyPasswd != NULL)
 			snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd);
@@ -1111,6 +1106,7 @@
 		    ctxt->controlFd = INVALID_SOCKET;
 		    return(-1);
 		}
+                /* Falls through. */
 	    case 2:
 		/* USER user@host command */
 		if (ctxt->user == NULL)
@@ -1164,6 +1160,7 @@
 		    ctxt->controlFd = INVALID_SOCKET;
 		    return(-1);
 		}
+                /* Falls through. */
 	    case 3:
 		/*
 		 * If you need support for other Proxy authentication scheme
@@ -1212,6 +1209,7 @@
 	case 3:
 	    __xmlIOErr(XML_FROM_FTP, XML_FTP_ACCNT,
 		       "FTP server asking for ACCNT on anonymous\n");
+           /* Falls through. */
 	case 1:
 	case 4:
 	case 5:
diff --git a/nanohttp.c b/nanohttp.c
index e109ad7..9cd2292 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -11,7 +11,6 @@
  * daniel@veillard.com
  */
 
-#define NEED_SOCKETS
 #define IN_LIBXML
 #include "libxml.h"
 
@@ -74,14 +73,8 @@
 #define XML_SOCKLEN_T unsigned int
 #endif
 
-#if defined(__MINGW32__) || defined(_WIN32_WCE)
-#ifndef _WINSOCKAPI_
-#define _WINSOCKAPI_
-#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include <wsockcompat.h>
-#include <winsock2.h>
-#undef XML_SOCKLEN_T
-#define XML_SOCKLEN_T unsigned int
 #endif
 
 #include <libxml/globals.h>
@@ -182,7 +175,21 @@
  */
 static int socket_errno(void) {
 #ifdef _WINSOCKAPI_
-    return(WSAGetLastError());
+    int err = WSAGetLastError();
+    switch(err) {
+        case WSAECONNRESET:
+            return(ECONNRESET);
+        case WSAEINPROGRESS:
+            return(EINPROGRESS);
+        case WSAEINTR:
+            return(EINTR);
+        case WSAESHUTDOWN:
+            return(ESHUTDOWN);
+        case WSAEWOULDBLOCK:
+            return(EWOULDBLOCK);
+        default:
+            return(err);
+    }
 #else
     return(errno);
 #endif
@@ -629,7 +636,7 @@
 
         if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1)
 #if defined(EINTR)
-            && (errno != EINTR)
+            && (socket_errno() != EINTR)
 #endif
             )
             return (0);
@@ -1038,16 +1045,13 @@
 static SOCKET
 xmlNanoHTTPConnectHost(const char *host, int port)
 {
-    struct hostent *h;
     struct sockaddr *addr = NULL;
-    struct in_addr ia;
     struct sockaddr_in sockin;
 
 #ifdef SUPPORT_IP6
     struct in6_addr ia6;
     struct sockaddr_in6 sockin6;
 #endif
-    int i;
     SOCKET s;
 
     memset (&sockin, 0, sizeof(sockin));
@@ -1084,7 +1088,7 @@
 
 	for (res = result; res; res = res->ai_next) {
 	    if (res->ai_family == AF_INET) {
-		if (res->ai_addrlen > sizeof(sockin)) {
+		if ((size_t)res->ai_addrlen > sizeof(sockin)) {
 		    __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
 		    freeaddrinfo (result);
 		    return INVALID_SOCKET;
@@ -1094,7 +1098,7 @@
 		addr = (struct sockaddr *)&sockin;
 #ifdef SUPPORT_IP6
 	    } else if (have_ipv6 () && (res->ai_family == AF_INET6)) {
-		if (res->ai_addrlen > sizeof(sockin6)) {
+		if ((size_t)res->ai_addrlen > sizeof(sockin6)) {
 		    __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
 		    freeaddrinfo (result);
 		    return INVALID_SOCKET;
@@ -1122,6 +1126,10 @@
 #endif
 #if !defined(HAVE_GETADDRINFO) || !defined(_WIN32)
     {
+        struct hostent *h;
+        struct in_addr ia;
+        int i;
+
 	h = gethostbyname (GETHOSTBYNAME_ARG_CAST host);
 	if (h == NULL) {
 
@@ -1130,7 +1138,7 @@
  * extraction code. it work on Linux, if it work on your platform
  * and one want to enable it, send me the defined(foobar) needed
  */
-#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(linux)
+#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(__linux__)
 	    const char *h_err_txt = "";
 
 	    switch (h_errno) {
@@ -1423,9 +1431,9 @@
     if (ctxt->port != 80) {
 	/* reserve space for ':xxxxx', incl. potential proxy */
 	if (proxy)
-	    blen += 12;
+	    blen += 17;
 	else
-	    blen += 6;
+	    blen += 11;
     }
     bp = (char*)xmlMallocAtomic(blen);
     if ( bp == NULL ) {
@@ -1534,7 +1542,8 @@
 	xmlGenericError(xmlGenericErrorContext,
 		"\nRedirect to: %s\n", ctxt->location);
 #endif
-	while ( xmlNanoHTTPRecv(ctxt) > 0 ) ;
+	while ( xmlNanoHTTPRecv(ctxt) > 0 )
+            ;
         if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
 	    nbRedirects++;
 	    if (redirURL != NULL)
diff --git a/os400/initscript.sh b/os400/initscript.sh
index cc52e45..42ce54d 100644
--- a/os400/initscript.sh
+++ b/os400/initscript.sh
@@ -50,7 +50,7 @@
 setenv DEBUG            '*ALL'          # Debug level.
 setenv OPTIMIZE         '10'            # Optimisation level.
 setenv OUTPUT           '*NONE'         # Compilation output option.
-setenv TGTRLS           'V5R3M0'        # Target OS release.
+setenv TGTRLS           'V6R1M0'        # Target OS release.
 setenv IFSDIR           '/libxml2'      # Installation IFS directory.
 
 
@@ -217,7 +217,7 @@
         cat "${2}" >> __tmpsrcf.c
         CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
 #       CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
-        CMD="${CMD} OPTION(*INCDIRFIRST)"
+        CMD="${CMD} OPTION(*INCDIRFIRST) FLAG(10)"
         CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
         CMD="${CMD} INCDIR("
         if [  -z "${SYSICONV}" ]
diff --git a/os400/libxmlrpg/schemasInternals.rpgle b/os400/libxmlrpg/schemasInternals.rpgle
index 8d3013e..765ed00 100644
--- a/os400/libxmlrpg/schemasInternals.rpgle
+++ b/os400/libxmlrpg/schemasInternals.rpgle
@@ -2,7 +2,7 @@
       * Description: internal interfaces for the XML Schemas handling
       *              and schema validity checking
       *              The Schemas development is a Work In Progress.
-      *              Some of those interfaces are not garanteed to be API or
+      *              Some of those interfaces are not guaranteed to be API or
       *                ABI stable !
       *
       * Copy: See Copyright for the status of this software.
diff --git a/os400/libxmlrpg/xmlreader.rpgle b/os400/libxmlrpg/xmlreader.rpgle
index 9ec76b3..f9ab207 100644
--- a/os400/libxmlrpg/xmlreader.rpgle
+++ b/os400/libxmlrpg/xmlreader.rpgle
@@ -624,7 +624,7 @@
       * @arg: the user argument
       * @msg: the message
       * @severity: the severity of the error
-      * @locator: a locator indicating where the error occured
+      * @locator: a locator indicating where the error occurred
       *
       * Signature of an error callback from a reader parser
 
diff --git a/os400/libxmlrpg/xmlstring.rpgle b/os400/libxmlrpg/xmlstring.rpgle
index 8980fc0..59a7625 100644
--- a/os400/libxmlrpg/xmlstring.rpgle
+++ b/os400/libxmlrpg/xmlstring.rpgle
@@ -115,7 +115,7 @@
      d                                     like(xmlCint)
      d  buf                            *   value options(*string)               xmlChar *
      d  len                                value like(xmlCint)
-     d  msg                            *   value options(*string)               const xmlChar *
+     d  msg                            *   value options(*string)               const char *
      d  arg1                           *   value options(*string: *nopass)
      d  arg2                           *   value options(*string: *nopass)
      d  arg3                           *   value options(*string: *nopass)
@@ -129,7 +129,7 @@
      d                                     like(xmlCint)
      d  buf                            *   value options(*string)               xmlChar *
      d  len                                value like(xmlCint)
-     d  msg                            *   value options(*string)               const xmlChar *
+     d  msg                            *   value options(*string)               const char *
      d  ap                                 likeds(xmlVaList)
 
      d xmlGetUTF8Char  pr                  extproc('xmlGetUTF8Char')
diff --git a/os400/make-src.sh b/os400/make-src.sh
index 6094de8..4c03c56 100644
--- a/os400/make-src.sh
+++ b/os400/make-src.sh
@@ -17,7 +17,7 @@
 echo '#pragma comment(user, "libxml2 version '"${LIBXML_VERSION}"'")' > os400.c
 echo '#pragma comment(user, __DATE__)' >> os400.c
 echo '#pragma comment(user, __TIME__)' >> os400.c
-echo '#pragma comment(copyright, "Copyright (C) 1998-2015 Daniel Veillard. OS/400 version by P. Monnerat.")' >> os400.c
+echo '#pragma comment(copyright, "Copyright (C) 1998-2017 Daniel Veillard. OS/400 version by P. Monnerat.")' >> os400.c
 make_module     OS400           os400.c
 LINK=                           # No need to rebuild service program yet.
 MODULES=
diff --git a/os400/os400config.h.in b/os400/os400config.h.in
index 3966ac8..ad5abb7 100644
--- a/os400/os400config.h.in
+++ b/os400/os400config.h.in
@@ -333,9 +333,6 @@
    #define below would cause a syntax error. */
 #undef _UINT32_T
 
-/* Using the Win32 Socket implementation */
-#undef _WINSOCKAPI_
-
 /* ss_family is not defined here, use __ss_family instead */
 #undef ss_family
 
diff --git a/parser.c b/parser.c
index 63ae15f..04aa717 100644
--- a/parser.c
+++ b/parser.c
@@ -30,10 +30,15 @@
  * daniel@veillard.com
  */
 
+/* To avoid EBCDIC trouble when parsing on zOS */
+#if defined(__MVS__)
+#pragma convert("ISO8859-1")
+#endif
+
 #define IN_LIBXML
 #include "libxml.h"
 
-#if defined(WIN32) && !defined (__CYGWIN__)
+#if defined(_WIN32) && !defined (__CYGWIN__)
 #define XML_DIR_SEP '\\'
 #else
 #define XML_DIR_SEP '/'
@@ -43,6 +48,7 @@
 #include <limits.h>
 #include <string.h>
 #include <stdarg.h>
+#include <stddef.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/threads.h>
 #include <libxml/globals.h>
@@ -1087,7 +1093,12 @@
 struct _xmlDefAttrs {
     int nbAttrs;	/* number of defaulted attributes on that element */
     int maxAttrs;       /* the size of the array */
-    const xmlChar *values[5]; /* array of localname/prefix/values/external */
+#if __STDC_VERSION__ >= 199901L
+    /* Using a C99 flexible array member avoids UBSan errors. */
+    const xmlChar *values[]; /* array of localname/prefix/values/external */
+#else
+    const xmlChar *values[5];
+#endif
 };
 
 /**
@@ -1324,7 +1335,7 @@
         return;
 
     xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr,
-                     (void *) (long) type);
+                     (void *) (ptrdiff_t) type);
     return;
 
 mem_error:
@@ -1343,7 +1354,7 @@
                             const xmlChar *unused ATTRIBUTE_UNUSED) {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data;
 
-    if (((long) payload) == XML_ATTRIBUTE_CDATA) {
+    if (((ptrdiff_t) payload) == XML_ATTRIBUTE_CDATA) {
         xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
     }
 }
@@ -1855,7 +1866,7 @@
     ctxt->name = value;
     ctxt->pushTab[ctxt->nameNr * 3] = (void *) prefix;
     ctxt->pushTab[ctxt->nameNr * 3 + 1] = (void *) URI;
-    ctxt->pushTab[ctxt->nameNr * 3 + 2] = (void *) (long) nsNr;
+    ctxt->pushTab[ctxt->nameNr * 3 + 2] = (void *) (ptrdiff_t) nsNr;
     return (ctxt->nameNr++);
 mem_error:
     xmlErrMemory(ctxt, NULL);
@@ -2037,10 +2048,8 @@
 
 #define SKIP(val) do {							\
     ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val);			\
-    if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);	\
-    if ((*ctxt->input->cur == 0) &&					\
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))		\
-	    xmlPopInput(ctxt);						\
+    if (*ctxt->input->cur == 0)						\
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);			\
   } while (0)
 
 #define SKIPL(val) do {							\
@@ -2052,10 +2061,8 @@
 	ctxt->nbChars++;						\
 	ctxt->input->cur++;						\
     }									\
-    if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);	\
-    if ((*ctxt->input->cur == 0) &&					\
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))		\
-	    xmlPopInput(ctxt);						\
+    if (*ctxt->input->cur == 0)						\
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);			\
   } while (0)
 
 #define SHRINK if ((ctxt->progressive == 0) &&				\
@@ -2065,10 +2072,9 @@
 
 static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
     xmlParserInputShrink(ctxt->input);
-    if ((*ctxt->input->cur == 0) &&
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
-	    xmlPopInput(ctxt);
-  }
+    if (*ctxt->input->cur == 0)
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+}
 
 #define GROW if ((ctxt->progressive == 0) &&				\
 		 (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK))	\
@@ -2080,7 +2086,8 @@
 
     if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) ||
          (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) &&
-         ((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) &&
+         ((ctxt->input->buf) &&
+          (ctxt->input->buf->readcallback != xmlInputReadCallbackNop)) &&
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
         xmlHaltParser(ctxt);
@@ -2093,9 +2100,8 @@
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
 	return;
     }
-    if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0) &&
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
-	    xmlPopInput(ctxt);
+    if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0))
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
 }
 
 #define SKIP_BLANKS xmlSkipBlankChars(ctxt)
@@ -2115,7 +2121,6 @@
 	ctxt->input->line++; ctxt->input->col = 1;			\
     } else ctxt->input->col++;						\
     ctxt->input->cur += l;				\
-    if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);	\
   } while (0)
 
 #define CUR_CHAR(l) xmlCurrentChar(ctxt, &l)
@@ -2165,26 +2170,35 @@
 	}
 	ctxt->input->cur = cur;
     } else {
-	int cur;
-	do {
-	    cur = CUR;
-	    while ((IS_BLANK_CH(cur) && /* CHECKED tstblanks.xml */
-	           (ctxt->instate != XML_PARSER_EOF))) {
+        int expandPE = ((ctxt->external != 0) || (ctxt->inputNr != 1));
+
+	while (1) {
+            if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */
 		NEXT;
-		cur = CUR;
-		res++;
-	    }
-	    while ((cur == 0) && (ctxt->inputNr > 1) &&
-		   (ctxt->instate != XML_PARSER_COMMENT)) {
-		xmlPopInput(ctxt);
-		cur = CUR;
-	    }
-	    /*
-	     * Need to handle support of entities branching here
-	     */
-	    if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);
-	} while ((IS_BLANK(cur)) && /* CHECKED tstblanks.xml */
-	         (ctxt->instate != XML_PARSER_EOF));
+	    } else if (CUR == '%') {
+                /*
+                 * Need to handle support of entities branching here
+                 */
+	        if ((expandPE == 0) || (IS_BLANK_CH(NXT(1))) || (NXT(1) == 0))
+                    break;
+	        xmlParsePEReference(ctxt);
+            } else if (CUR == 0) {
+                if (ctxt->inputNr <= 1)
+                    break;
+                xmlPopInput(ctxt);
+            } else {
+                break;
+            }
+
+            /*
+             * Also increase the counter when entering or exiting a PERef.
+             * The spec says: "When a parameter-entity reference is recognized
+             * in the DTD and included, its replacement text MUST be enlarged
+             * by the attachment of one leading and one following space (#x20)
+             * character."
+             */
+	    res++;
+        }
     }
     return(res);
 }
@@ -2210,10 +2224,13 @@
     if (xmlParserDebugEntities)
 	xmlGenericError(xmlGenericErrorContext,
 		"Popping input %d\n", ctxt->inputNr);
+    if ((ctxt->inputNr > 1) && (ctxt->inSubset == 0) &&
+        (ctxt->instate != XML_PARSER_EOF))
+        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+                    "Unfinished entity outside the DTD");
     xmlFreeInputStream(inputPop(ctxt));
-    if ((*ctxt->input->cur == 0) &&
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
-	    return(xmlPopInput(ctxt));
+    if (*ctxt->input->cur == 0)
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
     return(CUR);
 }
 
@@ -2239,6 +2256,13 @@
 	xmlGenericError(xmlGenericErrorContext,
 		"Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
     }
+    if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
+        (ctxt->inputNr > 1024)) {
+        xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+        while (ctxt->inputNr > 1)
+            xmlFreeInputStream(inputPop(ctxt));
+	return(-1);
+    }
     ret = inputPush(ctxt, input);
     if (ctxt->instate == XML_PARSER_EOF)
         return(-1);
@@ -2444,57 +2468,6 @@
 }
 
 /**
- * xmlNewBlanksWrapperInputStream:
- * @ctxt:  an XML parser context
- * @entity:  an Entity pointer
- *
- * Create a new input stream for wrapping
- * blanks around a PEReference
- *
- * Returns the new input stream or NULL
- */
-
-static void deallocblankswrapper (xmlChar *str) {xmlFree(str);}
-
-static xmlParserInputPtr
-xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
-    xmlParserInputPtr input;
-    xmlChar *buffer;
-    size_t length;
-    if (entity == NULL) {
-	xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-	            "xmlNewBlanksWrapperInputStream entity\n");
-	return(NULL);
-    }
-    if (xmlParserDebugEntities)
-	xmlGenericError(xmlGenericErrorContext,
-		"new blanks wrapper for entity: %s\n", entity->name);
-    input = xmlNewInputStream(ctxt);
-    if (input == NULL) {
-	return(NULL);
-    }
-    length = xmlStrlen(entity->name) + 5;
-    buffer = xmlMallocAtomic(length);
-    if (buffer == NULL) {
-	xmlErrMemory(ctxt, NULL);
-        xmlFree(input);
-	return(NULL);
-    }
-    buffer [0] = ' ';
-    buffer [1] = '%';
-    buffer [length-3] = ';';
-    buffer [length-2] = ' ';
-    buffer [length-1] = 0;
-    memcpy(buffer + 2, entity->name, length - 5);
-    input->free = deallocblankswrapper;
-    input->base = buffer;
-    input->cur = buffer;
-    input->length = length;
-    input->end = &buffer[length];
-    return(input);
-}
-
-/**
  * xmlParserHandlePEReference:
  * @ctxt:  the parser context
  *
@@ -2528,11 +2501,6 @@
  */
 void
 xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
-    const xmlChar *name;
-    xmlEntityPtr entity = NULL;
-    xmlParserInputPtr input;
-
-    if (RAW != '%') return;
     switch(ctxt->instate) {
 	case XML_PARSER_CDATA_SECTION:
 	    return;
@@ -2587,128 +2555,7 @@
             return;
     }
 
-    NEXT;
-    name = xmlParseName(ctxt);
-    if (xmlParserDebugEntities)
-	xmlGenericError(xmlGenericErrorContext,
-		"PEReference: %s\n", name);
-    if (name == NULL) {
-	xmlFatalErr(ctxt, XML_ERR_PEREF_NO_NAME, NULL);
-    } else {
-	if (RAW == ';') {
-	    NEXT;
-	    if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL))
-		entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
-	    if (ctxt->instate == XML_PARSER_EOF)
-	        return;
-	    if (entity == NULL) {
-
-		/*
-		 * [ WFC: Entity Declared ]
-		 * In a document without any DTD, a document with only an
-		 * internal DTD subset which contains no parameter entity
-		 * references, or a document with "standalone='yes'", ...
-		 * ... The declaration of a parameter entity must precede
-		 * any reference to it...
-		 */
-		if ((ctxt->standalone == 1) ||
-		    ((ctxt->hasExternalSubset == 0) &&
-		     (ctxt->hasPErefs == 0))) {
-		    xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
-			 "PEReference: %%%s; not found\n", name);
-	        } else {
-		    /*
-		     * [ VC: Entity Declared ]
-		     * In a document with an external subset or external
-		     * parameter entities with "standalone='no'", ...
-		     * ... The declaration of a parameter entity must precede
-		     * any reference to it...
-		     */
-		    if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) {
-		        xmlValidityError(ctxt, XML_WAR_UNDECLARED_ENTITY,
-			                 "PEReference: %%%s; not found\n",
-				         name, NULL);
-		    } else
-		        xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
-			              "PEReference: %%%s; not found\n",
-				      name, NULL);
-		    ctxt->valid = 0;
-		}
-		xmlParserEntityCheck(ctxt, 0, NULL, 0);
-	    } else if (ctxt->input->free != deallocblankswrapper) {
-		    input = xmlNewBlanksWrapperInputStream(ctxt, entity);
-		    if (xmlPushInput(ctxt, input) < 0)
-		        return;
-	    } else {
-	        if ((entity->etype == XML_INTERNAL_PARAMETER_ENTITY) ||
-		    (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY)) {
-		    xmlChar start[4];
-		    xmlCharEncoding enc;
-
-		    /*
-		     * Note: external parameter entities will not be loaded, it
-		     * is not required for a non-validating parser, unless the
-		     * option of validating, or substituting entities were
-		     * given. Doing so is far more secure as the parser will
-		     * only process data coming from the document entity by
-		     * default.
-		     */
-                    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
-		        ((ctxt->options & XML_PARSE_NOENT) == 0) &&
-			((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
-			((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
-			((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
-			(ctxt->replaceEntities == 0) &&
-			(ctxt->validate == 0))
-			return;
-
-		    /*
-		     * handle the extra spaces added before and after
-		     * c.f. http://www.w3.org/TR/REC-xml#as-PE
-		     * this is done independently.
-		     */
-		    input = xmlNewEntityInputStream(ctxt, entity);
-		    if (xmlPushInput(ctxt, input) < 0)
-		        return;
-
-		    /*
-		     * Get the 4 first bytes and decode the charset
-		     * if enc != XML_CHAR_ENCODING_NONE
-		     * plug some encoding conversion routines.
-		     * Note that, since we may have some non-UTF8
-		     * encoding (like UTF16, bug 135229), the 'length'
-		     * is not known, but we can calculate based upon
-		     * the amount of data in the buffer.
-		     */
-		    GROW
-                    if (ctxt->instate == XML_PARSER_EOF)
-                        return;
-		    if ((ctxt->input->end - ctxt->input->cur)>=4) {
-			start[0] = RAW;
-			start[1] = NXT(1);
-			start[2] = NXT(2);
-			start[3] = NXT(3);
-			enc = xmlDetectCharEncoding(start, 4);
-			if (enc != XML_CHAR_ENCODING_NONE) {
-			    xmlSwitchEncoding(ctxt, enc);
-			}
-		    }
-
-		    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
-			(CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l' )) &&
-			(IS_BLANK_CH(NXT(5)))) {
-			xmlParseTextDecl(ctxt);
-		    }
-		} else {
-		    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
-			     "PEReference: %s is not a parameter entity\n",
-				      name);
-		}
-	    }
-	} else {
-	    xmlFatalErr(ctxt, XML_ERR_PEREF_SEMICOL_MISSING, NULL);
-	}
-    }
+    xmlParsePEReference(ctxt);
 }
 
 /*
@@ -2790,9 +2637,9 @@
 	if (c == 0) break;
         if ((c == '&') && (str[1] == '#')) {
 	    int val = xmlParseStringCharRef(ctxt, &str);
-	    if (val != 0) {
-		COPY_BUF(0,buffer,nbchars,val);
-	    }
+	    if (val == 0)
+                goto int_error;
+	    COPY_BUF(0,buffer,nbchars,val);
 	    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
 	        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
 	    }
@@ -2802,9 +2649,6 @@
 			"String decoding Entity Reference: %.30s\n",
 			str);
 	    ent = xmlParseStringEntityRef(ctxt, &str);
-	    if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
-	        (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
-	        goto int_error;
 	    xmlParserEntityCheck(ctxt, 0, ent, 0);
 	    if (ent != NULL)
 	        ctxt->nbentities += ent->checked / 2;
@@ -2818,30 +2662,27 @@
 		} else {
 		    xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
 			    "predefined entity has no content\n");
+                    goto int_error;
 		}
 	    } else if ((ent != NULL) && (ent->content != NULL)) {
 		ctxt->depth++;
 		rep = xmlStringDecodeEntities(ctxt, ent->content, what,
 			                      0, 0, 0);
 		ctxt->depth--;
+		if (rep == NULL)
+                    goto int_error;
 
-		if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
-		    (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
-		    goto int_error;
-
-		if (rep != NULL) {
-		    current = rep;
-		    while (*current != 0) { /* non input consuming loop */
-			buffer[nbchars++] = *current++;
-			if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
-			    if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
-				goto int_error;
-			    growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
-			}
-		    }
-		    xmlFree(rep);
-		    rep = NULL;
-		}
+                current = rep;
+                while (*current != 0) { /* non input consuming loop */
+                    buffer[nbchars++] = *current++;
+                    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+                        if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
+                            goto int_error;
+                        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
+                    }
+                }
+                xmlFree(rep);
+                rep = NULL;
 	    } else if (ent != NULL) {
 		int i = xmlStrlen(ent->name);
 		const xmlChar *cur = ent->name;
@@ -2859,8 +2700,6 @@
 		xmlGenericError(xmlGenericErrorContext,
 			"String decoding PE Reference: %.30s\n", str);
 	    ent = xmlParseStringPEReference(ctxt, &str);
-	    if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
-	        goto int_error;
 	    xmlParserEntityCheck(ctxt, 0, ent, 0);
 	    if (ent != NULL)
 	        ctxt->nbentities += ent->checked / 2;
@@ -2886,19 +2725,19 @@
 		rep = xmlStringDecodeEntities(ctxt, ent->content, what,
 			                      0, 0, 0);
 		ctxt->depth--;
-		if (rep != NULL) {
-		    current = rep;
-		    while (*current != 0) { /* non input consuming loop */
-			buffer[nbchars++] = *current++;
-			if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
-			    if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
-			        goto int_error;
-			    growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
-			}
-		    }
-		    xmlFree(rep);
-		    rep = NULL;
-		}
+		if (rep == NULL)
+                    goto int_error;
+                current = rep;
+                while (*current != 0) { /* non input consuming loop */
+                    buffer[nbchars++] = *current++;
+                    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+                        if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
+                            goto int_error;
+                        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
+                    }
+                }
+                xmlFree(rep);
+                rep = NULL;
 	    }
 	} else {
 	    COPY_BUF(l,buffer,nbchars,c);
@@ -3406,13 +3245,6 @@
 	    len += l;
 	    NEXTL(l);
 	    c = CUR_CHAR(l);
-	    if (c == 0) {
-		count = 0;
-		GROW;
-                if (ctxt->instate == XML_PARSER_EOF)
-                    return(NULL);
-		c = CUR_CHAR(l);
-	    }
 	}
     }
     if ((len > XML_MAX_NAME_LENGTH) &&
@@ -3420,15 +3252,18 @@
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
         return(NULL);
     }
-    if (ctxt->input->cur > ctxt->input->base && (*ctxt->input->cur == '\n') && (ctxt->input->cur[-1] == '\r')) {
-        if (ctxt->input->base > ctxt->input->cur - (len + 1)) {
-            return(NULL);
-        }
+    if (ctxt->input->cur - ctxt->input->base < len) {
+        /*
+         * There were a couple of bugs where PERefs lead to to a change
+         * of the buffer. Check the buffer size to avoid passing an invalid
+         * pointer to xmlDictLookup.
+         */
+        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+                    "unexpected change of input buffer");
+        return (NULL);
+    }
+    if ((*ctxt->input->cur == '\n') && (ctxt->input->cur[-1] == '\r'))
         return(xmlDictLookup(ctxt->dict, ctxt->input->cur - (len + 1), len));
-    }
-    if (ctxt->input->base > ctxt->input->cur - len) {
-        return(NULL);
-    }
     return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
 }
 
@@ -3899,10 +3734,8 @@
     ctxt->instate = XML_PARSER_ENTITY_VALUE;
     input = ctxt->input;
     GROW;
-    if (ctxt->instate == XML_PARSER_EOF) {
-        xmlFree(buf);
-        return(NULL);
-    }
+    if (ctxt->instate == XML_PARSER_EOF)
+        goto error;
     NEXT;
     c = CUR_CHAR(l);
     /*
@@ -3923,18 +3756,12 @@
 	    tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
 	    if (tmp == NULL) {
 		xmlErrMemory(ctxt, NULL);
-		xmlFree(buf);
-		return(NULL);
+                goto error;
 	    }
 	    buf = tmp;
 	}
 	COPY_BUF(l,buf,len,c);
 	NEXTL(l);
-	/*
-	 * Pop-up of finished entities.
-	 */
-	while ((RAW == 0) && (ctxt->inputNr > 1)) /* non input consuming */
-	    xmlPopInput(ctxt);
 
 	GROW;
 	c = CUR_CHAR(l);
@@ -3944,10 +3771,13 @@
 	}
     }
     buf[len] = 0;
-    if (ctxt->instate == XML_PARSER_EOF) {
-        xmlFree(buf);
-        return(NULL);
+    if (ctxt->instate == XML_PARSER_EOF)
+        goto error;
+    if (c != stop) {
+        xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL);
+        goto error;
     }
+    NEXT;
 
     /*
      * Raise problem w.r.t. '&' and '%' being used in non-entities
@@ -3959,20 +3789,25 @@
 	if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) {
 	    xmlChar *name;
 	    xmlChar tmp = *cur;
+            int nameOk = 0;
 
 	    cur++;
 	    name = xmlParseStringName(ctxt, &cur);
-            if ((name == NULL) || (*cur != ';')) {
+            if (name != NULL) {
+                nameOk = 1;
+                xmlFree(name);
+            }
+            if ((nameOk == 0) || (*cur != ';')) {
 		xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR,
 	    "EntityValue: '%c' forbidden except for entities references\n",
 	                          tmp);
+                goto error;
 	    }
 	    if ((tmp == '%') && (ctxt->inSubset == 1) &&
 		(ctxt->inputNr == 1)) {
 		xmlFatalErr(ctxt, XML_ERR_ENTITY_PE_INTERNAL, NULL);
+                goto error;
 	    }
-	    if (name != NULL)
-		xmlFree(name);
 	    if (*cur == 0)
 	        break;
 	}
@@ -3981,28 +3816,24 @@
 
     /*
      * Then PEReference entities are substituted.
+     *
+     * NOTE: 4.4.7 Bypassed
+     * When a general entity reference appears in the EntityValue in
+     * an entity declaration, it is bypassed and left as is.
+     * so XML_SUBSTITUTE_REF is not set here.
      */
-    if (c != stop) {
-	xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL);
-	xmlFree(buf);
-    } else {
-	NEXT;
-	/*
-	 * NOTE: 4.4.7 Bypassed
-	 * When a general entity reference appears in the EntityValue in
-	 * an entity declaration, it is bypassed and left as is.
-	 * so XML_SUBSTITUTE_REF is not set here.
-	 */
-        ++ctxt->depth;
-	ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
-				      0, 0, 0);
-        --ctxt->depth;
-	if (orig != NULL)
-	    *orig = buf;
-	else
-	    xmlFree(buf);
+    ++ctxt->depth;
+    ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
+                                  0, 0, 0);
+    --ctxt->depth;
+    if (orig != NULL) {
+        *orig = buf;
+        buf = NULL;
     }
 
+error:
+    if (buf != NULL)
+        xmlFree(buf);
     return(ret);
 }
 
@@ -4172,7 +4003,9 @@
 			        ent->checked |= 1;
 			    xmlFree(rep);
 			    rep = NULL;
-			}
+			} else {
+                            ent->content[0] = 0;
+                        }
 		    }
 
 		    /*
@@ -4596,7 +4429,7 @@
 	    if (*in == ']') {
 		if ((in[1] == ']') && (in[2] == '>')) {
 		    xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
-		    ctxt->input->cur = in;
+		    ctxt->input->cur = in + 1;
 		    return;
 		}
 		in++;
@@ -4789,22 +4622,20 @@
     *publicID = NULL;
     if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
         SKIP(6);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 	                   "Space required after 'SYSTEM'\n");
 	}
-        SKIP_BLANKS;
 	URI = xmlParseSystemLiteral(ctxt);
 	if (URI == NULL) {
 	    xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL);
         }
     } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) {
         SKIP(6);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		    "Space required after 'PUBLIC'\n");
 	}
-        SKIP_BLANKS;
 	*publicID = xmlParsePubidLiteral(ctxt);
 	if (*publicID == NULL) {
 	    xmlFatalErr(ctxt, XML_ERR_PUBID_REQUIRED, NULL);
@@ -4813,26 +4644,20 @@
 	    /*
 	     * We don't handle [83] so "S SystemLiteral" is required.
 	     */
-	    if (!IS_BLANK_CH(CUR)) {
+	    if (SKIP_BLANKS == 0) {
 		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			"Space required after the Public Identifier\n");
 	    }
 	} else {
 	    /*
 	     * We handle [83] so we return immediately, if
-	     * "S SystemLiteral" is not detected. From a purely parsing
-	     * point of view that's a nice mess.
+	     * "S SystemLiteral" is not detected. We skip blanks if no
+             * system literal was found, but this is harmless since we must
+             * be at the end of a NotationDecl.
 	     */
-	    const xmlChar *ptr;
-	    GROW;
-
-	    ptr = CUR_PTR;
-	    if (!IS_BLANK_CH(*ptr)) return(NULL);
-
-	    while (IS_BLANK_CH(*ptr)) ptr++; /* TODO: dangerous, fix ! */
-	    if ((*ptr != '\'') && (*ptr != '"')) return(NULL);
+	    if (SKIP_BLANKS == 0) return(NULL);
+	    if ((CUR != '\'') && (CUR != '"')) return(NULL);
 	}
-        SKIP_BLANKS;
 	URI = xmlParseSystemLiteral(ctxt);
 	if (URI == NULL) {
 	    xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL);
@@ -4962,7 +4787,8 @@
     } else {
 	if (inputid != ctxt->input->id) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-		"Comment doesn't start and stop in the same entity\n");
+		           "Comment doesn't start and stop in the same"
+                           " entity\n");
 	}
         NEXT;
 	if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
@@ -5110,7 +4936,8 @@
 	        if (in[2] == '>') {
 		    if (ctxt->input->id != inputid) {
 			xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-			"comment doesn't start and stop in the same entity\n");
+			               "comment doesn't start and stop in the"
+                                       " same entity\n");
 		    }
 		    SKIP(3);
 		    if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
@@ -5278,7 +5105,7 @@
     int count = 0;
 
     if ((RAW == '<') && (NXT(1) == '?')) {
-	xmlParserInputPtr input = ctxt->input;
+	int inputid = ctxt->input->id;
 	state = ctxt->instate;
         ctxt->instate = XML_PARSER_PI;
 	/*
@@ -5294,9 +5121,10 @@
         target = xmlParsePITarget(ctxt);
 	if (target != NULL) {
 	    if ((RAW == '?') && (NXT(1) == '>')) {
-		if (input != ctxt->input) {
+		if (inputid != ctxt->input->id) {
 		    xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-	    "PI declaration doesn't start and stop in the same entity\n");
+	                           "PI declaration doesn't start and stop in"
+                                   " the same entity\n");
 		}
 		SKIP(2);
 
@@ -5317,12 +5145,10 @@
 		ctxt->instate = state;
 		return;
 	    }
-	    cur = CUR;
-	    if (!IS_BLANK(cur)) {
+	    if (SKIP_BLANKS == 0) {
 		xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED,
 			  "ParsePI: PI %s space expected\n", target);
 	    }
-            SKIP_BLANKS;
 	    cur = CUR_CHAR(l);
 	    while (IS_CHAR(cur) && /* checked */
 		   ((cur != '?') || (NXT(1) != '>'))) {
@@ -5378,9 +5204,10 @@
 		xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
 		      "ParsePI: PI %s never end ...\n", target);
 	    } else {
-		if (input != ctxt->input) {
-		    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
-	    "PI declaration doesn't start and stop in the same entity\n");
+		if (inputid != ctxt->input->id) {
+		    xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+	                           "PI declaration doesn't start and stop in"
+                                   " the same entity\n");
 		}
 		SKIP(2);
 
@@ -5436,32 +5263,30 @@
     xmlChar *Systemid;
 
     if (CMP10(CUR_PTR, '<', '!', 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
-	xmlParserInputPtr input = ctxt->input;
+	int inputid = ctxt->input->id;
 	SHRINK;
 	SKIP(10);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after '<!NOTATION'\n");
 	    return;
 	}
-	SKIP_BLANKS;
 
         name = xmlParseName(ctxt);
 	if (name == NULL) {
 	    xmlFatalErr(ctxt, XML_ERR_NOTATION_NOT_STARTED, NULL);
 	    return;
 	}
-	if (!IS_BLANK_CH(CUR)) {
-	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
-		     "Space required after the NOTATION name'\n");
-	    return;
-	}
 	if (xmlStrchr(name, ':') != NULL) {
 	    xmlNsErr(ctxt, XML_NS_ERR_COLON,
 		     "colons are forbidden from notation names '%s'\n",
 		     name, NULL, NULL);
 	}
-	SKIP_BLANKS;
+	if (SKIP_BLANKS == 0) {
+	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
+		     "Space required after the NOTATION name'\n");
+	    return;
+	}
 
 	/*
 	 * Parse the IDs.
@@ -5470,9 +5295,10 @@
 	SKIP_BLANKS;
 
 	if (RAW == '>') {
-	    if (input != ctxt->input) {
-		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
-	"Notation declaration doesn't start and stop in the same entity\n");
+	    if (inputid != ctxt->input->id) {
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+	                       "Notation declaration doesn't start and stop"
+                               " in the same entity\n");
 	    }
 	    NEXT;
 	    if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
@@ -5516,23 +5342,20 @@
     const xmlChar *ndata = NULL;
     int isParameter = 0;
     xmlChar *orig = NULL;
-    int skipped;
 
     /* GROW; done in the caller */
     if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
-	xmlParserInputPtr input = ctxt->input;
+	int inputid = ctxt->input->id;
 	SHRINK;
 	SKIP(8);
-	skipped = SKIP_BLANKS;
-	if (skipped == 0) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after '<!ENTITY'\n");
 	}
 
 	if (RAW == '%') {
 	    NEXT;
-	    skipped = SKIP_BLANKS;
-	    if (skipped == 0) {
+	    if (SKIP_BLANKS == 0) {
 		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			       "Space required after '%%'\n");
 	    }
@@ -5550,8 +5373,7 @@
 		     "colons are forbidden from entities names '%s'\n",
 		     name, NULL, NULL);
 	}
-        skipped = SKIP_BLANKS;
-	if (skipped == 0) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after the entity name\n");
 	}
@@ -5662,18 +5484,16 @@
 			xmlFreeURI(uri);
 		    }
 		}
-		if ((RAW != '>') && (!IS_BLANK_CH(CUR))) {
+		if ((RAW != '>') && (SKIP_BLANKS == 0)) {
 		    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 				   "Space required before 'NDATA'\n");
 		}
-		SKIP_BLANKS;
 		if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
 		    SKIP(5);
-		    if (!IS_BLANK_CH(CUR)) {
+		    if (SKIP_BLANKS == 0) {
 			xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 				       "Space required after 'NDATA'\n");
 		    }
-		    SKIP_BLANKS;
 		    ndata = xmlParseName(ctxt);
 		    if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
 		        (ctxt->sax->unparsedEntityDecl != NULL))
@@ -5712,16 +5532,17 @@
 	    }
 	}
 	if (ctxt->instate == XML_PARSER_EOF)
-	    return;
+	    goto done;
 	SKIP_BLANKS;
 	if (RAW != '>') {
 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
 	            "xmlParseEntityDecl: entity %s not terminated\n", name);
 	    xmlHaltParser(ctxt);
 	} else {
-	    if (input != ctxt->input) {
+	    if (inputid != ctxt->input->id) {
 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-	"Entity declaration doesn't start and stop in the same entity\n");
+	                       "Entity declaration doesn't start and stop in"
+                               " the same entity\n");
 	    }
 	    NEXT;
 	}
@@ -5743,17 +5564,17 @@
 		    cur = xmlSAX2GetEntity(ctxt, name);
 		}
 	    }
-            if (cur != NULL) {
-	        if (cur->orig != NULL)
-		    xmlFree(orig);
-		else
-		    cur->orig = orig;
-	    } else
-		xmlFree(orig);
+            if ((cur != NULL) && (cur->orig == NULL)) {
+		cur->orig = orig;
+                orig = NULL;
+	    }
 	}
+
+done:
 	if (value != NULL) xmlFree(value);
 	if (URI != NULL) xmlFree(URI);
 	if (literal != NULL) xmlFree(literal);
+        if (orig != NULL) xmlFree(orig);
     }
 }
 
@@ -5804,11 +5625,10 @@
     if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
 	SKIP(6);
 	val = XML_ATTRIBUTE_FIXED;
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after '#FIXED'\n");
 	}
-	SKIP_BLANKS;
     }
     ret = xmlParseAttValue(ctxt);
     ctxt->instate = XML_PARSER_DTD;
@@ -5980,12 +5800,11 @@
 xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
     if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
 	SKIP(8);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after 'NOTATION'\n");
 	    return(0);
 	}
-        SKIP_BLANKS;
 	*tree = xmlParseNotationType(ctxt);
 	if (*tree == NULL) return(0);
 	return(XML_ATTRIBUTE_NOTATION);
@@ -6089,14 +5908,13 @@
     xmlEnumerationPtr tree;
 
     if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
-	xmlParserInputPtr input = ctxt->input;
+	int inputid = ctxt->input->id;
 
 	SKIP(9);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		                 "Space required after '<!ATTLIST'\n");
 	}
-        SKIP_BLANKS;
         elemName = xmlParseName(ctxt);
 	if (elemName == NULL) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
@@ -6106,7 +5924,6 @@
 	SKIP_BLANKS;
 	GROW;
 	while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
-	    const xmlChar *check = CUR_PTR;
 	    int type;
 	    int def;
 	    xmlChar *defaultValue = NULL;
@@ -6120,12 +5937,11 @@
 		break;
 	    }
 	    GROW;
-	    if (!IS_BLANK_CH(CUR)) {
+	    if (SKIP_BLANKS == 0) {
 		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		        "Space required after the attribute name\n");
 		break;
 	    }
-	    SKIP_BLANKS;
 
 	    type = xmlParseAttributeType(ctxt, &tree);
 	    if (type <= 0) {
@@ -6133,14 +5949,13 @@
 	    }
 
 	    GROW;
-	    if (!IS_BLANK_CH(CUR)) {
+	    if (SKIP_BLANKS == 0) {
 		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			       "Space required after the attribute type\n");
 	        if (tree != NULL)
 		    xmlFreeEnumeration(tree);
 		break;
 	    }
-	    SKIP_BLANKS;
 
 	    def = xmlParseDefaultDecl(ctxt, &defaultValue);
 	    if (def <= 0) {
@@ -6155,7 +5970,7 @@
 
 	    GROW;
             if (RAW != '>') {
-		if (!IS_BLANK_CH(CUR)) {
+		if (SKIP_BLANKS == 0) {
 		    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			"Space required after the attribute default value\n");
 		    if (defaultValue != NULL)
@@ -6164,16 +5979,6 @@
 			xmlFreeEnumeration(tree);
 		    break;
 		}
-		SKIP_BLANKS;
-	    }
-	    if (check == CUR_PTR) {
-		xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-		            "in xmlParseAttributeListDecl\n");
-		if (defaultValue != NULL)
-		    xmlFree(defaultValue);
-	        if (tree != NULL)
-		    xmlFreeEnumeration(tree);
-		break;
 	    }
 	    if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
 		(ctxt->sax->attributeDecl != NULL))
@@ -6195,10 +6000,10 @@
 	    GROW;
 	}
 	if (RAW == '>') {
-	    if (input != ctxt->input) {
-		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-    "Attribute list declaration doesn't start and stop in the same entity\n",
-                                 NULL, NULL);
+	    if (inputid != ctxt->input->id) {
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+                               "Attribute list declaration doesn't start and"
+                               " stop in the same entity\n");
 	    }
 	    NEXT;
 	}
@@ -6235,10 +6040,10 @@
 	SKIP_BLANKS;
 	SHRINK;
 	if (RAW == ')') {
-	    if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
-		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-"Element content declaration doesn't start and stop in the same entity\n",
-                                 NULL, NULL);
+	    if (ctxt->input->id != inputchk) {
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+                               "Element content declaration doesn't start and"
+                               " stop in the same entity\n");
 	    }
 	    NEXT;
 	    ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
@@ -6279,7 +6084,7 @@
 	    if (elem == NULL) {
 		xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
 			"xmlParseElementMixedContentDecl : Name expected\n");
-		xmlFreeDocElementContent(ctxt->myDoc, cur);
+		xmlFreeDocElementContent(ctxt->myDoc, ret);
 		return(NULL);
 	    }
 	    SKIP_BLANKS;
@@ -6294,10 +6099,10 @@
             }
             if (ret != NULL)
                 ret->ocur = XML_ELEMENT_CONTENT_MULT;
-	    if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
-		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-"Element content declaration doesn't start and stop in the same entity\n",
-				 NULL, NULL);
+	    if (ctxt->input->id != inputchk) {
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+                               "Element content declaration doesn't start and"
+                               " stop in the same entity\n");
 	    }
 	    SKIP(2);
 	} else {
@@ -6537,10 +6342,10 @@
 	if (last != NULL)
 	    last->parent = cur;
     }
-    if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
-	xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-"Element content declaration doesn't start and stop in the same entity\n",
-			 NULL, NULL);
+    if (ctxt->input->id != inputchk) {
+	xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+                       "Element content declaration doesn't start and stop in"
+                       " the same entity\n");
     }
     NEXT;
     if (RAW == '?') {
@@ -6713,28 +6518,24 @@
 
     /* GROW; done in the caller */
     if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
-	xmlParserInputPtr input = ctxt->input;
+	int inputid = ctxt->input->id;
 
 	SKIP(9);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		           "Space required after 'ELEMENT'\n");
 	    return(-1);
 	}
-        SKIP_BLANKS;
         name = xmlParseName(ctxt);
 	if (name == NULL) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
 			   "xmlParseElementDecl: no name for Element\n");
 	    return(-1);
 	}
-	while ((RAW == 0) && (ctxt->inputNr > 1))
-	    xmlPopInput(ctxt);
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "Space required after the element name\n");
 	}
-        SKIP_BLANKS;
 	if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
 	    SKIP(5);
 	    /*
@@ -6766,12 +6567,6 @@
 	}
 
 	SKIP_BLANKS;
-	/*
-	 * Pop-up of finished entities.
-	 */
-	while ((RAW == 0) && (ctxt->inputNr > 1))
-	    xmlPopInput(ctxt);
-	SKIP_BLANKS;
 
 	if (RAW != '>') {
 	    xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
@@ -6779,9 +6574,10 @@
 		xmlFreeDocElementContent(ctxt->myDoc, content);
 	    }
 	} else {
-	    if (input != ctxt->input) {
+	    if (inputid != ctxt->input->id) {
 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-    "Element declaration doesn't start and stop in the same entity\n");
+                               "Element declaration doesn't start and stop in"
+                               " the same entity\n");
 	    }
 
 	    NEXT;
@@ -6834,9 +6630,9 @@
 	    return;
 	} else {
 	    if (ctxt->input->id != id) {
-		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-	    "All markup of the conditional section is not in the same entity\n",
-				     NULL, NULL);
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+	                       "All markup of the conditional section is not"
+                               " in the same entity\n");
 	    }
 	    NEXT;
 	}
@@ -6849,6 +6645,8 @@
 		    "Entering INCLUDE Conditional Section\n");
 	}
 
+        SKIP_BLANKS;
+        GROW;
 	while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
 	        (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) {
 	    const xmlChar *check = CUR_PTR;
@@ -6856,18 +6654,11 @@
 
 	    if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
 		xmlParseConditionalSections(ctxt);
-	    } else if (IS_BLANK_CH(CUR)) {
-		NEXT;
-	    } else if (RAW == '%') {
-		xmlParsePEReference(ctxt);
 	    } else
 		xmlParseMarkupDecl(ctxt);
 
-	    /*
-	     * Pop-up of finished entities.
-	     */
-	    while ((RAW == 0) && (ctxt->inputNr > 1))
-		xmlPopInput(ctxt);
+            SKIP_BLANKS;
+            GROW;
 
 	    if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
 		xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
@@ -6897,9 +6688,9 @@
 	    return;
 	} else {
 	    if (ctxt->input->id != id) {
-		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-	    "All markup of the conditional section is not in the same entity\n",
-				     NULL, NULL);
+		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+	                       "All markup of the conditional section is not"
+                               " in the same entity\n");
 	    }
 	    NEXT;
 	}
@@ -6961,9 +6752,9 @@
 	xmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);
     } else {
 	if (ctxt->input->id != id) {
-	    xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
-	"All markup of the conditional section is not in the same entity\n",
-				 NULL, NULL);
+	    xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+	                   "All markup of the conditional section is not in"
+                           " the same entity\n");
 	}
 	if ((ctxt-> instate != XML_PARSER_EOF) &&
 	    ((ctxt->input->cur + 3) <= ctxt->input->end))
@@ -7031,13 +6822,6 @@
         return;
 
     /*
-     * This is only for internal subset. On external entities,
-     * the replacement is done before parsing stage
-     */
-    if ((ctxt->external == 0) && (ctxt->inputNr == 1))
-	xmlParsePEReference(ctxt);
-
-    /*
      * Conditional sections are allowed from entities included
      * by PE References in the internal subset.
      */
@@ -7074,11 +6858,10 @@
 	return;
     }
 
-    if (!IS_BLANK_CH(CUR)) {
+    if (SKIP_BLANKS == 0) {
 	xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		       "Space needed after '<?xml'\n");
     }
-    SKIP_BLANKS;
 
     /*
      * We may have the VersionInfo here.
@@ -7087,7 +6870,7 @@
     if (version == NULL)
 	version = xmlCharStrdup(XML_DEFAULT_VERSION);
     else {
-	if (!IS_BLANK_CH(CUR)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 		           "Space needed here\n");
 	}
@@ -7178,27 +6961,19 @@
 
     ctxt->instate = XML_PARSER_DTD;
     ctxt->external = 1;
+    SKIP_BLANKS;
     while (((RAW == '<') && (NXT(1) == '?')) ||
            ((RAW == '<') && (NXT(1) == '!')) ||
-	   (RAW == '%') || IS_BLANK_CH(CUR)) {
+	   (RAW == '%')) {
 	const xmlChar *check = CUR_PTR;
 	unsigned int cons = ctxt->input->consumed;
 
 	GROW;
         if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
 	    xmlParseConditionalSections(ctxt);
-	} else if (IS_BLANK_CH(CUR)) {
-	    NEXT;
-	} else if (RAW == '%') {
-            xmlParsePEReference(ctxt);
 	} else
 	    xmlParseMarkupDecl(ctxt);
-
-	/*
-	 * Pop-up of finished entities.
-	 */
-	while ((RAW == 0) && (ctxt->inputNr > 1))
-	    xmlPopInput(ctxt);
+        SKIP_BLANKS;
 
 	if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
 	    xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
@@ -7427,6 +7202,9 @@
 	}
 	if (ent->checked == 0)
 	    ent->checked = 2;
+
+        /* Prevent entity from being parsed and expanded twice (Bug 760367). */
+        was_checked = 0;
     } else if (ent->checked != 1) {
 	ctxt->nbentities += ent->checked / 2;
     }
@@ -8063,12 +7841,14 @@
     NEXT;
     name = xmlParseName(ctxt);
     if (name == NULL) {
-	xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
-		       "xmlParsePEReference: no name\n");
+	xmlFatalErrMsg(ctxt, XML_ERR_PEREF_NO_NAME, "PEReference: no name\n");
 	return;
     }
+    if (xmlParserDebugEntities)
+	xmlGenericError(xmlGenericErrorContext,
+		"PEReference: %s\n", name);
     if (RAW != ';') {
-	xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+	xmlFatalErr(ctxt, XML_ERR_PEREF_SEMICOL_MISSING, NULL);
         return;
     }
 
@@ -8110,10 +7890,15 @@
 	     * ... The declaration of a parameter entity must
 	     * precede any reference to it...
 	     */
-	    xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
-			  "PEReference: %%%s; not found\n",
-			  name, NULL);
-	    ctxt->valid = 0;
+            if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) {
+                xmlValidityError(ctxt, XML_WAR_UNDECLARED_ENTITY,
+                                 "PEReference: %%%s; not found\n",
+                                 name, NULL);
+            } else
+                xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
+                              "PEReference: %%%s; not found\n",
+                              name, NULL);
+            ctxt->valid = 0;
 	}
 	xmlParserEntityCheck(ctxt, 0, NULL, 0);
     } else {
@@ -8125,41 +7910,54 @@
 	    xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
 		  "Internal: %%%s; is not a parameter entity\n",
 			  name, NULL);
-	} else if (ctxt->input->free != deallocblankswrapper) {
-	    input = xmlNewBlanksWrapperInputStream(ctxt, entity);
-	    if (xmlPushInput(ctxt, input) < 0)
-		return;
 	} else {
+            xmlChar start[4];
+            xmlCharEncoding enc;
+
 	    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
 	        ((ctxt->options & XML_PARSE_NOENT) == 0) &&
-	        ((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
-	        ((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
-	        ((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
-	        (ctxt->replaceEntities == 0) &&
-	        (ctxt->validate == 0))
-	        return;
-	    /*
-	     * TODO !!!
-	     * handle the extra spaces added before and after
-	     * c.f. http://www.w3.org/TR/REC-xml#as-PE
-	     */
-	    input = xmlNewEntityInputStream(ctxt, entity);
-	    if (xmlPushInput(ctxt, input) < 0)
+		((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
+		((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
+		((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
+		(ctxt->replaceEntities == 0) &&
+		(ctxt->validate == 0))
 		return;
-	    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
-		(CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
-		(IS_BLANK_CH(NXT(5)))) {
-		xmlParseTextDecl(ctxt);
-		if (ctxt->errNo ==
-		    XML_ERR_UNSUPPORTED_ENCODING) {
-		    /*
-		     * The XML REC instructs us to stop parsing
-		     * right here
-		     */
-		    xmlHaltParser(ctxt);
-		    return;
-		}
-	    }
+
+	    input = xmlNewEntityInputStream(ctxt, entity);
+	    if (xmlPushInput(ctxt, input) < 0) {
+                xmlFreeInputStream(input);
+		return;
+            }
+
+	    if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {
+                /*
+                 * Get the 4 first bytes and decode the charset
+                 * if enc != XML_CHAR_ENCODING_NONE
+                 * plug some encoding conversion routines.
+                 * Note that, since we may have some non-UTF8
+                 * encoding (like UTF16, bug 135229), the 'length'
+                 * is not known, but we can calculate based upon
+                 * the amount of data in the buffer.
+                 */
+                GROW
+                if (ctxt->instate == XML_PARSER_EOF)
+                    return;
+                if ((ctxt->input->end - ctxt->input->cur)>=4) {
+                    start[0] = RAW;
+                    start[1] = NXT(1);
+                    start[2] = NXT(2);
+                    start[3] = NXT(3);
+                    enc = xmlDetectCharEncoding(start, 4);
+                    if (enc != XML_CHAR_ENCODING_NONE) {
+                        xmlSwitchEncoding(ctxt, enc);
+                    }
+                }
+
+                if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
+                    (IS_BLANK_CH(NXT(5)))) {
+                    xmlParseTextDecl(ctxt);
+                }
+            }
 	}
     }
     ctxt->hasPErefs = 1;
@@ -8335,6 +8133,7 @@
 	entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
     if (ctxt->instate == XML_PARSER_EOF) {
 	xmlFree(name);
+	*str = ptr;
 	return(NULL);
     }
     if (entity == NULL) {
@@ -8473,6 +8272,7 @@
      * Is there any DTD definition ?
      */
     if (RAW == '[') {
+        int baseInputNr = ctxt->inputNr;
         ctxt->instate = XML_PARSER_DTD;
         NEXT;
 	/*
@@ -8480,7 +8280,8 @@
 	 * PEReferences.
 	 * Subsequence (markupdecl | PEReference | S)*
 	 */
-	while ((RAW != ']') && (ctxt->instate != XML_PARSER_EOF)) {
+	while (((RAW != ']') || (ctxt->inputNr > baseInputNr)) &&
+               (ctxt->instate != XML_PARSER_EOF)) {
 	    const xmlChar *check = CUR_PTR;
 	    unsigned int cons = ctxt->input->consumed;
 
@@ -8488,16 +8289,13 @@
 	    xmlParseMarkupDecl(ctxt);
 	    xmlParsePEReference(ctxt);
 
-	    /*
-	     * Pop-up of finished entities.
-	     */
-	    while ((RAW == 0) && (ctxt->inputNr > 1))
-		xmlPopInput(ctxt);
-
 	    if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
 		xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 	     "xmlParseInternalSubset: error detected in Markup declaration\n");
-		break;
+                if (ctxt->inputNr > baseInputNr)
+                    xmlPopInput(ctxt);
+                else
+		    break;
 	    }
 	}
 	if (RAW == ']') {
@@ -8575,7 +8373,7 @@
 	ctxt->instate = XML_PARSER_CONTENT;
     } else {
 	xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
-	       "Specification mandate value for attribute %s\n", name);
+	       "Specification mandates value for attribute %s\n", name);
 	return(NULL);
     }
 
@@ -8732,11 +8530,10 @@
 	GROW
 	if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
 	    break;
-	if (!IS_BLANK_CH(RAW)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "attributes construct error\n");
 	}
-	SKIP_BLANKS;
         if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
             (attname == NULL) && (attvalue == NULL)) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
@@ -9274,8 +9071,8 @@
     if (ctxt->attsSpecial != NULL) {
         int type;
 
-        type = (int) (long) xmlHashQLookup2(ctxt->attsSpecial,
-                                            pref, elem, *prefix, name);
+        type = (int) (ptrdiff_t) xmlHashQLookup2(ctxt->attsSpecial,
+                                                 pref, elem, *prefix, name);
         if (type != 0)
             normalize = 1;
     }
@@ -9308,7 +9105,7 @@
         ctxt->instate = XML_PARSER_CONTENT;
     } else {
         xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
-                          "Specification mandate value for attribute %s\n",
+                          "Specification mandates value for attribute %s\n",
                           name);
         return (NULL);
     }
@@ -9391,9 +9188,8 @@
     xmlChar *attvalue;
     const xmlChar **atts = ctxt->atts;
     int maxatts = ctxt->maxatts;
-    int nratts, nbatts, nbdef;
-    int i, j, nbNs, attval, oldline, oldcol, inputNr;
-    const xmlChar *base;
+    int nratts, nbatts, nbdef, inputid;
+    int i, j, nbNs, attval;
     unsigned long cur;
     int nsNr = ctxt->nsNr;
 
@@ -9407,13 +9203,9 @@
      *       The Shrinking is only possible once the full set of attribute
      *       callbacks have been done.
      */
-reparse:
     SHRINK;
-    base = ctxt->input->base;
     cur = ctxt->input->cur - ctxt->input->base;
-    inputNr = ctxt->inputNr;
-    oldline = ctxt->input->line;
-    oldcol = ctxt->input->col;
+    inputid = ctxt->input->id;
     nbatts = 0;
     nratts = 0;
     nbdef = 0;
@@ -9437,8 +9229,6 @@
      */
     SKIP_BLANKS;
     GROW;
-    if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
-        goto base_changed;
 
     while (((RAW != '>') &&
 	   ((RAW != '/') || (NXT(1) != '>')) &&
@@ -9449,211 +9239,181 @@
 
 	attname = xmlParseAttribute2(ctxt, prefix, localname,
 	                             &aprefix, &attvalue, &len, &alloc);
-	if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) {
-	    if ((attvalue != NULL) && (alloc != 0))
-	        xmlFree(attvalue);
-	    attvalue = NULL;
-	    goto base_changed;
-	}
-        if ((attname != NULL) && (attvalue != NULL)) {
-	    if (len < 0) len = xmlStrlen(attvalue);
-            if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {
-	        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
-		xmlURIPtr uri;
+        if ((attname == NULL) || (attvalue == NULL))
+            goto next_attr;
+	if (len < 0) len = xmlStrlen(attvalue);
 
-                if (URL == NULL) {
-		    xmlErrMemory(ctxt, "dictionary allocation failure");
-		    if ((attvalue != NULL) && (alloc != 0))
-			xmlFree(attvalue);
-		    return(NULL);
-		}
-                if (*URL != 0) {
-		    uri = xmlParseURI((const char *) URL);
-		    if (uri == NULL) {
-			xmlNsErr(ctxt, XML_WAR_NS_URI,
-			         "xmlns: '%s' is not a valid URI\n",
-					   URL, NULL, NULL);
-		    } else {
-			if (uri->scheme == NULL) {
-			    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
-				      "xmlns: URI %s is not absolute\n",
-				      URL, NULL, NULL);
-			}
-			xmlFreeURI(uri);
-		    }
-		    if (URL == ctxt->str_xml_ns) {
-			if (attname != ctxt->str_xml) {
-			    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			 "xml namespace URI cannot be the default namespace\n",
-				     NULL, NULL, NULL);
-			}
-			goto skip_default_ns;
-		    }
-		    if ((len == 29) &&
-			(xmlStrEqual(URL,
-				 BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
-			xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			     "reuse of the xmlns namespace name is forbidden\n",
-				 NULL, NULL, NULL);
-			goto skip_default_ns;
-		    }
-		}
-		/*
-		 * check that it's not a defined namespace
-		 */
-		for (j = 1;j <= nbNs;j++)
-		    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)
-			break;
-		if (j <= nbNs)
-		    xmlErrAttributeDup(ctxt, NULL, attname);
-		else
-		    if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
-skip_default_ns:
-		if ((attvalue != NULL) && (alloc != 0)) {
-		    xmlFree(attvalue);
-		    attvalue = NULL;
-		}
-		if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
-		    break;
-		if (!IS_BLANK_CH(RAW)) {
-		    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
-				   "attributes construct error\n");
-		    break;
-		}
-		SKIP_BLANKS;
-		if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
-		    goto base_changed;
-		continue;
-	    }
-            if (aprefix == ctxt->str_xmlns) {
-	        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
-		xmlURIPtr uri;
+        if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {
+            const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
+            xmlURIPtr uri;
 
-                if (attname == ctxt->str_xml) {
-		    if (URL != ctxt->str_xml_ns) {
-		        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			         "xml namespace prefix mapped to wrong URI\n",
-			         NULL, NULL, NULL);
-		    }
-		    /*
-		     * Do not keep a namespace definition node
-		     */
-		    goto skip_ns;
-		}
+            if (URL == NULL) {
+                xmlErrMemory(ctxt, "dictionary allocation failure");
+                if ((attvalue != NULL) && (alloc != 0))
+                    xmlFree(attvalue);
+                return(NULL);
+            }
+            if (*URL != 0) {
+                uri = xmlParseURI((const char *) URL);
+                if (uri == NULL) {
+                    xmlNsErr(ctxt, XML_WAR_NS_URI,
+                             "xmlns: '%s' is not a valid URI\n",
+                                       URL, NULL, NULL);
+                } else {
+                    if (uri->scheme == NULL) {
+                        xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
+                                  "xmlns: URI %s is not absolute\n",
+                                  URL, NULL, NULL);
+                    }
+                    xmlFreeURI(uri);
+                }
                 if (URL == ctxt->str_xml_ns) {
-		    if (attname != ctxt->str_xml) {
-		        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			         "xml namespace URI mapped to wrong prefix\n",
-			         NULL, NULL, NULL);
-		    }
-		    goto skip_ns;
-		}
-                if (attname == ctxt->str_xmlns) {
-		    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			     "redefinition of the xmlns prefix is forbidden\n",
-			     NULL, NULL, NULL);
-		    goto skip_ns;
-		}
-		if ((len == 29) &&
-		    (xmlStrEqual(URL,
-		                 BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
-		    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-			     "reuse of the xmlns namespace name is forbidden\n",
-			     NULL, NULL, NULL);
-		    goto skip_ns;
-		}
-		if ((URL == NULL) || (URL[0] == 0)) {
-		    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
-		             "xmlns:%s: Empty XML namespace is not allowed\n",
-			          attname, NULL, NULL);
-		    goto skip_ns;
-		} else {
-		    uri = xmlParseURI((const char *) URL);
-		    if (uri == NULL) {
-			xmlNsErr(ctxt, XML_WAR_NS_URI,
-			     "xmlns:%s: '%s' is not a valid URI\n",
-					   attname, URL, NULL);
-		    } else {
-			if ((ctxt->pedantic) && (uri->scheme == NULL)) {
-			    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
-				      "xmlns:%s: URI %s is not absolute\n",
-				      attname, URL, NULL);
-			}
-			xmlFreeURI(uri);
-		    }
-		}
+                    if (attname != ctxt->str_xml) {
+                        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                     "xml namespace URI cannot be the default namespace\n",
+                                 NULL, NULL, NULL);
+                    }
+                    goto next_attr;
+                }
+                if ((len == 29) &&
+                    (xmlStrEqual(URL,
+                             BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
+                    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                         "reuse of the xmlns namespace name is forbidden\n",
+                             NULL, NULL, NULL);
+                    goto next_attr;
+                }
+            }
+            /*
+             * check that it's not a defined namespace
+             */
+            for (j = 1;j <= nbNs;j++)
+                if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)
+                    break;
+            if (j <= nbNs)
+                xmlErrAttributeDup(ctxt, NULL, attname);
+            else
+                if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
 
-		/*
-		 * check that it's not a defined namespace
-		 */
-		for (j = 1;j <= nbNs;j++)
-		    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)
-			break;
-		if (j <= nbNs)
-		    xmlErrAttributeDup(ctxt, aprefix, attname);
-		else
-		    if (nsPush(ctxt, attname, URL) > 0) nbNs++;
-skip_ns:
-		if ((attvalue != NULL) && (alloc != 0)) {
-		    xmlFree(attvalue);
-		    attvalue = NULL;
-		}
-		if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
-		    break;
-		if (!IS_BLANK_CH(RAW)) {
-		    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
-				   "attributes construct error\n");
-		    break;
-		}
-		SKIP_BLANKS;
-		if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
-		    goto base_changed;
-		continue;
-	    }
+        } else if (aprefix == ctxt->str_xmlns) {
+            const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
+            xmlURIPtr uri;
 
-	    /*
-	     * Add the pair to atts
-	     */
-	    if ((atts == NULL) || (nbatts + 5 > maxatts)) {
-	        if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
-		    if (attvalue[len] == 0)
-			xmlFree(attvalue);
-		    goto failed;
-		}
-	        maxatts = ctxt->maxatts;
-		atts = ctxt->atts;
-	    }
-	    ctxt->attallocs[nratts++] = alloc;
-	    atts[nbatts++] = attname;
-	    atts[nbatts++] = aprefix;
-	    atts[nbatts++] = NULL; /* the URI will be fetched later */
-	    atts[nbatts++] = attvalue;
-	    attvalue += len;
-	    atts[nbatts++] = attvalue;
-	    /*
-	     * tag if some deallocation is needed
-	     */
-	    if (alloc != 0) attval = 1;
-	} else {
-	    if ((attvalue != NULL) && (attvalue[len] == 0))
-		xmlFree(attvalue);
-	}
+            if (attname == ctxt->str_xml) {
+                if (URL != ctxt->str_xml_ns) {
+                    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                             "xml namespace prefix mapped to wrong URI\n",
+                             NULL, NULL, NULL);
+                }
+                /*
+                 * Do not keep a namespace definition node
+                 */
+                goto next_attr;
+            }
+            if (URL == ctxt->str_xml_ns) {
+                if (attname != ctxt->str_xml) {
+                    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                             "xml namespace URI mapped to wrong prefix\n",
+                             NULL, NULL, NULL);
+                }
+                goto next_attr;
+            }
+            if (attname == ctxt->str_xmlns) {
+                xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                         "redefinition of the xmlns prefix is forbidden\n",
+                         NULL, NULL, NULL);
+                goto next_attr;
+            }
+            if ((len == 29) &&
+                (xmlStrEqual(URL,
+                             BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
+                xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                         "reuse of the xmlns namespace name is forbidden\n",
+                         NULL, NULL, NULL);
+                goto next_attr;
+            }
+            if ((URL == NULL) || (URL[0] == 0)) {
+                xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+                         "xmlns:%s: Empty XML namespace is not allowed\n",
+                              attname, NULL, NULL);
+                goto next_attr;
+            } else {
+                uri = xmlParseURI((const char *) URL);
+                if (uri == NULL) {
+                    xmlNsErr(ctxt, XML_WAR_NS_URI,
+                         "xmlns:%s: '%s' is not a valid URI\n",
+                                       attname, URL, NULL);
+                } else {
+                    if ((ctxt->pedantic) && (uri->scheme == NULL)) {
+                        xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
+                                  "xmlns:%s: URI %s is not absolute\n",
+                                  attname, URL, NULL);
+                    }
+                    xmlFreeURI(uri);
+                }
+            }
 
-failed:
+            /*
+             * check that it's not a defined namespace
+             */
+            for (j = 1;j <= nbNs;j++)
+                if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)
+                    break;
+            if (j <= nbNs)
+                xmlErrAttributeDup(ctxt, aprefix, attname);
+            else
+                if (nsPush(ctxt, attname, URL) > 0) nbNs++;
+
+        } else {
+            /*
+             * Add the pair to atts
+             */
+            if ((atts == NULL) || (nbatts + 5 > maxatts)) {
+                if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
+                    goto next_attr;
+                }
+                maxatts = ctxt->maxatts;
+                atts = ctxt->atts;
+            }
+            ctxt->attallocs[nratts++] = alloc;
+            atts[nbatts++] = attname;
+            atts[nbatts++] = aprefix;
+            /*
+             * The namespace URI field is used temporarily to point at the
+             * base of the current input buffer for non-alloced attributes.
+             * When the input buffer is reallocated, all the pointers become
+             * invalid, but they can be reconstructed later.
+             */
+            if (alloc)
+                atts[nbatts++] = NULL;
+            else
+                atts[nbatts++] = ctxt->input->base;
+            atts[nbatts++] = attvalue;
+            attvalue += len;
+            atts[nbatts++] = attvalue;
+            /*
+             * tag if some deallocation is needed
+             */
+            if (alloc != 0) attval = 1;
+            attvalue = NULL; /* moved into atts */
+        }
+
+next_attr:
+        if ((attvalue != NULL) && (alloc != 0)) {
+            xmlFree(attvalue);
+            attvalue = NULL;
+        }
 
 	GROW
         if (ctxt->instate == XML_PARSER_EOF)
             break;
-	if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
-	    goto base_changed;
 	if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
 	    break;
-	if (!IS_BLANK_CH(RAW)) {
+	if (SKIP_BLANKS == 0) {
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
 			   "attributes construct error\n");
 	    break;
 	}
-	SKIP_BLANKS;
         if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
             (attname == NULL) && (attvalue == NULL)) {
 	    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
@@ -9661,8 +9421,27 @@
 	    break;
 	}
         GROW;
-	if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
-	    goto base_changed;
+    }
+
+    if (ctxt->input->id != inputid) {
+        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+                    "Unexpected change of input\n");
+        localname = NULL;
+        goto done;
+    }
+
+    /* Reconstruct attribute value pointers. */
+    for (i = 0, j = 0; j < nratts; i += 5, j++) {
+        if (atts[i+2] != NULL) {
+            /*
+             * Arithmetic on dangling pointers is technically undefined
+             * behavior, but well...
+             */
+            ptrdiff_t offset = ctxt->input->base - atts[i+2];
+            atts[i+2]  = NULL;    /* Reset repurposed namespace URI */
+            atts[i+3] += offset;  /* value */
+            atts[i+4] += offset;  /* valuend */
+        }
     }
 
     /*
@@ -9809,6 +9588,7 @@
 	                  nsname, 0, NULL, nbatts / 5, nbdef, atts);
     }
 
+done:
     /*
      * Free up attribute allocated strings if needed
      */
@@ -9819,34 +9599,6 @@
     }
 
     return(localname);
-
-base_changed:
-    /*
-     * the attribute strings are valid iif the base didn't changed
-     */
-    if (attval != 0) {
-	for (i = 3,j = 0; j < nratts;i += 5,j++)
-	    if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))
-	        xmlFree((xmlChar *) atts[i]);
-    }
-
-    /*
-     * We can't switch from one entity to another in the middle
-     * of a start tag
-     */
-    if (inputNr != ctxt->inputNr) {
-        xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
-		    "Start tag doesn't start and stop in the same entity\n");
-	return(NULL);
-    }
-
-    ctxt->input->cur = ctxt->input->base + cur;
-    ctxt->input->line = oldline;
-    ctxt->input->col = oldcol;
-    if (ctxt->wellFormed == 1) {
-	goto reparse;
-    }
-    return(NULL);
 }
 
 /**
@@ -10115,11 +9867,6 @@
 	}
 
 	GROW;
-	/*
-	 * Pop-up of finished entities.
-	 */
-	while ((RAW == 0) && (ctxt->inputNr > 1))
-	    xmlPopInput(ctxt);
 	SHRINK;
 
 	if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
@@ -11272,7 +11019,7 @@
  * Check that the block of characters is okay as SCdata content [20]
  *
  * Returns the number of bytes to pass if okay, a negative index where an
- *         UTF-8 error occured otherwise
+ *         UTF-8 error occurred otherwise
  */
 static int
 xmlCheckCdataPush(const xmlChar *utf, int len, int complete) {
@@ -11414,13 +11161,6 @@
 	if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
 	    return(0);
 
-
-	/*
-	 * Pop-up of finished entities.
-	 */
-	while ((RAW == 0) && (ctxt->inputNr > 1))
-	    xmlPopInput(ctxt);
-
 	if (ctxt->input == NULL) break;
 	if (ctxt->input->buf == NULL)
 	    avail = ctxt->input->length -
@@ -11771,11 +11511,6 @@
 		    ctxt->checkIndex = 0;
 		    xmlParseCharData(ctxt, 0);
 		}
-		/*
-		 * Pop-up of finished entities.
-		 */
-		while ((RAW == 0) && (ctxt->inputNr > 1))
-		    xmlPopInput(ctxt);
 		if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
 		    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 		                "detected an error in element content\n");
@@ -11798,9 +11533,10 @@
 		}
 		if (ctxt->sax2) {
 		    xmlParseEndTag2(ctxt,
-		           (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3],
-		           (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0,
-		       (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0);
+		            (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3],
+		            (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0,
+		            (int) (ptrdiff_t)
+                                ctxt->pushTab[ctxt->nameNr * 3 - 1], 0);
 		    nameNsPop(ctxt);
 		}
 #ifdef LIBXML_SAX1_ENABLED
@@ -12718,6 +12454,8 @@
         return;
     ctxt->instate = XML_PARSER_EOF;
     ctxt->disableSAX = 1;
+    while (ctxt->inputNr > 1)
+        xmlFreeInputStream(inputPop(ctxt));
     if (ctxt->input != NULL) {
         /*
 	 * in case there was a specific allocation deallocate before
@@ -12729,6 +12467,7 @@
 	}
 	ctxt->input->cur = BAD_CAST"";
 	ctxt->input->base = ctxt->input->cur;
+        ctxt->input->end = ctxt->input->cur;
     }
 }
 
@@ -13497,7 +13236,7 @@
     /*
      * And record the last error if any
      */
-    if (ctxt->lastError.code != XML_ERR_OK)
+    if ((oldctxt != NULL) && (ctxt->lastError.code != XML_ERR_OK))
         xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
 
     if (sax != NULL)
@@ -15137,7 +14876,7 @@
     xmlInitNodeInfoSeq(&ctxt->node_seq);
 
     if (ctxt->attsDefault != NULL) {
-        xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);
+        xmlHashFree(ctxt->attsDefault, xmlHashDefaultDeallocator);
         ctxt->attsDefault = NULL;
     }
     if (ctxt->attsSpecial != NULL) {
diff --git a/parserInternals.c b/parserInternals.c
index bfc778a..e75e547 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -10,7 +10,7 @@
 #define IN_LIBXML
 #include "libxml.h"
 
-#if defined(WIN32) && !defined (__CYGWIN__)
+#if defined(_WIN32) && !defined (__CYGWIN__)
 #define XML_DIR_SEP '\\'
 #else
 #define XML_DIR_SEP '/'
@@ -435,8 +435,6 @@
 
     if ((*ctxt->input->cur == 0) &&
         (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
-        if ((ctxt->instate != XML_PARSER_COMMENT))
-            xmlPopInput(ctxt);
         return;
     }
 
@@ -470,8 +468,8 @@
 
         c = *cur;
         if (c & 0x80) {
-        if (c == 0xC0)
-	    goto encoding_error;
+            if (c == 0xC0)
+	        goto encoding_error;
             if (cur[1] == 0) {
                 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
                 cur = ctxt->input->cur;
@@ -523,8 +521,6 @@
             ctxt->input->cur++;
 
         ctxt->nbChars++;
-        if (*ctxt->input->cur == 0)
-            xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
     } else {
         /*
          * Assume it's a fixed length encoding (1) with
@@ -538,14 +534,9 @@
             ctxt->input->col++;
         ctxt->input->cur++;
         ctxt->nbChars++;
-        if (*ctxt->input->cur == 0)
-            xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
     }
-    if ((*ctxt->input->cur == '%') && (!ctxt->html))
-        xmlParserHandlePEReference(ctxt);
-    if ((*ctxt->input->cur == 0) &&
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
-        xmlPopInput(ctxt);
+    if (*ctxt->input->cur == 0)
+        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
     return;
 encoding_error:
     /*
@@ -1101,8 +1092,15 @@
 	        break;
 	}
     }
-    if (handler == NULL)
+    /*
+     * TODO: We could recover from errors in external entites 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);
     if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
@@ -1226,6 +1224,7 @@
                  */
                 nbchars = xmlCharEncFirstLineInput(input->buf, len);
             }
+            xmlBufResetInput(input->buf->buffer, input);
             if (nbchars < 0) {
                 xmlErrInternal(ctxt,
                                "switching encoding: encoder error\n",
@@ -1233,7 +1232,6 @@
                 return (-1);
             }
 	    input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
-            xmlBufResetInput(input->buf->buffer, input);
         }
         return (0);
     } else if (input->length == 0) {
@@ -1797,7 +1795,7 @@
     if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
     if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
     if (ctxt->attsDefault != NULL)
-        xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);
+        xmlHashFree(ctxt->attsDefault, xmlHashDefaultDeallocator);
     if (ctxt->attsSpecial != NULL)
         xmlHashFree(ctxt->attsSpecial, NULL);
     if (ctxt->freeElems != NULL) {
diff --git a/pattern.c b/pattern.c
index 33dee3a..0eb8d81 100644
--- a/pattern.c
+++ b/pattern.c
@@ -969,6 +969,7 @@
 		ERROR5(NULL, NULL, NULL,
 		    "xmlCompileAttributeTest : no namespace bound to prefix %s\n",
 		    prefix);
+	        XML_PAT_FREE_STRING(ctxt, prefix);
 		ctxt->error = 1;
 		goto error;
 	    }
diff --git a/python/setup.py b/python/setup.py
deleted file mode 100755
index 1ac4eac..0000000
--- a/python/setup.py
+++ /dev/null
@@ -1,242 +0,0 @@
-#!/usr/bin/python -u
-#
-# Setup script for libxml2 and libxslt if found
-#
-import sys, os
-from distutils.core import setup, Extension
-
-# Below ROOT, we expect to find include, include/libxml2, lib and bin.
-# On *nix, it is not needed (but should not harm),
-# on Windows, it is set by configure.js.
-ROOT = r'/usr/local'
-
-# Thread-enabled libxml2
-with_threads = 1
-
-# If this flag is set (windows only),
-# a private copy of the dlls are included in the package.
-# If this flag is not set, the libxml2 and libxslt
-# dlls must be found somewhere in the PATH at runtime.
-WITHDLLS = 1 and sys.platform.startswith('win')
-
-def missing(file):
-    if os.access(file, os.R_OK) == 0:
-        return 1
-    return 0
-
-try:
-    HOME = os.environ['HOME']
-except:
-    HOME="C:"
-
-if WITHDLLS:
-    # libxml dlls (expected in ROOT/bin)
-    dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
-    dlls = [os.path.join(ROOT,'bin',dll) for dll in dlls]
-
-    # create __init__.py for the libxmlmods package
-    if not os.path.exists("libxmlmods"):
-        os.mkdir("libxmlmods")
-        open("libxmlmods/__init__.py","w").close()
-
-    def altImport(s):
-        s = s.replace("import libxml2mod","from libxmlmods import libxml2mod")
-        s = s.replace("import libxsltmod","from libxmlmods import libxsltmod")
-        return s
-
-if sys.platform.startswith('win'):
-    libraryPrefix = 'lib'
-    platformLibs = []
-else:
-    libraryPrefix = ''
-    platformLibs = ["m","z"]
-
-# those are examined to find
-# - libxml2/libxml/tree.h
-# - iconv.h
-# - libxslt/xsltconfig.h
-includes_dir = [
-"/usr/include",
-"/usr/local/include",
-"/opt/include",
-os.path.join(ROOT,'include'),
-HOME
-];
-
-xml_includes=""
-for dir in includes_dir:
-    if not missing(dir + "/libxml2/libxml/tree.h"):
-        xml_includes=dir + "/libxml2"
-        break;
-
-if xml_includes == "":
-    print("failed to find headers for libxml2: update includes_dir")
-    sys.exit(1)
-
-iconv_includes=""
-for dir in includes_dir:
-    if not missing(dir + "/iconv.h"):
-        iconv_includes=dir
-        break;
-
-if iconv_includes == "":
-    print("failed to find headers for libiconv: update includes_dir")
-    sys.exit(1)
-
-# those are added in the linker search path for libraries
-libdirs = [
-os.path.join(ROOT,'lib'),
-]
-
-xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
-             "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
-             "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
-
-xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml",
-             "libxslt.c", "libxsl.py", "libxslt_wrap.h",
-             "xsltgenerator.py"]
-
-if missing("libxml2-py.c") or missing("libxml2.py"):
-    try:
-        try:
-            import xmlgenerator
-        except:
-            import generator
-    except:
-        print("failed to find and generate stubs for libxml2, aborting ...")
-        print(sys.exc_info()[0], sys.exc_info()[1])
-        sys.exit(1)
-
-    head = open("libxml.py", "r")
-    generated = open("libxml2class.py", "r")
-    result = open("libxml2.py", "w")
-    for line in head.readlines():
-        if WITHDLLS:
-            result.write(altImport(line))
-        else:
-            result.write(line)
-    for line in generated.readlines():
-        result.write(line)
-    head.close()
-    generated.close()
-    result.close()
-
-with_xslt=0
-if missing("libxslt-py.c") or missing("libxslt.py"):
-    if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
-        print("libxslt stub generator not found, libxslt not built")
-    else:
-        try:
-            import xsltgenerator
-        except:
-            print("failed to generate stubs for libxslt, aborting ...")
-            print(sys.exc_info()[0], sys.exc_info()[1])
-        else:
-            head = open("libxsl.py", "r")
-            generated = open("libxsltclass.py", "r")
-            result = open("libxslt.py", "w")
-            for line in head.readlines():
-                if WITHDLLS:
-                    result.write(altImport(line))
-                else:
-                    result.write(line)
-            for line in generated.readlines():
-                result.write(line)
-            head.close()
-            generated.close()
-            result.close()
-            with_xslt=1
-else:
-    with_xslt=1
-
-if with_xslt == 1:
-    xslt_includes=""
-    for dir in includes_dir:
-        if not missing(dir + "/libxslt/xsltconfig.h"):
-            xslt_includes=dir + "/libxslt"
-            break;
-
-    if xslt_includes == "":
-        print("failed to find headers for libxslt: update includes_dir")
-        with_xslt = 0
-
-
-descr = "libxml2 package"
-modules = [ 'libxml2', 'drv_libxml2' ]
-if WITHDLLS:
-    modules.append('libxmlmods.__init__')
-c_files = ['libxml2-py.c', 'libxml.c', 'types.c' ]
-includes= [xml_includes, iconv_includes]
-libs    = [libraryPrefix + "xml2"] + platformLibs
-macros  = []
-if with_threads:
-    macros.append(('_REENTRANT','1'))
-if with_xslt == 1:
-    descr = "libxml2 and libxslt package"
-    if not sys.platform.startswith('win'):
-        #
-        # We are gonna build 2 identical shared libs with merge initializing
-        # both libxml2mod and libxsltmod
-        #
-        c_files = c_files + ['libxslt-py.c', 'libxslt.c']
-        xslt_c_files = c_files
-        macros.append(('MERGED_MODULES', '1'))
-    else:
-        #
-        # On windows the MERGED_MODULE option is not needed
-        # (and does not work)
-        #
-        xslt_c_files = ['libxslt-py.c', 'libxslt.c', 'types.c']
-    libs.insert(0, libraryPrefix + 'exslt')
-    libs.insert(0, libraryPrefix + 'xslt')
-    includes.append(xslt_includes)
-    modules.append('libxslt')
-
-
-extens=[Extension('libxml2mod', c_files, include_dirs=includes,
-                  library_dirs=libdirs,
-                  libraries=libs, define_macros=macros)]
-if with_xslt == 1:
-    extens.append(Extension('libxsltmod', xslt_c_files, include_dirs=includes,
-                            library_dirs=libdirs,
-                            libraries=libs, define_macros=macros))
-
-if missing("MANIFEST"):
-
-    manifest = open("MANIFEST", "w")
-    manifest.write("setup.py\n")
-    for file in xml_files:
-        manifest.write(file + "\n")
-    if with_xslt == 1:
-        for file in xslt_files:
-            manifest.write(file + "\n")
-    manifest.close()
-
-if WITHDLLS:
-    ext_package = "libxmlmods"
-    if sys.version >= "2.2":
-        base = "lib/site-packages/"
-    else:
-        base = ""
-    data_files = [(base+"libxmlmods",dlls)]
-else:
-    ext_package = None
-    data_files = []
-
-setup (name = "libxml2-python",
-       # On *nix, the version number is created from setup.py.in
-       # On windows, it is set by configure.js
-       version = "2.9.4",
-       description = descr,
-       author = "Daniel Veillard",
-       author_email = "veillard@redhat.com",
-       url = "http://xmlsoft.org/python.html",
-       licence="MIT Licence",
-       py_modules=modules,
-       ext_modules=extens,
-       ext_package=ext_package,
-       data_files=data_files,
-       )
-
-sys.exit(0)
-
diff --git a/python/tests/xpathleak.py b/python/tests/xpathleak.py
index 33ab61c..6940b79 100755
--- a/python/tests/xpathleak.py
+++ b/python/tests/xpathleak.py
@@ -4,25 +4,15 @@
 libxml2.debugMemory(True)
 
 expect="""--> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 --> Invalid expression
---> xmlXPathEval: evaluation failed
 """
 err=""
 def callback(ctx, str):
diff --git a/relaxng.c b/relaxng.c
index 3d3e69c..88d351d 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
@@ -2728,9 +2729,10 @@
  * Free the structure associated to the type library
  */
 static void
-xmlRelaxNGFreeTypeLibrary(xmlRelaxNGTypeLibraryPtr lib,
+xmlRelaxNGFreeTypeLibrary(void *payload,
                           const xmlChar * namespace ATTRIBUTE_UNUSED)
 {
+    xmlRelaxNGTypeLibraryPtr lib = (xmlRelaxNGTypeLibraryPtr) payload;
     if (lib == NULL)
         return;
     if (lib->namespace != NULL)
@@ -2841,8 +2843,7 @@
     xmlSchemaCleanupTypes();
     if (xmlRelaxNGTypeInitialized == 0)
         return;
-    xmlHashFree(xmlRelaxNGRegisteredTypes, (xmlHashDeallocator)
-                xmlRelaxNGFreeTypeLibrary);
+    xmlHashFree(xmlRelaxNGRegisteredTypes, xmlRelaxNGFreeTypeLibrary);
     xmlRelaxNGTypeInitialized = 0;
 }
 
@@ -4310,10 +4311,11 @@
  *     algorithm
  */
 static void
-xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def,
-                             xmlRelaxNGParserCtxtPtr ctxt,
-                             xmlChar * name ATTRIBUTE_UNUSED)
+xmlRelaxNGComputeInterleaves(void *payload, void *data,
+                             const xmlChar * name ATTRIBUTE_UNUSED)
 {
+    xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
+    xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
     xmlRelaxNGDefinePtr cur, *tmp;
 
     xmlRelaxNGPartitionPtr partitions = NULL;
@@ -4404,7 +4406,7 @@
                 if ((*tmp)->type == XML_RELAXNG_TEXT) {
                     res = xmlHashAddEntry2(partitions->triage,
                                            BAD_CAST "#text", NULL,
-                                           (void *) (long) (i + 1));
+                                           (void *) (ptrdiff_t) (i + 1));
                     if (res != 0)
                         is_determinist = -1;
                 } else if (((*tmp)->type == XML_RELAXNG_ELEMENT) &&
@@ -4412,22 +4414,22 @@
                     if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0))
                         res = xmlHashAddEntry2(partitions->triage,
                                                (*tmp)->name, NULL,
-                                               (void *) (long) (i + 1));
+                                               (void *) (ptrdiff_t) (i + 1));
                     else
                         res = xmlHashAddEntry2(partitions->triage,
                                                (*tmp)->name, (*tmp)->ns,
-                                               (void *) (long) (i + 1));
+                                               (void *) (ptrdiff_t) (i + 1));
                     if (res != 0)
                         is_determinist = -1;
                 } else if ((*tmp)->type == XML_RELAXNG_ELEMENT) {
                     if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0))
                         res = xmlHashAddEntry2(partitions->triage,
                                                BAD_CAST "#any", NULL,
-                                               (void *) (long) (i + 1));
+                                               (void *) (ptrdiff_t) (i + 1));
                     else
                         res = xmlHashAddEntry2(partitions->triage,
                                                BAD_CAST "#any", (*tmp)->ns,
-                                               (void *) (long) (i + 1));
+                                               (void *) (ptrdiff_t) (i + 1));
                     if ((*tmp)->nameClass != NULL)
                         is_determinist = 2;
                     if (res != 0)
@@ -4662,7 +4664,7 @@
  * Import import one references into the current grammar
  */
 static void
-xmlRelaxNGParseImportRef(void *payload, void *data, xmlChar *name) {
+xmlRelaxNGParseImportRef(void *payload, void *data, const xmlChar *name) {
     xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
     xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
     int tmp;
@@ -5669,10 +5671,10 @@
  * element of a given grammar using the same name.
  */
 static void
-xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref,
-                         xmlRelaxNGParserCtxtPtr ctxt,
-                         const xmlChar * name)
+xmlRelaxNGCheckReference(void *payload, void *data, const xmlChar * name)
 {
+    xmlRelaxNGDefinePtr ref = (xmlRelaxNGDefinePtr) payload;
+    xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
     xmlRelaxNGGrammarPtr grammar;
     xmlRelaxNGDefinePtr def, cur;
 
@@ -5725,9 +5727,10 @@
  * element of a given grammar using the same name.
  */
 static void
-xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define,
-                       xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * name)
+xmlRelaxNGCheckCombine(void *payload, void *data, const xmlChar * name)
 {
+    xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) payload;
+    xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
     xmlChar *combine;
     int choiceOrInterleave = -1;
     int missing = 0;
@@ -6610,16 +6613,14 @@
      */
     xmlRelaxNGCombineStart(ctxt, ret);
     if (ret->defs != NULL) {
-        xmlHashScan(ret->defs, (xmlHashScanner) xmlRelaxNGCheckCombine,
-                    ctxt);
+        xmlHashScan(ret->defs, xmlRelaxNGCheckCombine, ctxt);
     }
 
     /*
      * link together defines and refs in this grammar
      */
     if (ret->refs != NULL) {
-        xmlHashScan(ret->refs, (xmlHashScanner) xmlRelaxNGCheckReference,
-                    ctxt);
+        xmlHashScan(ret->refs, xmlRelaxNGCheckReference, ctxt);
     }
 
 
@@ -7550,8 +7551,7 @@
      * try to preprocess interleaves
      */
     if (ctxt->interleaves != NULL) {
-        xmlHashScan(ctxt->interleaves,
-                    (xmlHashScanner) xmlRelaxNGComputeInterleaves, ctxt);
+        xmlHashScan(ctxt->interleaves, xmlRelaxNGComputeInterleaves, ctxt);
     }
 
     /*
@@ -8890,7 +8890,7 @@
             if (ret != 0) {
                 break;
             }
-            /* no break on purpose */
+            /* Falls through. */
         case XML_RELAXNG_ZEROORMORE:{
                 xmlChar *cur, *temp;
 
@@ -9387,7 +9387,7 @@
             if (tmp == NULL) {
                 i = nbgroups;
             } else {
-                i = ((long) tmp) - 1;
+                i = ((ptrdiff_t) tmp) - 1;
                 if (partitions->flags & IS_NEEDCHECK) {
                     group = partitions->groups[i];
                     if (!xmlRelaxNGNodeMatchesList(cur, group->defs))
@@ -10167,7 +10167,7 @@
             }
             if (ctxt->errNr > errNr)
                 xmlRelaxNGPopErrors(ctxt, errNr);
-            /* no break on purpose */
+            /* Falls through. */
         case XML_RELAXNG_ZEROORMORE:{
                 int progress;
                 xmlRelaxNGStatesPtr states = NULL, res = NULL;
diff --git a/result/HTML/53867.html.sax b/result/HTML/53867.html.sax
index 81a9f15..1bb0d14 100644
--- a/result/HTML/53867.html.sax
+++ b/result/HTML/53867.html.sax
@@ -1,10 +1,10 @@
 SAX.setDocumentLocator()
 SAX.startDocument()
 SAX.startElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(style)
 SAX.cdata(
@@ -15,12 +15,12 @@
 SAX.cdata(................
 ............., 977)
 SAX.endElement(style)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endDocument()
diff --git a/result/HTML/758518-entity.html b/result/HTML/758518-entity.html
new file mode 100644
index 0000000..e72b0cb
--- /dev/null
+++ b/result/HTML/758518-entity.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>&amp;&Ugrave;</p></body></html>
diff --git a/result/HTML/758518-entity.html.err b/result/HTML/758518-entity.html.err
new file mode 100644
index 0000000..0186677
--- /dev/null
+++ b/result/HTML/758518-entity.html.err
@@ -0,0 +1,3 @@
+./test/HTML/758518-entity.html:1: HTML parser error : htmlParseEntityRef: expecting ';'

+  ^
diff --git a/result/HTML/758518-entity.html.sax b/result/HTML/758518-entity.html.sax
new file mode 100644
index 0000000..3d017ab
--- /dev/null
+++ b/result/HTML/758518-entity.html.sax
@@ -0,0 +1,12 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.error: htmlParseEntityRef: expecting ';'
+SAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(&amp;, 1)
+SAX.characters(&Ugrave;, 2)
+SAX.endElement(p)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/result/HTML/758518-tag.html b/result/HTML/758518-tag.html
new file mode 100644
index 0000000..f99f421
--- /dev/null
+++ b/result/HTML/758518-tag.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>&#147;</p></body></html>
diff --git a/result/HTML/758518-tag.html.err b/result/HTML/758518-tag.html.err
new file mode 100644
index 0000000..c912c91
--- /dev/null
+++ b/result/HTML/758518-tag.html.err
@@ -0,0 +1,3 @@
+./test/HTML/758518-tag.html:1: HTML parser error : PI is not started correctly

+^
diff --git a/result/HTML/758518-tag.html.sax b/result/HTML/758518-tag.html.sax
new file mode 100644
index 0000000..fd4aa94
--- /dev/null
+++ b/result/HTML/758518-tag.html.sax
@@ -0,0 +1,10 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.error: PI is not started correctlySAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(&#147;, 2)
+SAX.endElement(p)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/result/HTML/758605.html.sax b/result/HTML/758605.html.sax
index c6e0986..1f18426 100644
--- a/result/HTML/758605.html.sax
+++ b/result/HTML/758605.html.sax
@@ -6,7 +6,7 @@
 SAX.startElement(p)
 SAX.characters(&amp;, 1)
 SAX.characters(&ecirc;, 2)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(p)
 SAX.endElement(body)
diff --git a/result/HTML/Down.html.sax b/result/HTML/Down.html.sax
index c23c332..ae3c056 100644
--- a/result/HTML/Down.html.sax
+++ b/result/HTML/Down.html.sax
@@ -1,18 +1,18 @@
 SAX.setDocumentLocator()
 SAX.startDocument()
 SAX.startElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
   , 3)
 SAX.startElement(title)
 SAX.characters(This service is temporary down, 30)
 SAX.endElement(title)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
 
 , 2)
 SAX.startElement(body, bgcolor='#FFFFFF')
@@ -29,9 +29,9 @@
 SAX.characters(
 , 1)
 SAX.endElement(body)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endDocument()
diff --git a/result/HTML/attrents.html.sax b/result/HTML/attrents.html.sax
index c1cfb42..30df683 100644
--- a/result/HTML/attrents.html.sax
+++ b/result/HTML/attrents.html.sax
@@ -1,7 +1,7 @@
 SAX.setDocumentLocator()
 SAX.startDocument()
 SAX.startElement(html)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(body, bgcolor='#FFFFFF')
 SAX.characters(

@@ -13,9 +13,9 @@
 SAX.characters(

 , 2)
 SAX.endElement(body)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.endElement(html)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.endDocument()
diff --git a/result/HTML/autoclose.html.sax b/result/HTML/autoclose.html.sax
index 5a45627..c541c5e 100644
--- a/result/HTML/autoclose.html.sax
+++ b/result/HTML/autoclose.html.sax
@@ -4,7 +4,7 @@
 SAX.startElement(body)
 SAX.startElement(hr)
 SAX.endElement(hr)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(body)
 SAX.endElement(html)
diff --git a/result/HTML/cf_128.html.sax b/result/HTML/cf_128.html.sax
index 8f66a42..3913ebd 100644
--- a/result/HTML/cf_128.html.sax
+++ b/result/HTML/cf_128.html.sax
@@ -2,18 +2,18 @@
 SAX.startDocument()
 SAX.internalSubset(HTML, -//W3C//DTD HTML 4.0 Transitional//EN, http://www.w3.org/TR/REC-html40/strict.dtd)
 SAX.startElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(title)
 SAX.characters(gnome-xml push mode bug, 23)
 SAX.endElement(title)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(head)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(body)
 SAX.characters(
@@ -61,9 +61,9 @@
 SAX.characters(
   , 3)
 SAX.endElement(body)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(html)
-SAX.ignorableWhitespace(  
+SAX.characters(  
 , 3)
 SAX.endDocument()
diff --git a/result/HTML/doc2.htm.sax b/result/HTML/doc2.htm.sax
index 7cbbc51..63c7164 100644
--- a/result/HTML/doc2.htm.sax
+++ b/result/HTML/doc2.htm.sax
@@ -8,31 +8,31 @@
 SAX.startElement(title)
 SAX.characters(Welcome to Copernic.com, 23)
 SAX.endElement(title)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(script, language='javascript')
 SAX.cdata(
           NS_ActualOpen=windo, 194)
 SAX.endElement(script)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.comment( END Naviscope Javascript )
 SAX.error: Misplaced DOCTYPE declaration
 SAX.internalSubset(HTML, -//W3C//DTD HTML 4.0 Transitional//EN, )
 SAX.comment( saved from url=(0027)http://www.agents-tech.com/ )
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(meta, content='text/html; charset=iso-8859-1', http-equiv='Content-Type')
 SAX.endElement(meta)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(meta, content='Copernic.com Inc. develops innovative agent technology solutions to efficiently access and manage the overwhelming quantity of information available on the Internet and intranets.', name='DESCRIPTION')
 SAX.endElement(meta)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(meta, content='agent,technology,intranet,extranet,management,filtering,ranking,solution,service,intelligent,intelligence,client,server,architecture,developer,development,information,telecommunication,announcement,press,product,profile,contact,multi-agent,meta-search,metasearch,multi-thread,mobile,wireless,shopping,robot,PCS,Copernic,engine,toolkit,CDK,EDK', name='KEYWORDS')
 SAX.endElement(meta)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(meta, content='MSHTML 5.00.3103.1000', name='GENERATOR')
 SAX.endElement(meta)
@@ -64,6 +64,6 @@
 SAX.endElement(noframes)
 SAX.endElement(frameset)
 SAX.endElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endDocument()
diff --git a/result/HTML/doc3.htm.sax b/result/HTML/doc3.htm.sax
index 13477f1..fb33cf2 100644
--- a/result/HTML/doc3.htm.sax
+++ b/result/HTML/doc3.htm.sax
@@ -8,46 +8,46 @@
 SAX.startElement(title)
 SAX.characters(BP6.com #1 online resource for, 47)
 SAX.endElement(title)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(script, language='javascript')
 SAX.cdata(

           NS_ActualOpen=wind, 199)
 SAX.endElement(script)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.comment( END Naviscope Javascript )
 SAX.error: Misplaced DOCTYPE declaration
 SAX.internalSubset(HTML, -//W3C//DTD HTML 3.2//EN, )
 SAX.comment(last modified on Tuesday, February 22, 2000 11:47 PM )
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(meta, content='text/html;CHARSET=iso-8859-1', http-equiv='Content-Type')
 SAX.endElement(meta)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(meta, content='Tim', name='Author')
 SAX.endElement(meta)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(style, type='text/css')
 SAX.cdata(A.nav {

 	COLOR: #003399; TEXT, 115)
 SAX.endElement(style)
-SAX.ignorableWhitespace(

+SAX.characters(

 

 , 4)
 SAX.startElement(script, language='JavaScript')
 SAX.cdata(
 &lt;!-- Idea by:  Nic Wolfe (, 476)
 SAX.endElement(script)
-SAX.ignorableWhitespace(

+SAX.characters(

 

 , 4)
 SAX.startElement(meta, content='MSHTML 5.00.3103.1000', name='GENERATOR')
 SAX.endElement(meta)
 SAX.endElement(head)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(body, alink='red', bgcolor='black', link='red', text='white', vlink='red')
 SAX.characters(

@@ -2873,6 +2873,6 @@
 , 2)
 SAX.endElement(body)
 SAX.endElement(html)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.endDocument()
diff --git a/result/HTML/entities.html.sax b/result/HTML/entities.html.sax
index 709b60d..3843f6d 100644
--- a/result/HTML/entities.html.sax
+++ b/result/HTML/entities.html.sax
@@ -20,7 +20,7 @@
 SAX.characters( b
 , 3)
 SAX.endElement(p)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(body)
 SAX.endElement(html)
diff --git a/result/HTML/entities2.html.sax b/result/HTML/entities2.html.sax
index c6efbe5..131b813 100644
--- a/result/HTML/entities2.html.sax
+++ b/result/HTML/entities2.html.sax
@@ -1,7 +1,7 @@
 SAX.setDocumentLocator()
 SAX.startDocument()
 SAX.startElement(html)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.startElement(body)
 SAX.characters(
@@ -17,7 +17,7 @@
 SAX.characters(
 , 1)
 SAX.endElement(body)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.endElement(html)
 SAX.endDocument()