Changed the new xmlRead/xmlCtxtRead APIs to have an extra base URL

* parser.c xmllint.c doc/libxml2-api.xml include/libxml/parser.h:
  Changed the new xmlRead/xmlCtxtRead APIs to have an extra
  base URL parameter when not loading from a file or URL.
Daniel
diff --git a/ChangeLog b/ChangeLog
index ade40f7..4caf31e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Sep 25 23:03:23 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+	* parser.c xmllint.c doc/libxml2-api.xml include/libxml/parser.h:
+	  Changed the new xmlRead/xmlCtxtRead APIs to have an extra
+	  base URL parameter when not loading from a file or URL.
+
 Thu Sep 25 16:23:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
 
 	* configure.in: preparing a beta3 solving the ABI problems
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 0d5779e..326d2ff 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -5746,6 +5746,7 @@
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -5754,6 +5755,7 @@
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='fd' type='int' info='an open file descriptor'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -5772,6 +5774,7 @@
       <arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
       <arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
       <arg name='ioctx' type='void *' info='an I/O handler'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -5781,6 +5784,7 @@
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='buffer' type='const char *' info='a pointer to a char array'/>
       <arg name='size' type='int' info='the size of the array'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -6554,9 +6558,9 @@
       <info>Find the userdata specified by the QNames tuple</info>
       <return type='void *' info='the pointer to the userdata'/>
       <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='prefix' type='const xmlChar *' info='the second prefix of the userdata'/>
+      <arg name='prefix' type='const xmlChar *' info='the prefix of the userdata'/>
       <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='prefix2' type='const xmlChar *' info=''/>
+      <arg name='prefix2' type='const xmlChar *' info='the second prefix of the userdata'/>
       <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
     </function>
     <function name='xmlHashQLookup3' file='hash'>
@@ -8402,6 +8406,7 @@
       <info>parse an XML in-memory document and build a tree.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -8409,6 +8414,7 @@
       <info>parse an XML from a file descriptor and build a tree.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='fd' type='int' info='an open file descriptor'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -8425,6 +8431,7 @@
       <arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
       <arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
       <arg name='ioctx' type='void *' info='an I/O handler'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
