patch based on Wieant Nielander contribution to add the option of not

* include/libxml/parser.h xinclude.c xmllint.c: patch based on
  Wieant Nielander contribution to add the option of not doing
  URI base fixup in XInclude
Daniel

svn path=/trunk/; revision=3775
diff --git a/ChangeLog b/ChangeLog
index aca911c..b3bcf55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Aug 26 09:25:39 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+	* include/libxml/parser.h xinclude.c xmllint.c: patch based on
+	  Wieant Nielander contribution to add the option of not doing
+	  URI base fixup in XInclude
+
 Mon Aug 25 16:52:53 CEST 2008 Daniel Veillard <daniel@veillard.com>
 
 	* xmlreader.c: applied patch from Aswin to fix tree skipping
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 29212e5..48d6f19 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1093,7 +1093,8 @@
     XML_PARSE_COMPACT   = 1<<16,/* compact small text nodes; no modification of
                                    the tree allowed afterwards (will possibly
 				   crash if you try to modify the tree) */
-    XML_PARSE_OLD10	= 1<<17 /* parse using XML-1.0 before update 5 */
+    XML_PARSE_OLD10	= 1<<17,/* parse using XML-1.0 before update 5 */
+    XML_PARSE_NOBASEFIX = 1<<18 /* do not fixup XINCLUDE xml:base uris */
 } xmlParserOption;
 
 XMLPUBFUN void XMLCALL
diff --git a/xinclude.c b/xinclude.c
index bb41180..ae449f8 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1678,7 +1678,9 @@
     /*
      * Do the xml:base fixup if needed
      */
-    if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/'))) {
+    if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/')) &&
+        (!(ctxt->parseFlags & XML_PARSE_NOBASEFIX)) &&
+	(!(doc->parseFlags & XML_PARSE_NOBASEFIX))) {
 	xmlNodePtr node;
 	xmlChar *base;
 	xmlChar *curBase;
diff --git a/xmllint.c b/xmllint.c
index cabf24b..3a30cc8 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2891,6 +2891,7 @@
 #ifdef LIBXML_XINCLUDE_ENABLED
     printf("\t--xinclude : do XInclude processing\n");
     printf("\t--noxincludenode : same but do not generate XInclude nodes\n");
+    printf("\t--nofixup-base-uris : do not fixup xml:base uris\n");
 #endif
     printf("\t--loaddtd : fetch external DTD\n");
     printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
@@ -3093,6 +3094,12 @@
 	    options |= XML_PARSE_XINCLUDE;
 	    options |= XML_PARSE_NOXINCNODE;
 	}
+	else if ((!strcmp(argv[i], "-nofixup-base-uris")) ||
+	         (!strcmp(argv[i], "--nofixup-base-uris"))) {
+	    xinclude++;
+	    options |= XML_PARSE_XINCLUDE;
+	    options |= XML_PARSE_NOBASEFIX;
+	}
 #endif
 #ifdef LIBXML_OUTPUT_ENABLED
 #ifdef HAVE_ZLIB_H