Work done on the plane, ready to release libxml2-2.0.0, Daniel
diff --git a/ChangeLog b/ChangeLog
index d4ac9fc..27843c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Mon Apr  3 21:47:10 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
+
+	* configure.in: preparing libxml-2.0.0 version looks Ok so far
+	* README TODO: updated for release
+	* uri.c uri.h: added authority parsing/saving
+	* uri.c testURI.c Makefile.am: moved the testing code to testURI.c
+	* xmlversion.h.in configure.in nanoftp.[ch] nanohttp.[ch] encoding.h
+	  debugXML.[ch] xpath.[ch] xmlIO.c tester.c testXPath.c testHTML.c
+	  tree.c HTMLtree.c HTMLparser.c tree.c tree.h parser.c
+	  Makefile.am : added compile-time customization of libxml
+	  --with-ftp --with-http --with-html --with-xpath --with-debug
+	  --with-mem-debug
+	* *.[ch] autoconf.sh : moved to an absolute adressing of includes : 
+	  #include <libxml/xxx.h> I hope it won't break too much stuff
+	  and will be manageable in the future...
+	* xmllint.c Makefile.am libxml.spec.in : renamed tester.c to xmllint.c
+	  and added xmllint to the installed programs
+	* uri.h: added xmlFreeURI()
+	  
 Fri Mar 24 14:35:21 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
 
 	* uri.c uri.h: finished the escaping handling, the base support
diff --git a/HTMLparser.c b/HTMLparser.c
index aafaec6..5c1cfae 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -12,6 +12,9 @@
 #include "config.h"
 #endif
 
+#include "xmlversion.h"
+#ifdef LIBXML_HTML_ENABLED
+
 #include <stdio.h>
 #include <string.h> /* for memset() only */
 #ifdef HAVE_CTYPE_H
@@ -33,14 +36,14 @@
 #include <zlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "tree.h"
-#include "HTMLparser.h"
-#include "entities.h"
-#include "encoding.h"
-#include "valid.h"
-#include "parserInternals.h"
-#include "xmlIO.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/entities.h>
+#include <libxml/encoding.h>
+#include <libxml/valid.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xmlIO.h>
 #include "xml-error.h"
 
 #define HTML_MAX_NAMELEN 1000
@@ -3843,3 +3846,5 @@
 htmlParseFile(const char *filename, const char *encoding) {
     return(htmlSAXParseFile(filename, encoding, NULL, NULL));
 }
+
+#endif /* LIBXML_HTML_ENABLED */
diff --git a/HTMLparser.h b/HTMLparser.h
index 22fe614..44d9c27 100644
--- a/HTMLparser.h
+++ b/HTMLparser.h
@@ -8,7 +8,7 @@
 
 #ifndef __HTML_PARSER_H__
 #define __HTML_PARSER_H__
-#include "parser.h"
+#include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/HTMLtree.c b/HTMLtree.c
index fe9c0ae..e4a955c 100644
--- a/HTMLtree.c
+++ b/HTMLtree.c
@@ -12,6 +12,10 @@
 #else
 #include "config.h"
 #endif
+
+#include "xmlversion.h"
+#ifdef LIBXML_HTML_ENABLED
+
 #include <stdio.h>
 #include <string.h> /* for memset() only ! */
 
@@ -22,11 +26,11 @@
 #include <stdlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "HTMLparser.h"
-#include "HTMLtree.h"
-#include "entities.h"
-#include "valid.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/entities.h>
+#include <libxml/valid.h>
 
 static void
 htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur);
@@ -404,3 +408,4 @@
     return(ret * sizeof(xmlChar));
 }
 
+#endif /* LIBXML_HTML_ENABLED */
diff --git a/HTMLtree.h b/HTMLtree.h
index 2b375e5..9378ba4 100644
--- a/HTMLtree.h
+++ b/HTMLtree.h
@@ -11,7 +11,7 @@
 #define __HTML_TREE_H__
 
 #include <stdio.h>
-#include "tree.h"
+#include <libxml/tree.h>
 
 
 #ifdef __cplusplus
diff --git a/Makefile.am b/Makefile.am
index 8ed4141..74624da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,11 +2,11 @@
 
 SUBDIRS = doc
 
-INCLUDES = -I@srcdir@ @Z_CFLAGS@ @CORBA_CFLAGS@ $(VERSION_FLAGS)
+INCLUDES = -I@srcdir@ @Z_CFLAGS@ @CORBA_CFLAGS@ 
 
-VERSION_FLAGS = -DLIBXML_VERSION=\"@LIBXML_VERSION@\"
+noinst_PROGRAMS=testSAX testHTML testXPath testURI
 
-noinst_PROGRAMS=tester testSAX testHTML testXPath testURI
+bin_PROGRAMS = xmllint
 
 bin_SCRIPTS=xml-config
 
@@ -21,20 +21,20 @@
 		encoding.c \
 		error.c \
 		parser.c \
+		tree.c \
+		xmlIO.c \
+		xmlmemory.c \
+		uri.c \
+		valid.c \
+		xlink.c \
 		HTMLparser.c \
 		HTMLtree.c \
 		debugXML.c \
-		tree.c \
 		xpath.c \
-		xmlIO.c \
-		xmlmemory.c \
 		nanohttp.c \
-		nanoftp.c \
-		uri.c \
-		valid.c \
-		xlink.c
+		nanoftp.c
 
-xmlincdir = $(includedir)/gnome-xml
+xmlincdir = $(includedir)/libxml
 xmlinc_HEADERS = \
 		SAX.h \
 		entities.h \
@@ -53,15 +53,16 @@
 		nanoftp.h \
 		uri.h \
 		valid.h \
-		xlink.h
+		xlink.h \
+		xmlversion.h
 
 DEPS = $(top_builddir)/libxml.la
 LDADDS = $(top_builddir)/libxml.la @Z_LIBS@ @M_LIBS@
 
-tester_SOURCES=tester.c
-tester_LDFLAGS = 
-tester_DEPENDENCIES = $(DEPS)
-tester_LDADD=  @RDL_LIBS@ $(LDADDS)
+xmllint_SOURCES=xmllint.c
+xmllint_LDFLAGS = 
+xmllint_DEPENDENCIES = $(DEPS)
+xmllint_LDADD=  @RDL_LIBS@ $(LDADDS)
 
 testSAX_SOURCES=testSAX.c
 testSAX_LDFLAGS = 
@@ -78,15 +79,23 @@
 testXPath_DEPENDENCIES = $(DEPS)
 testXPath_LDADD= $(LDADDS)
 
+testURI_SOURCES=testURI.c
+testURI_LDFLAGS = 
+testURI_DEPENDENCIES = $(DEPS)
+testURI_LDADD= $(LDADDS)
+
 check-local: tests
 
+install-data: $(srcdir)/libxml
+
+$(srcdir)/libxml:
+	-$(RM) $(srcdir)/libxml
+	ln -s $(srcdir)/. $(srcdir)/libxml
+
 testall : tests SVGtests SAXtests XPathtests XMLenttests
 
 tests: XMLtests HTMLtests Validtests
 
-testURI: $(srcdir)/uri.c $(srcdir)/uri.h xmlmemory.o
-	$(CC) $(CFLAGS) -DSTANDALONE -o testURI $(srcdir)/uri.c xmlmemory.o 
-
 HTMLtests : testHTML
 	@echo "##"
 	@echo "## HTML regression tests"
@@ -107,7 +116,7 @@
 	      rm result.$$name result2.$$name error.$$name ; \
 	  fi ; fi ; done)
 
-XMLtests : tester
+XMLtests : xmllint
 	@echo "##"
 	@echo "## XML regression tests"
 	@echo "##"
@@ -116,17 +125,17 @@
 	  if [ ! -d $$i ] ; then \
 	  if [ ! -f $(srcdir)/result/$$name ] ; then \
 	      echo New test file $$name ; \
-	      $(top_builddir)/tester $$i > $(srcdir)/result/$$name ; \
+	      $(top_builddir)/xmllint $$i > $(srcdir)/result/$$name ; \
 	  else \
 	      echo Testing $$name ; \
-	      $(top_builddir)/tester $$i > result.$$name ; \
+	      $(top_builddir)/xmllint $$i > result.$$name ; \
 	      diff $(srcdir)/result/$$name result.$$name ; \
-	      $(top_builddir)/tester result.$$name > result2.$$name ; \
+	      $(top_builddir)/xmllint result.$$name > result2.$$name ; \
 	      diff result.$$name result2.$$name ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
 
-XMLenttests : tester
+XMLenttests : xmllint
 	@echo "##"
 	@echo "## XML entity subst regression tests"
 	@echo "##"
@@ -135,12 +144,12 @@
 	  if [ ! -d $$i ] ; then \
 	  if [ ! -f $(srcdir)/result/noent/$$name ] ; then \
 	      echo New test file $$name ; \
-	      $(top_builddir)/tester --noent $$i > $(srcdir)/result/noent/$$name ; \
+	      $(top_builddir)/xmllint --noent $$i > $(srcdir)/result/noent/$$name ; \
 	  else \
 	      echo Testing $$name ; \
-	      $(top_builddir)/tester --noent $$i > result.$$name ; \
+	      $(top_builddir)/xmllint --noent $$i > result.$$name ; \
 	      diff $(srcdir)/result/noent/$$name result.$$name ; \
-	      $(top_builddir)/tester --noent result.$$name > result2.$$name ; \
+	      $(top_builddir)/xmllint --noent result.$$name > result2.$$name ; \
 	      diff result.$$name result2.$$name ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
@@ -177,7 +186,7 @@
 	      rm result.$$name ; \
 	  fi ; fi ; done ; fi ; done)
 
-SVGtests : tester
+SVGtests : xmllint
 	@echo "##"
 	@echo "## SVG parsing regression tests"
 	@echo "##"
@@ -186,12 +195,12 @@
 	  if [ ! -d $$i ] ; then \
 	  if [ ! -f $(srcdir)/result/SVG/$$name ] ; then \
 	      echo New test file $$name ; \