@@ -8433,6 +8440,7 @@
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='buffer' type='const char *' info='a pointer to a char array'/>
       <arg name='size' type='int' info='the size of the array'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 965fbc4..e095bab 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1055,30 +1055,35 @@
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlReadDoc		(const xmlChar *cur,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
-		xmlReadFile		(const char *filename,
+		xmlReadFile		(const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlReadMemory		(const char *buffer,
 					 int size,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlReadFd		(int fd,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlReadIO		(xmlInputReadCallback ioread,
 					 xmlInputCloseCallback ioclose,
 					 void *ioctx,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlCtxtReadDoc		(xmlParserCtxtPtr ctxt,
 					 const xmlChar *cur,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
@@ -1090,11 +1095,13 @@
 		xmlCtxtReadMemory		(xmlParserCtxtPtr ctxt,
 					 const char *buffer,
 					 int size,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
 		xmlCtxtReadFd		(xmlParserCtxtPtr ctxt,
 					 int fd,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 XMLPUBFUN xmlDocPtr XMLCALL
@@ -1102,6 +1109,7 @@
 					 xmlInputReadCallback ioread,
 					 xmlInputCloseCallback ioclose,
 					 void *ioctx,
+					 const char *URL,
 					 const char *encoding,
 					 int options);
 
diff --git a/parser.c b/parser.c
index 6ebe1e5..2472f54 100644
--- a/parser.c
+++ b/parser.c
@@ -12102,6 +12102,7 @@
 /**
  * xmlDoRead:
  * @ctxt:  an XML parser context
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  * @reuse:  keep the context for reuse
@@ -12111,7 +12112,8 @@
  * Returns the resulting document tree or NULL
  */
 static xmlDocPtr
-xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
+xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
+          int options, int reuse)
 {
     xmlDocPtr ret;
     
@@ -12123,6 +12125,9 @@
 	if (hdlr != NULL)
 	    xmlSwitchToEncoding(ctxt, hdlr);
     }
+    if ((URL != NULL) && (ctxt->input != NULL) &&
+        (ctxt->input->filename == NULL))
+        ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL);
     xmlParseDocument(ctxt);
     if ((ctxt->wellFormed) || ctxt->recovery)
         ret = ctxt->myDoc;
@@ -12154,6 +12159,7 @@
 /**
  * xmlReadDoc:
  * @cur:  a pointer to a zero terminated string
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12162,7 +12168,7 @@
  * Returns the resulting document tree
  */
 xmlDocPtr
-xmlReadDoc(const xmlChar * cur, const char *encoding, int options)
+xmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int options)
 {
     xmlParserCtxtPtr ctxt;
 
@@ -12172,7 +12178,7 @@
     ctxt = xmlCreateDocParserCtxt(cur);
     if (ctxt == NULL)
         return (NULL);
-    return (xmlDoRead(ctxt, encoding, options, 0));
+    return (xmlDoRead(ctxt, URL, encoding, options, 0));
 }
 
 /**
@@ -12193,13 +12199,14 @@
     ctxt = xmlCreateFileParserCtxt(filename);
     if (ctxt == NULL)
         return (NULL);
-    return (xmlDoRead(ctxt, encoding, options, 0));
+    return (xmlDoRead(ctxt, NULL, encoding, options, 0));
 }
 
 /**
  * xmlReadMemory:
  * @buffer:  a pointer to a char array
  * @size:  the size of the array
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12208,19 +12215,20 @@
  * Returns the resulting document tree
  */
 xmlDocPtr
-xmlReadMemory(const char *buffer, int size, const char *encoding, int options)
+xmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options)
 {
     xmlParserCtxtPtr ctxt;
 
     ctxt = xmlCreateMemoryParserCtxt(buffer, size);
     if (ctxt == NULL)
         return (NULL);
-    return (xmlDoRead(ctxt, encoding, options, 0));
+    return (xmlDoRead(ctxt, URL, encoding, options, 0));
 }
 
 /**
  * xmlReadFd:
  * @fd:  an open file descriptor
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12229,7 +12237,7 @@
  * Returns the resulting document tree
  */
 xmlDocPtr
-xmlReadFd(int fd, const char *encoding, int options)
+xmlReadFd(int fd, const char *URL, const char *encoding, int options)
 {
     xmlParserCtxtPtr ctxt;
     xmlParserInputBufferPtr input;
@@ -12253,7 +12261,7 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 0));
+    return (xmlDoRead(ctxt, URL, encoding, options, 0));
 }
 
 /**
@@ -12261,6 +12269,7 @@
  * @ioread:  an I/O read function
  * @ioclose:  an I/O close function
  * @ioctx:  an I/O handler
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12270,7 +12279,7 @@
  */
 xmlDocPtr
 xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
-          void *ioctx, const char *encoding, int options)
+          void *ioctx, const char *URL, const char *encoding, int options)
 {
     xmlParserCtxtPtr ctxt;
     xmlParserInputBufferPtr input;
@@ -12295,13 +12304,14 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 0));
+    return (xmlDoRead(ctxt, URL, encoding, options, 0));
 }
 
 /**
  * xmlCtxtReadDoc:
  * @ctxt:  an XML parser context
  * @cur:  a pointer to a zero terminated string
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12312,7 +12322,7 @@
  */
 xmlDocPtr
 xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