-	      $(top_builddir)/tester $$i > $(srcdir)/result/SVG/$$name ; \
+	      $(top_builddir)/xmllint $$i > $(srcdir)/result/SVG/$$name ; \
 	  else \
 	      echo Testing $$name ; \
-	      $(top_builddir)/tester $$i > result.$$name ; \
+	      $(top_builddir)/xmllint $$i > result.$$name ; \
 	      diff $(srcdir)/result/SVG/$$name result.$$name ; \
-	      $(top_builddir)/tester result.$$name > result2.$$name ; \
+	      $(top_builddir)/xmllint result.$$name > result2.$$name ; \
 	      diff result.$$name result2.$$name ; \
 	      rm result.$$name result2.$$name ; \
 	  fi ; fi ; done)
@@ -214,7 +223,7 @@
 	  fi ; fi ; done)
 
 
-Validtests : tester
+Validtests : xmllint
 	@echo "##"
 	@echo "## Validity checking regression tests"
 	@echo "##"
@@ -223,10 +232,10 @@
 	  if [ ! -d $$i ] ; then \
 	  if [ ! -f $(srcdir)/result/VC/$$name ] ; then \
 	      echo New test file $$name ; \
-	      $(top_builddir)/tester --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
+	      $(top_builddir)/xmllint --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
 	  else \
 	      echo Testing $$name ; \
-	      $(top_builddir)/tester --noout --valid $$i 2> result.$$name ; \
+	      $(top_builddir)/xmllint --noout --valid $$i 2> result.$$name ; \
 	      diff $(srcdir)/result/VC/$$name result.$$name ; \
 	      rm result.$$name ; \
 	  fi ; fi ; done)
@@ -238,10 +247,10 @@
 	  if [ ! -d $$i ] ; then \
 	  if [ ! -f $(srcdir)/result/valid/$$name ] ; then \
 	      echo New test file $$name ; \
-	      $(top_builddir)/tester --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \
+	      $(top_builddir)/xmllint --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \
 	  else \
 	      echo Testing $$name ; \
-	      $(top_builddir)/tester --valid $$i > result.$$name 2>error.$$name ; \
+	      $(top_builddir)/xmllint --valid $$i > result.$$name 2>error.$$name ; \
 	      diff $(srcdir)/result/valid/$$name result.$$name ; \
 	      diff $(srcdir)/result/valid/$$name.err error.$$name ; \
 	      rm result.$$name error.$$name ; \
diff --git a/README b/README
index 48aa403..2746bfe 100644
--- a/README
+++ b/README
@@ -1,14 +1,14 @@
 
                   XML parser for Gnome
 
-Documentation is available on-line at
-    http://rufus.w3.org/veillard/XML/xml.html
+Full documentation is available on-line at
+    http://xmlsoft.org/
 
-A mailing-list has been set-up, to subscribe:
+A mailing-list is available, to subscribe:
     echo "subscribe xml" | mail majordomo@rufus.w3.org
 
 The list archive is at:
-    http://rufus.w3.org/veillard/XML/messages/
+    http://xmlsoft.org/messages/
 
 NOTE: I use a second CVS server for experimental version of the XML code,
       this mean that if you commit without a Changelog or without sending
diff --git a/SAX.c b/SAX.c
index 10c6a83..f1a85ed 100644
--- a/SAX.c
+++ b/SAX.c
@@ -14,16 +14,16 @@
 #endif
 #include <stdio.h>
 #include <stdlib.h>
-#include "xmlmemory.h"
-#include "tree.h"
-#include "parser.h"
-#include "parserInternals.h"
-#include "valid.h"
-#include "entities.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include <libxml/valid.h>
+#include <libxml/entities.h>
 #include "xml-error.h"
-#include "debugXML.h"
-#include "xmlIO.h"
-#include "SAX.h"
+#include <libxml/debugXML.h>
+#include <libxml/xmlIO.h>
+#include <libxml/SAX.h>
 
 /* #define DEBUG_SAX */
 /* #define DEBUG_SAX_TREE */
diff --git a/SAX.h b/SAX.h
index bbd0f96..a3bd102 100644
--- a/SAX.h
+++ b/SAX.h
@@ -12,8 +12,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "parser.h"
-#include "xlink.h"
+#include <libxml/parser.h>
+#include <libxml/xlink.h>
 
 #ifdef __cplusplus
 #define extern "C" {
diff --git a/TODO b/TODO
index ff7f3c0..a89f24c 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,10 @@
            TODO for the XML parser and stuff:
 	   ==================================
 
+CVS:
+====
+  rename tester.c to xmllint.c
+
 TODO:
 =====
 
@@ -14,6 +18,9 @@
   be saved back.
 - Go through erratas and do the cleanup.
   http://www.w3.org/XML/xml-19980210-errata ... bummmer 
+- Handle undefined namespaces in entity contents better ... at least
+  issue a warning
+- General checking of DTD validation in presence of namespaces ... hairy
 
 TODO:
 =====
@@ -36,14 +43,6 @@
 EXTENSIONS:
 ===========
 
-- Check attribute normalization especially xmlGetProp()
-- Validity checking problems for NOTATIONS attributes
-- Validity checking problems for ENTITY ENTITIES attributes
-- dynamically adapt the alloc entry point to use g_alloc()/g_free()
-  if the programmer wants it: 
-    - use xmlMemSetup() to reset the routines used.
-- Parsing of a well balanced chunk
-- URI module: validation, base, etc ...
 - Tools to produce man pages from the SGML docs.
 - Finish XPath
   => attributes addressing troubles
@@ -79,8 +78,7 @@
 - Add a DTD cache prefilled with xhtml DTDs and entities and a program to
   manage them -> like the /usr/bin/install-catalog from SGML
   right place seems $datadir/xmldtds
-
-- turn tester into a generic program xml-test installed with xml-devel
+  Maybe this is better left to user apps
 
 - Add output to XHTML in case of HTML documents.
 
@@ -88,6 +86,15 @@
 Done:
 =====
 
+- dynamically adapt the alloc entry point to use g_alloc()/g_free()
+  if the programmer wants it: 
+    - use xmlMemSetup() to reset the routines used.
+- Check attribute normalization especially xmlGetProp()
+- Validity checking problems for NOTATIONS attributes
+- Validity checking problems for ENTITY ENTITIES attributes
+- Parsing of a well balanced chunk xmlParseBalancedChunkMemory()
+- URI module: validation, base, etc ... see uri.[ch]
+- turn tester into a generic program xmllint installed with libxml
 - extend validity checks to go through entities content instead of
   just labelling them PCDATA
 - Save Dtds using the children list instead of dumping the tables,
diff --git a/autogen.sh b/autogen.sh
index 0399185..e5a30eb 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -10,7 +10,7 @@
 
 (autoconf --version) < /dev/null > /dev/null 2>&1 || {
 	echo
-	echo "You must have autoconf installed to compile gnome-xml."
+	echo "You must have autoconf installed to compile libxml."
 	echo "Download the appropriate package for your distribution,"
 	echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
 	DIE=1
@@ -18,7 +18,7 @@
 
 (libtool --version) < /dev/null > /dev/null 2>&1 || {
 	echo
-	echo "You must have libtool installed to compile gnome-xml."
+	echo "You must have libtool installed to compile libxml."
 	echo "Get ftp://alpha.gnu.org/gnu/libtool-1.0h.tar.gz"
 	echo "(or a newer version if it is available)"
 	DIE=1
@@ -26,7 +26,7 @@
 
 (automake --version) < /dev/null > /dev/null 2>&1 || {
 	echo
-	echo "You must have automake installed to compile gnome-xml."
+	echo "You must have automake installed to compile libxml."
 	echo "Get ftp://ftp.cygnus.com/pub/home/tromey/automake-1.2d.tar.gz"
 	echo "(or a newer version if it is available)"
 	DIE=1
@@ -37,7 +37,7 @@
 fi
 
 test -f entities.h || {
-	echo "You must run this script in the top-level gnome-xml directory"
+	echo "You must run this script in the top-level libxml directory"
 	exit 1
 }
 
@@ -61,4 +61,4 @@
 $srcdir/configure "$@"
 
 echo 
-echo "Now type 'make' to compile gnome-xml."
+echo "Now type 'make' to compile libxml."
diff --git a/configure.in b/configure.in
index 01e8dfd..baea933 100644
--- a/configure.in
+++ b/configure.in
@@ -9,13 +9,16 @@
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
 
+LIBXML_VERSION_NUMBER=`expr $LIBXML_MAJOR_VERSION \* 10000 + $LIBXML_MINOR_VERSION \* 100 + $LIBXML_MICRO_VERSION`
+
 AC_SUBST(LIBXML_MAJOR_VERSION)
 AC_SUBST(LIBXML_MINOR_VERSION)
 AC_SUBST(LIBXML_MICRO_VERSION)
 AC_SUBST(LIBXML_VERSION)
 AC_SUBST(LIBXML_VERSION_INFO)
+AC_SUBST(LIBXML_VERSION_NUMBER)
 
-VERSION=${LIBXML_VERSION}beta
+VERSION=${LIBXML_VERSION}
 
 AM_INIT_AUTOMAKE(libxml2, $VERSION)
 
@@ -108,7 +111,7 @@
   [M_LIBS="-lm"; AC_DEFINE(HAVE_ISINF)]))
 
 XML_LIBDIR='-L${libdir}'
-XML_INCLUDEDIR='-I${includedir}/gnome-xml'
+XML_INCLUDEDIR='-I${includedir}/libxml -I${includedir}'
 XML_LIBS="-lxml $Z_LIBS $M_LIBS $LIBS"
 
 dnl
@@ -147,6 +150,80 @@
 AC_CHECK_LIB(readline, readline,
              RDL_LIBS="-lreadline ${RDL_LIBS}"; AC_DEFINE(HAVE_LIBREADLINE))
 
+
+dnl
+dnl Aloow to disable various pieces
+dnl
+
+AC_ARG_WITH(ftp, [  --with-ftp              Add the FTP support (on)])
+if test "$with_ftp" = "no" ; then
+    echo Disabling FTP support
+    WITH_FTP=0
+    FTP_OBJ=
+else    
+    WITH_FTP=1
+    FTP_OBJ=nanoftp.o
+fi
+AC_SUBST(WITH_FTP)
+AC_SUBST(FTP_OBJ)
+
+AC_ARG_WITH(http, [  --with-http             Add the HTTP support (on)])
+if test "$with_http" = "no" ; then
+    echo Disabling HTTP support
+    WITH_HTTP=0
+    HTTP_OBJ=
+else    
+    WITH_HTTP=1
+    HTTP_OBJ=nanohttp.o
+fi
+AC_SUBST(WITH_HTTP)
+AC_SUBST(HTTP_OBJ)
+
+AC_ARG_WITH(html, [  --with-html             Add the HTML support (on)])
+if test "$with_html" = "no" ; then
+    echo Disabling HTML support
+    WITH_HTML=0
+    HTML_OBJ=
+else    
+    WITH_HTML=1
+    HTML_OBJ="HTMLparser.o HTMLtree.o"
+fi
+AC_SUBST(WITH_HTML)
+AC_SUBST(HTML_OBJ)
+
+AC_ARG_WITH(xpath, [  --with-xpath            Add the XPATH support (on)])
+if test "$with_xpath" = "no" ; then
+    echo Disabling XPATH support
+    WITH_XPATH=0
+    XPATH_OBJ=
+else    
+    WITH_XPATH=1
+    XPATH_OBJ=xpath.o
+fi
+AC_SUBST(WITH_XPATH)
+AC_SUBST(XPATH_OBJ)
+
+AC_ARG_WITH(debug, [  --with-debug            Add the debugging module (on)])
+if test "$with_debug" = "no" ; then
+    echo Disabling DEBUG support
+    WITH_DEBUG=0
+    DEBUG_OBJ=
+else    
+    WITH_DEBUG=1
+    DEBUG_OBJ=debugXML.o
+fi
+AC_SUBST(WITH_DEBUG)
+AC_SUBST(DEBUG_OBJ)
+
+AC_ARG_WITH(mem_debug, [  --with-mem-debug        Add the memory debugging module (off)])
+if test "$with_mem_debug" = "yes" ; then
+    echo Enabling memory debug support
+    WITH_MEM_DEBUG=1
+else    
+    WITH_MEM_DEBUG=0
+fi
+AC_SUBST(WITH_MEM_DEBUG)
+
 AC_SUBST(CFLAGS)
 AC_SUBST(XML_CFLAGS)
 
@@ -159,5 +236,18 @@
 
 AC_SUBST(M_LIBS)
 AC_SUBST(RDL_LIBS)
-AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xml-config win32config.h)
+
+dnl
+dnl create the libxml link needed to get dependencies right
+dnl
+if test -f $srcdir/libxml 
+then
+    rm -f $srcdir/libxml libxml
+    (cd $srcdir ; ln -s . libxml)
+    (ln -s . libxml)
+else
+    (cd $srcdir ; rm -f libxml ; ln -s . libxml)
+    (rm -f libxml ; ln -s . libxml)
+fi
+AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xmlversion.h xml-config win32config.h)
 