-               const char *encoding, int options)
+               const char *URL, const char *encoding, int options)
 {
     xmlParserInputPtr stream;
 
@@ -12328,7 +12338,7 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 1));
+    return (xmlDoRead(ctxt, URL, encoding, options, 1));
 }
 
 /**
@@ -12361,7 +12371,7 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 1));
+    return (xmlDoRead(ctxt, NULL, encoding, options, 1));
 }
 
 /**
@@ -12369,6 +12379,7 @@
  * @ctxt:  an XML parser context
  * @buffer:  a pointer to a char array
  * @size:  the size of the array
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12379,7 +12390,7 @@
  */
 xmlDocPtr
 xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
-                  const char *encoding, int options)
+                  const char *URL, const char *encoding, int options)
 {
     xmlParserInputBufferPtr input;
     xmlParserInputPtr stream;
@@ -12403,13 +12414,14 @@
     }
 
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 1));
+    return (xmlDoRead(ctxt, URL, encoding, options, 1));
 }
 
 /**
  * xmlCtxtReadFd:
  * @ctxt:  an XML parser context
  * @fd:  an open file descriptor
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12419,8 +12431,8 @@
  * Returns the resulting document tree
  */
 xmlDocPtr
-xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding,
-              int options)
+xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
+              const char *URL, const char *encoding, int options)
 {
     xmlParserInputBufferPtr input;
     xmlParserInputPtr stream;
@@ -12442,7 +12454,7 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 1));
+    return (xmlDoRead(ctxt, URL, encoding, options, 1));
 }
 
 /**
@@ -12451,6 +12463,7 @@
  * @ioread:  an I/O read function
  * @ioclose:  an I/O close function
  * @ioctx:  an I/O handler
+ * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption(s)
  *
@@ -12462,6 +12475,7 @@
 xmlDocPtr
 xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
               xmlInputCloseCallback ioclose, void *ioctx,
+	      const char *URL,
               const char *encoding, int options)
 {
     xmlParserInputBufferPtr input;
@@ -12484,5 +12498,5 @@
         return (NULL);
     }
     inputPush(ctxt, stream);
-    return (xmlDoRead(ctxt, encoding, options, 1));
+    return (xmlDoRead(ctxt, URL, encoding, options, 1));
 }
diff --git a/win32/libxml2.def.src b/win32/libxml2.def.src
index 7710eb0..247ffdf 100644
--- a/win32/libxml2.def.src
+++ b/win32/libxml2.def.src
@@ -673,6 +673,7 @@
 xmlDictLookup
 xmlDictOwns
 xmlDictQLookup
+xmlDictReference
 xmlDictSize
 xmlDocCopyNode
 xmlDocDump
diff --git a/xmllint.c b/xmllint.c
index bdc198c..bd835d1 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -806,7 +806,7 @@
 	    }
 	} else if (testIO) {
 	    if ((filename[0] == '-') && (filename[1] == 0)) {
-	        doc = xmlReadFd(0, NULL, options);
+	        doc = xmlReadFd(0, NULL, NULL, options);
 	    } else {
 	        FILE *f;
 
@@ -815,12 +815,12 @@
 		    if (rectxt == NULL)
 			doc = xmlReadIO((xmlInputReadCallback) myRead,
 					(xmlInputCloseCallback) myClose, f,
-					NULL, options);
+					filename, NULL, options);
 		    else
 			doc = xmlCtxtReadIO(rectxt,
 			                (xmlInputReadCallback) myRead,
 					(xmlInputCloseCallback) myClose, f,
-					NULL, options);
+					filename, NULL, options);
 		} else
 		    doc = NULL;
 	    }
@@ -858,10 +858,11 @@
 	        return;
 
 	    if (rectxt == NULL)
-		doc = xmlReadMemory((char *) base, info.st_size, NULL, options);
+		doc = xmlReadMemory((char *) base, info.st_size,
+		                    filename, NULL, options);
 	    else
-		doc = xmlCtxtReadMemory(rectxt,
-			       (char *) base, info.st_size, NULL, options);
+		doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
+			                filename, NULL, options);
 	        
 	    munmap((char *) base, info.st_size);
 #endif