diff --git a/debugXML.c b/debugXML.c
index a872e88..6a271b8 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -12,6 +12,10 @@
 #else
 #include "config.h"
 #endif
+
+#include "xmlversion.h"
+#ifdef LIBXML_DEBUG_ENABLED
+
 #include <stdio.h>
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
@@ -19,13 +23,13 @@
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
-#include "xmlmemory.h"
-#include "tree.h"
-#include "parser.h"
-#include "valid.h"
-#include "debugXML.h"
-#include "HTMLtree.h"
-#include "HTMLparser.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/valid.h>
+#include <libxml/debugXML.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/HTMLparser.h>
 
 #define IS_BLANK(c)							\
   (((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
@@ -1059,10 +1063,17 @@
 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
                   xmlNodePtr node2) {
     if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
+#ifdef LIBXML_HTML_ENABLED
 	if (node->type == XML_HTML_DOCUMENT_NODE)
 	    htmlDocDump(stdout, (htmlDocPtr) node);
 	else
 	    htmlNodeDumpFile(stdout, ctxt->doc, node);
+#else
+	if (node->type == XML_DOCUMENT_NODE)
+	    xmlDocDump(stdout, (xmlDocPtr) node);
+	else
+	    xmlElemDump(stdout, ctxt->doc, node);
+#endif /* LIBXML_HTML_ENABLED */
     } else {
 	if (node->type == XML_DOCUMENT_NODE)
 	    xmlDocDump(stdout, (xmlDocPtr) node);
@@ -1095,7 +1106,12 @@
 	html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
 
     if (html) {
+#ifdef LIBXML_HTML_ENABLED
 	doc = htmlParseFile(filename, NULL);
+#else	
+	printf("HTML support not compiled in\n");
+	doc = NULL;
+#endif /* LIBXML_HTML_ENABLED */
     } else {
 	doc = xmlParseFile(filename);
     }
@@ -1104,11 +1120,15 @@
 	    xmlFreeDoc(ctxt->doc);
 	}
 	ctxt->loaded = 1;
+#ifdef LIBXML_XPATH_ENABLED
 	xmlXPathFreeContext(ctxt->pctxt);
+#endif /* LIBXML_XPATH_ENABLED */
 	xmlFree(ctxt->filename);
 	ctxt->doc = doc;
 	ctxt->node = (xmlNodePtr) doc;	 
+#ifdef LIBXML_XPATH_ENABLED
 	ctxt->pctxt = xmlXPathNewContext(doc);
+#endif /* LIBXML_XPATH_ENABLED */
 	ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
     } else
         return(-1);
@@ -1151,10 +1171,17 @@
 	    }
 	    break;
         case XML_HTML_DOCUMENT_NODE:
+#ifdef LIBXML_HTML_ENABLED
 	    if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
 		fprintf(stderr, "Failed to write to %s\n", filename);
 		return(-1);
 	    }
+#else
+	    if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
+		fprintf(stderr, "Failed to write to %s\n", filename);
+		return(-1);
+	    }
+#endif /* LIBXML_HTML_ENABLED */
 	    break;
 	default: {
 	    FILE *f;
@@ -1203,9 +1230,15 @@
 	    }
 	    break;
         case XML_HTML_DOCUMENT_NODE:
+#ifdef LIBXML_HTML_ENABLED
 	    if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
 		fprintf(stderr, "Failed to save to %s\n", filename);
 	    }
+#else
+	    if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
+		fprintf(stderr, "Failed to save to %s\n", filename);
+	    }
+#endif /* LIBXML_HTML_ENABLED */
 	    break;
 	default:
 	    fprintf(stderr, 
@@ -1444,11 +1477,13 @@
     ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
     ctxt->node = (xmlNodePtr) ctxt->doc;	 
 
+#ifdef LIBXML_XPATH_ENABLED
     ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
     if (ctxt->pctxt == NULL) {
 	xmlFree(ctxt);
 	return;
     }
+#endif /* LIBXML_XPATH_ENABLED */
     while (1) {
         if (ctxt->node == (xmlNodePtr) ctxt->doc)
 	    sprintf(prompt, "%s > ", "/");
@@ -1503,10 +1538,14 @@
 		    xmlShellList(ctxt, NULL, ctxt->node, NULL);
 	    } else {
 	        ctxt->pctxt->node = ctxt->node;
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
 	        ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
 		list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
+#else
+		list = NULL;
+#endif /* LIBXML_XPATH_ENABLED */
 		if (list != NULL) {
 		    switch (list->type) {
 			case XPATH_UNDEFINED:
@@ -1539,8 +1578,10 @@
 		} else {
 		    fprintf(stderr, "%s: no such node\n", arg);
 		}
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
+#endif /* LIBXML_XPATH_ENABLED */
 		ctxt->pctxt->nodelist = NULL;
 	    }
 	} else if (!strcmp(command, "cd")) {
@@ -1548,10 +1589,14 @@
 		ctxt->node = (xmlNodePtr) ctxt->doc;
 	    } else {
 	        ctxt->pctxt->node = ctxt->node;
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
 	        ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
 		list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
+#else
+		list = NULL;
+#endif /* LIBXML_XPATH_ENABLED */
 		if (list != NULL) {
 		    switch (list->type) {
 			case XPATH_UNDEFINED:
@@ -1578,8 +1623,10 @@
 		} else {
 		    fprintf(stderr, "%s: no such node\n", arg);
 		}
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
+#endif /* LIBXML_XPATH_ENABLED */
 		ctxt->pctxt->nodelist = NULL;
 	    }
 	} else if (!strcmp(command, "cat")) {
@@ -1587,10 +1634,14 @@
 		xmlShellCat(ctxt, NULL, ctxt->node, NULL);
 	    } else {
 	        ctxt->pctxt->node = ctxt->node;
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
 	        ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
 		list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
+#else
+		list = NULL;
+#endif /* LIBXML_XPATH_ENABLED */
 		if (list != NULL) {
 		    switch (list->type) {
 			case XPATH_UNDEFINED:
@@ -1620,8 +1671,10 @@
 		} else {
 		    fprintf(stderr, "%s: no such node\n", arg);
 		}
+#ifdef LIBXML_XPATH_ENABLED
 		if (ctxt->pctxt->nodelist != NULL)
 		    xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
+#endif /* LIBXML_XPATH_ENABLED */
 		ctxt->pctxt->nodelist = NULL;
 	    }
 	} else {
@@ -1629,7 +1682,9 @@
 	}
 	free(cmdline); /* not xmlFree here ! */
     }
+#ifdef LIBXML_XPATH_ENABLED
     xmlXPathFreeContext(ctxt->pctxt);
+#endif /* LIBXML_XPATH_ENABLED */
     if (ctxt->loaded) {
         xmlFreeDoc(ctxt->doc);
     }
@@ -1638,3 +1693,4 @@
         free(cmdline); /* not xmlFree here ! */
 }
 
+#endif /* LIBXML_DEBUG_ENABLED */
diff --git a/debugXML.h b/debugXML.h
index 5d4d2ae..3138469 100644
--- a/debugXML.h
+++ b/debugXML.h
@@ -8,8 +8,11 @@
 #ifndef __DEBUG_XML__
 #define __DEBUG_XML__
 #include <stdio.h>
-#include "tree.h"
-#include "xpath.h"
+#include <libxml/tree.h>
+
+#ifdef LIBXML_DEBUG_ENABLED
+
+#include <libxml/xpath.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -103,4 +106,6 @@
 #ifdef __cplusplus
 }
 #endif
+
+#endif /* LIBXML_DEBUG_ENABLED */
 #endif /* __DEBUG_XML__ */
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 6a0a787..83c5190 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -3,7 +3,7 @@
 <html>
 <head>
   <title>Upgrading libxml client code from 1.x to 2.x</title>
-  <meta name="GENERATOR" content="amaya V2.1">
+  <meta name="GENERATOR" content="amaya V2.4">
   <meta http-equiv="Content-Type" content="text/html">
 </head>
 
@@ -67,6 +67,14 @@
     (read and save) without inflating the document with extra formatting
     chars.</p>
   </li>
+  <li>The include path has changed to $prefix/libxml/ and the includes
+    themselves uses this new prefix in includes instructions... If you are
+    using (as expected) the 
+    <pre>xml-config --cflags</pre>
+    <p>output to generate you compile commands this will probably work out of
+    the box</p>
+    <p> </p>
+  </li>
 </ol>
 
 <p>Let me put some emphasis on the fact that there is far more changes from
@@ -77,6 +85,6 @@
 
 <p><a href="mailto:Daniel.Veillard@w3.org">Daniel Veillard</a></p>
 
-<p>$Id: upgrade.html,v 1.1 2000/03/04 11:39:43 veillard Exp $</p>
+<p>$Id: upgrade.html,v 1.2 2000/03/06 07:41:49 veillard Exp $</p>
 </body>
 </html>
diff --git a/doc/xml.html b/doc/xml.html
index 6504b94..3f03d7a 100644
--- a/doc/xml.html
+++ b/doc/xml.html
@@ -184,12 +184,30 @@
 <ul>
   <li>working on HTML and XML links recognition layers, get in touch with me
     if you want to test those.</li>
+  <li>So far the feedback on the libxml2 beta is positive</li>
+</ul>
+
+<h3>2.0.0: Apr 3 2000</h3>
+<ul>
+  <li>First public release of libxml2. If you are using libxml, it's a good
+    idea to check the 1.x to 2.x upgrade instructions</li>
+  <li>The include are now located under $prefix/include/libxml (instead of
+    $prefix/include/gnome-xml), they also are referenced by 
+    <pre>#include &lt;libxml/xxx.h></pre>
+    <p>instead of </p>
+    <pre>#include "xxx.h"</pre>
+  </li>
   <li>a new URI module for parsing URIs and following strictly RFC 2396</li>
   <li>the memory allocation routines used by libxml can now be overloaded
     dynamically by using xmlMemSetup()</li>
-  <li>So far the feedback on the libxml2 beta is positive</li>
+  <li>The previously CVS only tool tester has been renamed
+    <strong>xmllint</strong> and is now installed as part of the libxml2
+    package</li>
+  <li></li>
 </ul>
 
+<p> </p>
+
 <h3>2.0.0beta: Mar 14 2000</h3>
 <ul>
   <li>This is a first Beta release of libxml version 2</li>
@@ -404,7 +422,7 @@
 <p><img src="structure.gif" alt=" structure.gif "></p>
 
 <p>In the source package there is a small program (not installed by default)
-called <strong>tester</strong> which parses XML files given as argument and
+called <strong>xmllint</strong> which parses XML files given as argument and
 prints them back as parsed. This is useful for detecting errors both in XML
 code and in the XML parser itself. It has an option <strong>--debug</strong>
 which prints the actual in-memory structure of the document, here is the
@@ -590,9 +608,10 @@
 
 <p>The other way to get an XML tree in memory is by building it. Basically
 there is a set of functions dedicated to building new elements. (These are
-also described in "tree.h".) For example, here is a piece of code that
-produces the XML document used in the previous examples:</p>
-<pre>    xmlDocPtr doc;
+also described in &lt;libxml/tree.h>.) For example, here is a piece of code
+that produces the XML document used in the previous examples:</p>
+<pre>    #include &lt;libxml/tree.h>
+    xmlDocPtr doc;
     xmlNodePtr tree, subtree;
 
     doc = xmlNewDoc("1.0");
@@ -759,7 +778,7 @@
 
 <p>Here is the DOM tree built by libxml for the previous document in the
 default case:</p>
-<pre>/gnome/src/gnome-xml -> ./tester --debug test/ent1
+<pre>/gnome/src/gnome-xml -> ./xmllint --debug test/ent1
 DOCUMENT
 version=1.0
    ELEMENT EXAMPLE
@@ -816,7 +835,7 @@
 element and atributes with that URL. I suggest to use an URL within a domain
 you control, and that the URL should contain some kind of version information
 if possible. For example, <code>"http://www.gnome.org/gnumeric/1.0/"</code> is
-a good namespace scheme. </p>
+a good namespace scheme.</p>
 
 <p>Then when you load a file, make sure that a namespace carrying the
 version-independent prefix is installed on the root element of your document,
@@ -1047,7 +1066,8 @@
 
 <p>Here is another piece of code used to parse another level of the
 structure:</p>
-<pre>/*
+<pre>#include &lt;libxml/tree.h>
+/*
  * a Description for a Job
  */
 typedef struct job {
@@ -1112,6 +1132,6 @@
 
 <p><a href="mailto:Daniel.Veillard@w3.org">Daniel Veillard</a></p>
 
-<p>$Id: xml.html,v 1.30 2000/03/20 13:07:14 veillard Exp $</p>
+<p>$Id: xml.html,v 1.31 2000/03/24 13:41:54 veillard Exp $</p>
 </body>
 </html>
diff --git a/encoding.c b/encoding.c
index f02f197..4200929 100644
--- a/encoding.c
+++ b/encoding.c
@@ -34,8 +34,8 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-#include "encoding.h"
-#include "xmlmemory.h"
+#include <libxml/encoding.h>
+#include <libxml/xmlmemory.h>
 
 xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
 xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
diff --git a/encoding.h b/encoding.h
index 12a7910..1b1c92e 100644
--- a/encoding.h
+++ b/encoding.h
@@ -21,6 +21,7 @@
 #ifndef __XML_CHAR_ENCODING_H__
 #define __XML_CHAR_ENCODING_H__
 
+#include <libxml/xmlversion.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/entities.c b/entities.c
index d9cefed..15247a2 100644
--- a/entities.c
+++ b/entities.c
@@ -17,9 +17,9 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-#include "xmlmemory.h"
-#include "entities.h"
-#include "parser.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/entities.h>
+#include <libxml/parser.h>
 
 #define DEBUG_ENT_REF /* debugging of cross entities dependancies */
 
diff --git a/entities.h b/entities.h
index 50e1f51..f0ec731 100644
--- a/entities.h
+++ b/entities.h
@@ -9,7 +9,7 @@
 #ifndef __XML_ENTITIES_H__
 #define __XML_ENTITIES_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/error.c b/error.c
index 3191d80..4a124db 100644
--- a/error.c
+++ b/error.c
@@ -14,7 +14,7 @@
 
 #include <stdio.h>
 #include <stdarg.h>
-#include "parser.h"
+#include <libxml/parser.h>
 
 /**
  * xmlParserPrintFileInfo:
diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h
index 22fe614..44d9c27 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -8,7 +8,7 @@
 
 #ifndef __HTML_PARSER_H__
 #define __HTML_PARSER_H__
-#include "parser.h"
+#include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/libxml/HTMLtree.h b/include/libxml/HTMLtree.h
index 2b375e5..9378ba4 100644
--- a/include/libxml/HTMLtree.h
+++ b/include/libxml/HTMLtree.h
@@ -11,7 +11,7 @@
 #define __HTML_TREE_H__
 
 #include <stdio.h>
-#include "tree.h"
+#include <libxml/tree.h>
 
 
 #ifdef __cplusplus
diff --git a/include/libxml/SAX.h b/include/libxml/SAX.h
index bbd0f96..a3bd102 100644
--- a/include/libxml/SAX.h
+++ b/include/libxml/SAX.h
@@ -12,8 +12,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "parser.h"
-#include "xlink.h"
+#include <libxml/parser.h>
+#include <libxml/xlink.h>
 
 #ifdef __cplusplus
 #define extern "C" {
diff --git a/include/libxml/debugXML.h b/include/libxml/debugXML.h
index 5d4d2ae..3138469 100644
--- a/include/libxml/debugXML.h
+++ b/include/libxml/debugXML.h
@@ -8,8 +8,11 @@
 #ifndef __DEBUG_XML__
 #define __DEBUG_XML__
 #include <stdio.h>
-#include "tree.h"
-#include "xpath.h"
+#include <libxml/tree.h>
+
+#ifdef LIBXML_DEBUG_ENABLED
+
+#include <libxml/xpath.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -103,4 +106,6 @@
 #ifdef __cplusplus
 }
 #endif
+
+#endif /* LIBXML_DEBUG_ENABLED */
 #endif /* __DEBUG_XML__ */
diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h
index 12a7910..1b1c92e 100644
--- a/include/libxml/encoding.h
+++ b/include/libxml/encoding.h
@@ -21,6 +21,7 @@
 #ifndef __XML_CHAR_ENCODING_H__
 #define __XML_CHAR_ENCODING_H__
 
+#include <libxml/xmlversion.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/libxml/entities.h b/include/libxml/entities.h
index 50e1f51..f0ec731 100644
--- a/include/libxml/entities.h
+++ b/include/libxml/entities.h
@@ -9,7 +9,7 @@
 #ifndef __XML_ENTITIES_H__
 #define __XML_ENTITIES_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h
index 0a41b97..5346528 100644
--- a/include/libxml/nanoftp.h
+++ b/include/libxml/nanoftp.h
@@ -8,6 +8,10 @@
  
 #ifndef __NANO_FTP_H__
 #define __NANO_FTP_H__
+
+#include <libxml/xmlversion.h>
+#ifdef LIBXML_FTP_ENABLED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -101,5 +105,6 @@
 
 #ifdef __cplusplus
 }
+#endif /* LIBXML_FTP_ENABLED */
 #endif
 #endif /* __NANO_FTP_H__ */
diff --git a/include/libxml/nanohttp.h b/include/libxml/nanohttp.h
index 7e0e2ce..49f7645 100644
--- a/include/libxml/nanohttp.h
+++ b/include/libxml/nanohttp.h
@@ -8,6 +8,10 @@
  
 #ifndef __NANO_HTTP_H__
 #define __NANO_HTTP_H__
+
+#include <libxml/xmlversion.h>
+#ifdef LIBXML_HTTP_ENABLED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -33,5 +37,7 @@
 void	xmlNanoHTTPClose	(void *ctx);
 #ifdef __cplusplus
 }
+
+#endif /* LIBXML_HTTP_ENABLED */
 #endif
 #endif /* __NANO_HTTP_H__ */
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 54f00e6..d755b70 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -9,10 +9,10 @@
 #ifndef __XML_PARSER_H__
 #define __XML_PARSER_H__
 
-#include "tree.h"
-#include "valid.h"
-#include "xmlIO.h"
-#include "entities.h"
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/xmlIO.h>
+#include <libxml/entities.h>
 
 
 #ifdef __cplusplus
diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h
index db7965a..b29f11c 100644
--- a/include/libxml/parserInternals.h
+++ b/include/libxml/parserInternals.h
@@ -9,7 +9,7 @@
 #ifndef __XML_PARSER_INTERNALS_H__
 #define __XML_PARSER_INTERNALS_H__
 
-#include "parser.h"
+#include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index c881728..a755962 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -11,6 +11,7 @@
 #define __XML_TREE_H__
 
 #include <stdio.h>
+#include <libxml/xmlversion.h>
 
 
 #ifdef __cplusplus
diff --git a/include/libxml/uri.h b/include/libxml/uri.h
index b8b3995..f54754a 100644
--- a/include/libxml/uri.h
+++ b/include/libxml/uri.h
@@ -11,7 +11,7 @@
 #ifndef __XML_URI_H__
 #define __XML_URI_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -24,10 +24,11 @@
 typedef xmlURI *xmlURIPtr;
 struct _xmlURI {
     char *scheme;
+    char *opaque;
     char *authority;
     char *server;
+    char *user;
     int port;
-    char *opaque;
     char *path;
     char *query;
     char *fragment;
@@ -42,7 +43,13 @@
 	                        	 const xmlChar *base);
 xmlURIPtr	xmlParseURI		(const char *URI);
 xmlChar *	xmlSaveUri		(xmlURIPtr uri);
+void		xmlPrintURI		(FILE *stream,
+					 xmlURIPtr uri);
+char *		xmlURIUnescapeString	(const char *str,
+					 int len,
+					 char *target);
 int		xmlNormalizeURIPath	(char *path);
+void		xmlFreeURI		(xmlURIPtr uri);
 
 #ifdef __cplusplus
 }
diff --git a/include/libxml/valid.h b/include/libxml/valid.h
index d211207..ef65907 100644
--- a/include/libxml/valid.h
+++ b/include/libxml/valid.h
@@ -10,7 +10,7 @@
 #ifndef __XML_VALID_H__
 #define __XML_VALID_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/libxml/xlink.h b/include/libxml/xlink.h
index 0bcceeb..68a35fe 100644
--- a/include/libxml/xlink.h
+++ b/include/libxml/xlink.h
@@ -13,7 +13,7 @@
 #ifndef __XML_XLINK_H__
 #define __XML_XLINK_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 #define extern "C" {
diff --git a/include/libxml/xmlIO.h b/include/libxml/xmlIO.h
index 565c21c..4d63b82 100644
--- a/include/libxml/xmlIO.h
+++ b/include/libxml/xmlIO.h
@@ -10,9 +10,9 @@
 #define __XML_IO_H__
 
 #include <stdio.h>
-#include "tree.h"
-#include "parser.h"
-#include "encoding.h"
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/encoding.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/libxml/xmlmemory.h b/include/libxml/xmlmemory.h
index 43a92b0..0237820 100644
--- a/include/libxml/xmlmemory.h
+++ b/include/libxml/xmlmemory.h
@@ -9,6 +9,7 @@
 #define _DEBUG_MEMORY_ALLOC_
 
 #include <stdio.h>
+#include <libxml/xmlversion.h>
 
 /*
  * DEBUG_MEMORY_LOCATION should be activated only done when debugging 
diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h
index c0222e6..73e3f65 100644
--- a/include/libxml/xpath.h
+++ b/include/libxml/xpath.h
@@ -12,7 +12,7 @@
 #ifndef __XML_XPATH_H__
 #define __XML_XPATH_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/libxml.spec.in b/libxml.spec.in
index fdd12c7..129eb72 100644
--- a/libxml.spec.in
+++ b/libxml.spec.in
@@ -92,7 +92,7 @@
 
 %doc AUTHORS ChangeLog NEWS README COPYING COPYING.LIB TODO
 %{prefix}/lib/lib*.so.*
-%{prefix}/bin/xml-config
+%{prefix}/bin/xmllint
 
 %files devel
 %defattr(-, root, root)
@@ -101,3 +101,4 @@
 %{prefix}/lib/*a
 %{prefix}/lib/*.sh
 %{prefix}/include/*
+%{prefix}/bin/xml-config
diff --git a/nanoftp.c b/nanoftp.c
index e4f4214..2f5a418 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -11,7 +11,9 @@
 #else
 #include "config.h"
 #endif
+#include "xmlversion.h"
 
+#ifdef LIBXML_FTP_ENABLED
 #include <stdio.h>
 #include <string.h>
 
@@ -60,8 +62,8 @@
 #include <strings.h>
 #endif
 
-#include "xmlmemory.h"
-#include "nanoftp.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/nanoftp.h>
 
 /* #define DEBUG_FTP 1  */
 #ifdef STANDALONE
@@ -1815,3 +1817,12 @@
     exit(0);
 }
 #endif /* STANDALONE */
+#else /* !LIBXML_FTP_ENABLED */
+#ifdef STANDALONE
+#include <stdio.h>
+int main(int argc, char **argv) {
+    printf("%s : FTP support not compiled in\n", argv[0]);
+    return(0);
+}
+#endif /* STANDALONE */
+#endif /* LIBXML_FTP_ENABLED */
diff --git a/nanoftp.h b/nanoftp.h
index 0a41b97..5346528 100644
--- a/nanoftp.h
+++ b/nanoftp.h
@@ -8,6 +8,10 @@
  
 #ifndef __NANO_FTP_H__
 #define __NANO_FTP_H__
+
+#include <libxml/xmlversion.h>
+#ifdef LIBXML_FTP_ENABLED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -101,5 +105,6 @@
 
 #ifdef __cplusplus
 }
+#endif /* LIBXML_FTP_ENABLED */
 #endif
 #endif /* __NANO_FTP_H__ */
diff --git a/nanohttp.c b/nanohttp.c
index 438257b..7f5a153 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -21,7 +21,9 @@
 #include "config.h"
 #endif
 
+#include "xmlversion.h"
 
+#ifdef LIBXML_HTTP_ENABLED
 #include <stdio.h>
 #include <string.h>
 
@@ -59,8 +61,8 @@
 #include <strings.h>
 #endif
 
-#include "xmlmemory.h"
-#include "nanohttp.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/nanohttp.h>
 
 #ifdef STANDALONE
 #define DEBUG_HTTP
@@ -1231,3 +1233,12 @@
     return(0);
 }
 #endif /* STANDALONE */
+#else /* !LIBXML_HTTP_ENABLED */
+#ifdef STANDALONE
+#include <stdio.h>
+int main(int argc, char **argv) {
+    printf("%s : HTTP support not compiled in\n", argv[0]);
+    return(0);
+}
+#endif /* STANDALONE */
+#endif /* LIBXML_HTTP_ENABLED */
diff --git a/nanohttp.h b/nanohttp.h
index 7e0e2ce..49f7645 100644
--- a/nanohttp.h
+++ b/nanohttp.h
@@ -8,6 +8,10 @@
  
 #ifndef __NANO_HTTP_H__
 #define __NANO_HTTP_H__
+
+#include <libxml/xmlversion.h>
+#ifdef LIBXML_HTTP_ENABLED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -33,5 +37,7 @@
 void	xmlNanoHTTPClose	(void *ctx);
 #ifdef __cplusplus
 }
+
+#endif /* LIBXML_HTTP_ENABLED */
 #endif
 #endif /* __NANO_HTTP_H__ */
diff --git a/parser.c b/parser.c
index b43f530..80b779d 100644
--- a/parser.c
+++ b/parser.c
@@ -33,20 +33,20 @@
 #include <zlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "tree.h"
-#include "parser.h"
-#include "entities.h"
-#include "encoding.h"
-#include "valid.h"
-#include "parserInternals.h"
-#include "xmlIO.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/entities.h>
+#include <libxml/encoding.h>
+#include <libxml/valid.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xmlIO.h>
 #include "xml-error.h"
 
 #define XML_PARSER_BIG_BUFFER_SIZE 1000
 #define XML_PARSER_BUFFER_SIZE 100
 
-const char *xmlParserVersion = LIBXML_VERSION;
+const char *xmlParserVersion = LIBXML_VERSION_STRING;
 int xmlGetWarningsDefaultValue = 1;
 
 /*
diff --git a/parser.h b/parser.h
index 54f00e6..d755b70 100644
--- a/parser.h
+++ b/parser.h
@@ -9,10 +9,10 @@
 #ifndef __XML_PARSER_H__
 #define __XML_PARSER_H__
 
-#include "tree.h"
-#include "valid.h"
-#include "xmlIO.h"
-#include "entities.h"
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/xmlIO.h>
+#include <libxml/entities.h>
 
 
 #ifdef __cplusplus
diff --git a/parserInternals.h b/parserInternals.h
index db7965a..b29f11c 100644
--- a/parserInternals.h
+++ b/parserInternals.h
@@ -9,7 +9,7 @@
 #ifndef __XML_PARSER_INTERNALS_H__
 #define __XML_PARSER_INTERNALS_H__
 
-#include "parser.h"
+#include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/testHTML.c b/testHTML.c
index 61fc95e..d5157f6 100644
--- a/testHTML.c
+++ b/testHTML.c
@@ -12,6 +12,9 @@
 #include "config.h"
 #endif
 
+#include "xmlversion.h"
+#ifdef LIBXML_HTML_ENABLED
+
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
@@ -33,12 +36,14 @@
 #include <stdlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "HTMLparser.h"
-#include "HTMLtree.h"
-#include "debugXML.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/debugXML.h>
 
+#ifdef LIBXML_DEBUG_ENABLED
 static int debug = 0;
+#endif
 static int copy = 0;
 static int sax = 0;
 static int repeat = 0;
@@ -632,10 +637,14 @@
      * print it.
      */
     if (!noout) { 
+#ifdef LIBXML_DEBUG_ENABLED
 	if (!debug)
 	    htmlDocDump(stdout, doc);
 	else
 	    xmlDebugDumpDocument(stdout, doc);
+#else
+	htmlDocDump(stdout, doc);
+#endif
     }	
 
     /*
@@ -649,9 +658,12 @@
     int files = 0;
 
     for (i = 1; i < argc ; i++) {
+#ifdef LIBXML_DEBUG_ENABLED
 	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
 	    debug++;
-	else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
+	else
+#endif
+	    if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
 	    copy++;
 	else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push")))
 	    push++;
@@ -685,7 +697,9 @@
 	printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
 	       argv[0]);
 	printf("\tParse the HTML files and output the result of the parsing\n");
+#ifdef LIBXML_DEBUG_ENABLED
 	printf("\t--debug : dump a debug tree of the in-memory document\n");
+#endif
 	printf("\t--copy : used to test the internal copy implementation\n");
 	printf("\t--sax : debug the sequence of SAX callbacks\n");
 	printf("\t--repeat : parse the file 100 times, for timing\n");
@@ -697,3 +711,10 @@
 
     return(0);
 }
+#else /* !LIBXML_HTML_ENABLED */
+#include <stdio.h>
+int main(int argc, char **argv) {
+    printf("%s : HTML support not compiled in\n", argv[0]);
+    return(0);
+}
+#endif
diff --git a/testSAX.c b/testSAX.c
index d7b0f12..d5079af 100644
--- a/testSAX.c
+++ b/testSAX.c
@@ -36,11 +36,11 @@
 #endif
 
 
-#include "parser.h"
-#include "parserInternals.h" /* only for xmlNewInputFromFile() */
-#include "tree.h"
-#include "debugXML.h"
-#include "xmlmemory.h"
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h> /* only for xmlNewInputFromFile() */
+#include <libxml/tree.h>
+#include <libxml/debugXML.h>
+#include <libxml/xmlmemory.h>
 
 static int debug = 0;
 static int copy = 0;
diff --git a/testXPath.c b/testXPath.c
index b9824f2..1559cef 100644
--- a/testXPath.c
+++ b/testXPath.c
@@ -12,6 +12,9 @@
 #include "config.h"
 #endif
 
+#include "xmlversion.h"
+#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
+
 #include <stdio.h>
 #include <string.h>
 
@@ -32,11 +35,11 @@
 #endif
 
 
-#include "xpath.h"
-#include "tree.h"
-#include "parser.h"
-#include "debugXML.h"
-#include "xmlmemory.h"
+#include <libxml/xpath.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/debugXML.h>
+#include <libxml/xmlmemory.h>
 
 static int debug = 0;
 static int expr = 0;
@@ -211,3 +214,10 @@
 
     return(0);
 }
+#else
+#include <stdio.h>
+int main(int argc, char **argv) {
+    printf("%s : XPath/Debug support not compiled in\n", argv[0]);
+    return(0);
+}
+#endif /* LIBXML_XPATH_ENABLED */
diff --git a/tree.c b/tree.c
index 0b98d2d..3e739f9 100644
--- a/tree.c
+++ b/tree.c
@@ -25,11 +25,11 @@
 #include <zlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "tree.h"
-#include "parser.h"
-#include "entities.h"
-#include "valid.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/entities.h>
+#include <libxml/valid.h>
 
 static xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 };
 static xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 };
@@ -4451,7 +4451,11 @@
     if (buf == NULL) return;
     if ((doc != NULL) && 
         (doc->type == XML_HTML_DOCUMENT_NODE)) {
+#ifdef LIBXML_HTML_ENABLED
         htmlNodeDump(buf, doc, cur);
+#else	
+	printf("HTML support not compiled in\n");
+#endif /* LIBXML_HTML_ENABLED */
     } else
         xmlNodeDump(buf, doc, cur, 0, 1);
     xmlBufferDump(f, buf);
diff --git a/tree.h b/tree.h
index c881728..a755962 100644
--- a/tree.h
+++ b/tree.h
@@ -11,6 +11,7 @@
 #define __XML_TREE_H__
 
 #include <stdio.h>
+#include <libxml/xmlversion.h>
 
 
 #ifdef __cplusplus
diff --git a/uri.c b/uri.c
index aebb97f..6bac167 100644
--- a/uri.c
+++ b/uri.c
@@ -18,8 +18,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "xmlmemory.h"
-#include "uri.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/uri.h>
 
 /**
  * alpha    = lowalpha | upalpha
@@ -159,30 +159,14 @@
 #define NEXT(p) ((*p == '%')? p += 3 : p++)
 
 /**
+ * Productions from the spec.
  *
-
- *
-      authority     = server | reg_name
-      server        = [ [ userinfo "@" ] hostport ]
-
+ *    authority     = server | reg_name
  *    reg_name      = 1*( unreserved | escaped | "$" | "," |
  *                        ";" | ":" | "@" | "&" | "=" | "+" )
-
- *    userinfo      = *( unreserved | escaped |
- *                       ";" | ":" | "&" | "=" | "+" | "$" | "," )
-
-      hostport      = host [ ":" port ]
-      host          = hostname | IPv4address
-      hostname      = *( domainlabel "." ) toplabel [ "." ]
-      domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
-      toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
-      IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
-      port          = *digit
-
-      path          = [ abs_path | opaque_part ]
-
-
-     */
+ *
+ * path          = [ abs_path | opaque_part ]
+ */
 
 /**
  * xmlCreateURI:
@@ -302,7 +286,90 @@
 	}
 	ret[len++] = 0;
     } else {
-	if (uri->authority != NULL) {
+	if (uri->server != NULL) {
+	    if (len + 3 >= max) {
+		max *= 2;
+		ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
+		if (ret == NULL) {
+		    fprintf(stderr, "xmlSaveUri: out of memory\n");
+		    return(NULL);
+		}
+	    }
+	    ret[len++] = '/';
+	    ret[len++] = '/';
+	    if (uri->user != NULL) {
+		p = uri->user;
+		while (*p != 0) {
+		    if (len + 3 >= max) {
+			max *= 2;
+			ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
+			if (ret == NULL) {
+			    fprintf(stderr, "xmlSaveUri: out of memory\n");
+			    return(NULL);
+			}
+		    }
+		    if ((IS_UNRESERVED(*(p))) ||
+			((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) ||
+			((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
+			((*(p) == ',')))
+			ret[len++] = *p++;
+		    else {
+			int val = *p++;
+			ret[len++] = '%';
+			switch (val / 0x10) {
+			    case 0xF: ret[len++] = 'F'; break;
+			    case 0xE: ret[len++] = 'E'; break;
+			    case 0xD: ret[len++] = 'D'; break;
+			    case 0xC: ret[len++] = 'C'; break;
+			    case 0xB: ret[len++] = 'B'; break;
+			    case 0xA: ret[len++] = 'A'; break;
+			    default: ret[len++] = '0' + (val / 0x10);
+			}
+			switch (val % 0x10) {
+			    case 0xF: ret[len++] = 'F'; break;
+			    case 0xE: ret[len++] = 'E'; break;
+			    case 0xD: ret[len++] = 'D'; break;
+			    case 0xC: ret[len++] = 'C'; break;
+			    case 0xB: ret[len++] = 'B'; break;
+			    case 0xA: ret[len++] = 'A'; break;
+			    default: ret[len++] = '0' + (val % 0x10);
+			}
+		    }
+		}
+		if (len + 3 >= max) {
+		    max *= 2;
+		    ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
+		    if (ret == NULL) {
+			fprintf(stderr, "xmlSaveUri: out of memory\n");
+			return(NULL);
+		    }
+		}
+		ret[len++] = '@';
+	    }
+	    p = uri->server;
+	    while (*p != 0) {
+		if (len >= max) {
+		    max *= 2;
+		    ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
+		    if (ret == NULL) {
+			fprintf(stderr, "xmlSaveUri: out of memory\n");
+			return(NULL);
+		    }
+		}
+		ret[len++] = *p++;
+	    }
+	    if (uri->port > 0) {
+		if (len + 10 >= max) {
+		    max *= 2;
+		    ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
+		    if (ret == NULL) {
+			fprintf(stderr, "xmlSaveUri: out of memory\n");
+			return(NULL);
+		    }
+		}
+		len += sprintf((char *) &ret[len], ":%d", uri->port);
+	    }
+	} else if (uri->authority != NULL) {
 	    if (len + 3 >= max) {
 		max *= 2;
 		ret = xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
@@ -529,6 +596,8 @@
     uri->scheme = NULL;
     if (uri->server != NULL) xmlFree(uri->server);
     uri->server = NULL;
+    if (uri->user != NULL) xmlFree(uri->user);
+    uri->user = NULL;
     if (uri->path != NULL) xmlFree(uri->path);
     uri->path = NULL;
     if (uri->fragment != NULL) xmlFree(uri->fragment);
@@ -553,6 +622,7 @@
 
     if (uri->scheme != NULL) xmlFree(uri->scheme);
     if (uri->server != NULL) xmlFree(uri->server);
+    if (uri->user != NULL) xmlFree(uri->user);
     if (uri->path != NULL) xmlFree(uri->path);
     if (uri->fragment != NULL) xmlFree(uri->fragment);
     if (uri->opaque != NULL) xmlFree(uri->opaque);
@@ -563,7 +633,7 @@
 }
 
 /**
- * xmlURIUnescape:
+ * xmlURIUnescapeString:
  * @str:  the string to unescape
  * @len:   the lenght in bytes to unescape (or <= 0 to indicate full string)
  * @target:  optionnal destination buffer
@@ -574,7 +644,7 @@
  * Returns an copy of the string, but unescaped
  */
 char *
-xmlURIUnescape(const char *str, int len, char *target) {
+xmlURIUnescapeString(const char *str, int len, char *target) {
     char *ret, *out;
     const char *in;
 
@@ -586,7 +656,7 @@
     if (target == NULL) {
 	ret = (char *) xmlMalloc(len + 1);
 	if (ret == NULL) {
-	    fprintf(stderr, "xmlURIUnescape: out of memory\n");
+	    fprintf(stderr, "xmlURIUnescapeString: out of memory\n");
 	    return(NULL);
 	}
     } else
@@ -643,7 +713,7 @@
     while (IS_URIC(cur)) NEXT(cur);
     if (uri != NULL) {
 	if (uri->fragment != NULL) xmlFree(uri->fragment);
-	uri->fragment = xmlURIUnescape(*str, cur - *str, NULL);
+	uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL);
     }
     *str = cur;
     return(0);
@@ -669,7 +739,7 @@
     while (IS_URIC(cur)) NEXT(cur);
     if (uri != NULL) {
 	if (uri->query != NULL) xmlFree(uri->query);
-	uri->query = xmlURIUnescape(*str, cur - *str, NULL);
+	uri->query = xmlURIUnescapeString(*str, cur - *str, NULL);
     }
     *str = cur;
     return(0);
@@ -700,7 +770,7 @@
     while (IS_SCHEME(*cur)) cur++;
     if (uri != NULL) {
 	if (uri->scheme != NULL) xmlFree(uri->scheme);
-	uri->scheme = xmlURIUnescape(*str, cur - *str, NULL); /* !!! strndup */
+	uri->scheme = xmlURIUnescapeString(*str, cur - *str, NULL); /* !!! strndup */
     }
     *str = cur;
     return(0);
@@ -732,13 +802,143 @@
     while (IS_URIC(cur)) NEXT(cur);
     if (uri != NULL) {
 	if (uri->opaque != NULL) xmlFree(uri->opaque);
-	uri->opaque = xmlURIUnescape(*str, cur - *str, NULL);
+	uri->opaque = xmlURIUnescapeString(*str, cur - *str, NULL);
     }
     *str = cur;
     return(0);
 }
 
 /**
+ * xmlParseURIServer:
+ * @uri:  pointer to an URI structure
+ * @str:  pointer to the string to analyze
+ *
+ * Parse a server subpart of an URI, it's a finer grain analysis
+ * of the authority part.
+ * 
+ * server        = [ [ userinfo "@" ] hostport ]
+ * userinfo      = *( unreserved | escaped |
+ *                       ";" | ":" | "&" | "=" | "+" | "$" | "," )
+ * hostport      = host [ ":" port ]
+ * host          = hostname | IPv4address
+ * hostname      = *( domainlabel "." ) toplabel [ "." ]
+ * domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
+ * toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
+ * IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
+ * port          = *digit
+ *
+ * Returns 0 or the error code
+ */
+int
+xmlParseURIServer(xmlURIPtr uri, const char **str) {
+    const char *cur;
+    const char *host, *tmp;
+
+    if (str == NULL)
+	return(-1);
+    
+    cur = *str;
+
+    /*
+     * is there an userinfo ?
+     */
+    while (IS_USERINFO(cur)) NEXT(cur);
+    if (*cur == '@') {
+	if (uri != NULL) {
+	    if (uri->user != NULL) xmlFree(uri->user);
+	    uri->user = xmlURIUnescapeString(*str, cur - *str, NULL);
+	}
+	cur++;
+    } else {
+	if (uri != NULL) {
+	    if (uri->user != NULL) xmlFree(uri->user);
+	    uri->user = NULL;
+	}
+        cur = *str;
+    }
+    /*
+     * host part of hostport can derive either an IPV4 address
+     * or an unresolved name. Check the IP first, it easier to detect
+     * errors if wrong one
+     */
+    host = cur;
+    if (IS_DIGIT(*cur)) {
+        while(IS_DIGIT(*cur)) cur++;
+	if (*cur != '.')
+	    goto host_name;
+	cur++;
+	if (!IS_DIGIT(*cur))
+	    goto host_name;
+        while(IS_DIGIT(*cur)) cur++;
+	if (*cur != '.')
+	    goto host_name;
+	cur++;
+	if (!IS_DIGIT(*cur))
+	    goto host_name;
+        while(IS_DIGIT(*cur)) cur++;
+	if (*cur != '.')
+	    goto host_name;
+	cur++;
+	if (!IS_DIGIT(*cur))
+	    goto host_name;
+        while(IS_DIGIT(*cur)) cur++;
+	if (uri != NULL) {
+	    if (uri->authority != NULL) xmlFree(uri->authority);
+	    uri->authority = NULL;
+	    if (uri->server != NULL) xmlFree(uri->server);
+	    uri->server = xmlURIUnescapeString(host, cur - host, NULL);
+	}
+	goto host_done;
+    }
+host_name:
+    /*
+     * the hostname production as-is is a parser nightmare.
+     * simplify it to 
+     * hostname = *( domainlabel "." ) domainlabel [ "." ]
+     * and just make sure the last label starts with a non numeric char.
+     */
+    if (!IS_ALPHANUM(*cur))
+        return(6);
+    while (IS_ALPHANUM(*cur)) {
+        while ((IS_ALPHANUM(*cur)) || (*cur == '-')) cur++;
+	if (*cur == '.')
+	    cur++;
+    }
+    tmp = cur;
+    tmp--;
+    while (IS_ALPHANUM(*tmp) && (*tmp != '.') && (tmp >= host)) tmp--;
+    tmp++;
+    if (!IS_ALPHA(*tmp))
+        return(7);
+    if (uri != NULL) {
+	if (uri->authority != NULL) xmlFree(uri->authority);
+	uri->authority = NULL;
+	if (uri->server != NULL) xmlFree(uri->server);
+	uri->server = xmlURIUnescapeString(host, cur - host, NULL);
+    }
+
+host_done:
+
+    /*
+     * finish by checking for a port presence.
+     */
+    if (*cur == ':') {
+        cur++;
+	if (IS_DIGIT(*cur)) {
+	    if (uri != NULL)
+	        uri->port = 0;
+	    while (IS_DIGIT(*cur)) {
+	        if (uri != NULL)
+		    uri->port = uri->port * 10 + (*cur - '0');
+		cur++;
+	    }
+	}
+    }
+    *str = cur;
+    return(0);
+}	
+
+/**
  * xmlParseURIRelSegment:
  * @uri:  pointer to an URI structure
  * @str:  pointer to the string to analyze
@@ -765,7 +965,7 @@
     while (IS_SEGMENT(cur)) NEXT(cur);
     if (uri != NULL) {
 	if (uri->path != NULL) xmlFree(uri->path);
-	uri->path = xmlURIUnescape(*str, cur - *str, NULL);
+	uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
     }
     *str = cur;
     return(0);
@@ -830,7 +1030,7 @@
 	    path[len2] = '/';
 	    len2++;
 	}
-	xmlURIUnescape(*str, cur - *str, &path[len2]);
+	xmlURIUnescapeString(*str, cur - *str, &path[len2]);
 	if (uri->path != NULL)
 	    xmlFree(uri->path);
 	uri->path = path;
@@ -865,21 +1065,35 @@
 int
 xmlParseURIAuthority(xmlURIPtr uri, const char **str) {
     const char *cur;
+    int ret;
 
     if (str == NULL)
 	return(-1);
     
     cur = *str;
+
+    /*
+     * try first to parse it as a server string.
+     */
+    ret = xmlParseURIServer(uri, str);
+    if (ret == 0)
+        return(0);
+
+    /*
+     * failed, fallback to reg_name
+     */
     if (!IS_REG_NAME(cur)) {
 	return(5);
     }
     NEXT(cur);
     while (IS_REG_NAME(cur)) NEXT(cur);
     if (uri != NULL) {
+	if (uri->server != NULL) xmlFree(uri->server);
+	uri->server = NULL;
+	if (uri->user != NULL) xmlFree(uri->user);
+	uri->user = NULL;
 	if (uri->authority != NULL) xmlFree(uri->authority);
-	uri->authority = xmlURIUnescape(*str, cur - *str, NULL);
-
-	/* @@ Parse the authority to try to extract server infos !!! */
+	uri->authority = xmlURIUnescapeString(*str, cur - *str, NULL);
     }
     *str = cur;
     return(0);
@@ -1252,7 +1466,8 @@
     if (res == NULL)
 	goto done;
     if ((ref->scheme == NULL) && (ref->path == NULL) &&
-	(ref->authority == NULL) && (ref->query == NULL)) {
+	((ref->authority == NULL) && (ref->server == NULL)) &&
+	(ref->query == NULL)) {
 	if (ref->fragment == NULL)
 	    goto done;
         res->fragment = xmlMemStrdup(ref->fragment);
@@ -1279,8 +1494,15 @@
      *    component, which will also be undefined if the URI scheme does not
      *    use an authority component.
      */
-    if (ref->authority != NULL) {
-	res->authority = xmlMemStrdup(ref->authority);
+    if ((ref->authority != NULL) || (ref->server != NULL)) {
+	if (ref->authority != NULL)
+	    res->authority = xmlMemStrdup(ref->authority);
+	else {
+	    res->server = xmlMemStrdup(ref->server);
+	    if (ref->user != NULL)
+		res->user = xmlMemStrdup(ref->user);
+            res->port = ref->port;		
+	}
 	if (ref->path != NULL)
 	    res->path = xmlMemStrdup(ref->path);
 	if (ref->query != NULL)
@@ -1291,6 +1513,12 @@
     }
     if (bas->authority != NULL)
 	res->authority = xmlMemStrdup(bas->authority);
+    else if (bas->server != NULL) {
+	res->server = xmlMemStrdup(bas->server);
+	if (bas->user != NULL)
+	    res->user = xmlMemStrdup(bas->user);
+	res->port = bas->port;		
+    }
 
     /*
      * 5) If the path component begins with a slash character ("/"), then
@@ -1386,75 +1614,3 @@
 }
 
 
-#ifdef STANDALONE
-int main(int argc, char **argv) {
-    int i, ret, arg = 1;
-    xmlURIPtr uri;
-    const char *base = NULL;
-    xmlChar *composite;
-
-    if ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base"))) {
-	arg++;
-	base = argv[arg];
-	if (base != NULL)
-	    arg++;
-    }
-    uri = xmlCreateURI();
-    if (argv[arg] == NULL) {
-	char str[1024];
-
-        while (1) {
-	    /*
-	     * read one line in string buffer.
-	     */
-	    if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL)
-	       break;
-
-	    /*
-	     * remove the ending spaces
-	     */
-	    i = strlen(str);
-	    while ((i > 0) &&
-		   ((str[i - 1] == '\n') || (str[i - 1] == '\r') ||
-		    (str[i - 1] == ' ') || (str[i - 1] == '\t'))) {
-		i--;
-		str[i] = 0;
-	    }
-	    if (i <= 0)
-		continue;
-
-	    ret = xmlParseURIReference(uri, str);
-	    if (ret != 0)
-		printf("%s : error %d\n", str, ret);
-	    else {
-		xmlPrintURI(stdout, uri);
-		printf("\n");
-	    }
-
-        }
-    } else {
-	while (argv[arg] != NULL) {
-	    if (base == NULL) {
-		ret = xmlParseURIReference(uri, argv[arg]);
-		if (ret != 0)
-		    printf("%s : error %d\n", argv[arg], ret);
-		else {
-		    xmlPrintURI(stdout, uri);
-		    printf("\n");
-		}
-	    } else {
-		composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base);
-		if (base == NULL) {
-		} else {
-		    printf("%s\n", composite);
-		    xmlFree(composite);
-		}
-	    }
-	    arg++;
-	}
-    }
-    xmlFreeURI(uri);
-    xmlMemoryDump();
-    exit(0);
-}
-#endif
diff --git a/uri.h b/uri.h
index b8b3995..f54754a 100644
--- a/uri.h
+++ b/uri.h
@@ -11,7 +11,7 @@
 #ifndef __XML_URI_H__
 #define __XML_URI_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -24,10 +24,11 @@
 typedef xmlURI *xmlURIPtr;
 struct _xmlURI {
     char *scheme;
+    char *opaque;
     char *authority;
     char *server;
+    char *user;
     int port;
-    char *opaque;
     char *path;
     char *query;
     char *fragment;
@@ -42,7 +43,13 @@
 	                        	 const xmlChar *base);
 xmlURIPtr	xmlParseURI		(const char *URI);
 xmlChar *	xmlSaveUri		(xmlURIPtr uri);
+void		xmlPrintURI		(FILE *stream,
+					 xmlURIPtr uri);
+char *		xmlURIUnescapeString	(const char *str,
+					 int len,
+					 char *target);
 int		xmlNormalizeURIPath	(char *path);
+void		xmlFreeURI		(xmlURIPtr uri);
 
 #ifdef __cplusplus
 }
diff --git a/valid.c b/valid.c
index 398fee1..bc66ac5 100644
--- a/valid.c
+++ b/valid.c
@@ -20,10 +20,10 @@
 #include <stdlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "valid.h"
-#include "parser.h"
-#include "parserInternals.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/valid.h>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
 
 /*
  * Generic function for accessing stacks in the Validity Context
diff --git a/valid.h b/valid.h
index d211207..ef65907 100644
--- a/valid.h
+++ b/valid.h
@@ -10,7 +10,7 @@
 #ifndef __XML_VALID_H__
 #define __XML_VALID_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/xlink.c b/xlink.c
index 4bd10aa..1467343 100644
--- a/xlink.c
+++ b/xlink.c
@@ -35,11 +35,11 @@
 #include <zlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "tree.h"
-#include "parser.h"
-#include "valid.h"
-#include "xlink.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/valid.h>
+#include <libxml/xlink.h>
 
 #define XLINK_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xlink/namespace/")
 #define XHTML_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xhtml/")
diff --git a/xlink.h b/xlink.h
index 0bcceeb..68a35fe 100644
--- a/xlink.h
+++ b/xlink.h
@@ -13,7 +13,7 @@
 #ifndef __XML_XLINK_H__
 #define __XML_XLINK_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 #define extern "C" {
diff --git a/xml-error.h b/xml-error.h
index 709dfa2..34f4e66 100644
--- a/xml-error.h
+++ b/xml-error.h
@@ -1,7 +1,7 @@
 #ifndef __XML_ERROR_H__
 #define __XML_ERROR_H__
 
-#include "parser.h"
+#include <libxml/parser.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/xmlIO.c b/xmlIO.c
index 65db3fe..9c66d9f 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -34,12 +34,12 @@
 #include <zlib.h>
 #endif
 
-#include "xmlmemory.h"
-#include "parser.h"
-#include "parserInternals.h"
-#include "xmlIO.h"
-#include "nanohttp.h"
-#include "nanoftp.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xmlIO.h>
+#include <libxml/nanohttp.h>
+#include <libxml/nanoftp.h>
 
 /* #define DEBUG_INPUT */
 /* #define VERBOSE_FAILURE */
@@ -99,10 +99,14 @@
     if (in->gzfile != NULL)
         gzclose(in->gzfile);
 #endif
+#ifdef LIBXML_HTTP_ENABLED    
     if (in->httpIO != NULL)
         xmlNanoHTTPClose(in->httpIO);
+#endif    
+#ifdef LIBXML_FTP_ENABLED    
     if (in->ftpIO != NULL)
         xmlNanoFTPClose(in->ftpIO);
+#endif    
     if (in->fd >= 0)
         close(in->fd);
     memset(in, 0xbe, (size_t) sizeof(xmlParserInputBuffer));
@@ -135,6 +139,7 @@
 
     if (filename == NULL) return(NULL);
 
+#ifdef LIBXML_HTTP_ENABLED
     if (!strncmp(filename, "http://", 7)) {
         httpIO = xmlNanoHTTPOpen(filename, NULL);
         if (httpIO == NULL) {
@@ -144,7 +149,10 @@
 #endif
             return(NULL);
 	}
-    } else if (!strncmp(filename, "ftp://", 6)) {
+    } else
+#endif /* LIBXML_HTTP_ENABLED */
+#ifdef LIBXML_FTP_ENABLED
+	if (!strncmp(filename, "ftp://", 6)) {
         ftpIO = xmlNanoFTPOpen(filename);
         if (ftpIO == NULL) {
 #ifdef VERBOSE_FAILURE
@@ -153,7 +161,9 @@
 #endif
             return(NULL);
 	}
-    } else if (!strcmp(filename, "-")) {
+    } else
+#endif	/* LIBXML_FTP_ENABLED */
+	if (!strcmp(filename, "-")) {
 #ifdef HAVE_ZLIB_H
         input = gzdopen (fileno(stdin), "r");
         if (input == NULL) {
@@ -362,11 +372,17 @@
         fprintf(stderr, "xmlParserInputBufferGrow : out of memory !\n");
 	return(-1);
     }
+#ifdef LIBXML_HTTP_ENABLED
     if (in->httpIO != NULL) {
         res = xmlNanoHTTPRead(in->httpIO, &buffer[0], len);
-    } else if (in->ftpIO != NULL) {
+    } else
+#endif
+#ifdef LIBXML_FTP_ENABLED
+	if (in->ftpIO != NULL) {
         res = xmlNanoFTPRead(in->ftpIO, &buffer[0], len);
-    } else if (in->file != NULL) {
+    } else
+#endif
+	if (in->file != NULL) {
 	res = fread(&buffer[0], 1, len, in->file);
 #ifdef HAVE_ZLIB_H
     } else if (in->gzfile != NULL) {
diff --git a/xmlIO.h b/xmlIO.h
index 565c21c..4d63b82 100644
--- a/xmlIO.h
+++ b/xmlIO.h
@@ -10,9 +10,9 @@
 #define __XML_IO_H__
 
 #include <stdio.h>
-#include "tree.h"
-#include "parser.h"
-#include "encoding.h"
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/encoding.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/xmlmemory.c b/xmlmemory.c
index 24bb97a..3cadd9e 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -30,7 +30,7 @@
 #endif
 
 
-#include "xmlmemory.h"
+#include <libxml/xmlmemory.h>
 
 #ifdef xmlMalloc
 #undef xmlMalloc
diff --git a/xmlmemory.h b/xmlmemory.h
index 43a92b0..0237820 100644
--- a/xmlmemory.h
+++ b/xmlmemory.h
@@ -9,6 +9,7 @@
 #define _DEBUG_MEMORY_ALLOC_
 
 #include <stdio.h>
+#include <libxml/xmlversion.h>
 
 /*
  * DEBUG_MEMORY_LOCATION should be activated only done when debugging 
diff --git a/xpath.c b/xpath.c
index 398972f..c370077 100644
--- a/xpath.c
+++ b/xpath.c
@@ -19,6 +19,9 @@
 #include "config.h"
 #endif
 
+#include "xmlversion.h"
+#ifdef LIBXML_XPATH_ENABLED
+
 #include <stdio.h>
 #include <string.h>
 
@@ -41,11 +44,11 @@
 #include <ctype.h>
 #endif
 
-#include "xmlmemory.h"
-#include "tree.h"
-#include "valid.h"
-#include "xpath.h"
-#include "parserInternals.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/xpath.h>
+#include <libxml/parserInternals.h>
 
 /* #define DEBUG */
 /* #define DEBUG_STEP */
@@ -4579,3 +4582,4 @@
     return(res);
 }
 
+#endif /* LIBXML_XPATH_ENABLED */
diff --git a/xpath.h b/xpath.h
index c0222e6..73e3f65 100644
--- a/xpath.h
+++ b/xpath.h
@@ -12,7 +12,7 @@
 #ifndef __XML_XPATH_H__
 #define __XML_XPATH_H__
 
-#include "tree.h"
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {