diff --git a/ChangeLog b/ChangeLog index ade40f77..4caf31ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 25 23:03:23 CEST 2003 Daniel Veillard + + * 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 * configure.in: preparing a beta3 solving the ABI problems diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 0d5779eb..326d2ff3 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -5746,6 +5746,7 @@ actually an xmlCharEncoding'/> + @@ -5754,6 +5755,7 @@ actually an xmlCharEncoding'/> + @@ -5772,6 +5774,7 @@ actually an xmlCharEncoding'/> + @@ -5781,6 +5784,7 @@ actually an xmlCharEncoding'/> + @@ -6554,9 +6558,9 @@ actually an xmlCharEncoding'/> Find the userdata specified by the QNames tuple - + - + @@ -8402,6 +8406,7 @@ actually an xmlCharEncoding'/> parse an XML in-memory document and build a tree. + @@ -8409,6 +8414,7 @@ actually an xmlCharEncoding'/> parse an XML from a file descriptor and build a tree. + @@ -8425,6 +8431,7 @@ actually an xmlCharEncoding'/> + @@ -8433,6 +8440,7 @@ actually an xmlCharEncoding'/> + diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 965fbc47..e095babd 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -1055,30 +1055,35 @@ XMLPUBFUN int XMLCALL 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 @@ XMLPUBFUN xmlDocPtr XMLCALL 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 @@ XMLPUBFUN xmlDocPtr XMLCALL xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, + const char *URL, const char *encoding, int options); diff --git a/parser.c b/parser.c index 6ebe1e58..2472f545 100644 --- a/parser.c +++ b/parser.c @@ -12102,6 +12102,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options) /** * 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 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options) * 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 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse) 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 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse) /** * 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 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse) * 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 @@ xmlReadDoc(const xmlChar * cur, const char *encoding, int options) 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 @@ xmlReadFile(const char *filename, const char *encoding, int options) 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 @@ xmlReadFile(const char *filename, const char *encoding, int options) * 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 @@ xmlReadMemory(const char *buffer, int size, const char *encoding, int options) * 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 @@ xmlReadFd(int fd, const char *encoding, int options) return (NULL); } inputPush(ctxt, stream); - return (xmlDoRead(ctxt, encoding, options, 0)); + return (xmlDoRead(ctxt, URL, encoding, options, 0)); } /** @@ -12261,6 +12269,7 @@ xmlReadFd(int fd, const char *encoding, int options) * @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 @@ xmlReadFd(int fd, const char *encoding, int options) */ 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 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, 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 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, */ 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 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur, return (NULL); } inputPush(ctxt, stream); - return (xmlDoRead(ctxt, encoding, options, 1)); + return (xmlDoRead(ctxt, URL, encoding, options, 1)); } /** @@ -12361,7 +12371,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename, return (NULL); } inputPush(ctxt, stream); - return (xmlDoRead(ctxt, encoding, options, 1)); + return (xmlDoRead(ctxt, NULL, encoding, options, 1)); } /** @@ -12369,6 +12379,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename, * @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 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename, */ 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 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, } 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 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, * 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 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding, return (NULL); } inputPush(ctxt, stream); - return (xmlDoRead(ctxt, encoding, options, 1)); + return (xmlDoRead(ctxt, URL, encoding, options, 1)); } /** @@ -12451,6 +12463,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding, * @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 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding, xmlDocPtr xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, + const char *URL, const char *encoding, int options) { xmlParserInputBufferPtr input; @@ -12484,5 +12498,5 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, 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 7710eb05..247ffdff 100644 --- a/win32/libxml2.def.src +++ b/win32/libxml2.def.src @@ -673,6 +673,7 @@ xmlDictFree xmlDictLookup xmlDictOwns xmlDictQLookup +xmlDictReference xmlDictSize xmlDocCopyNode xmlDocDump diff --git a/xmllint.c b/xmllint.c index bdc198c4..bd835d12 100644 --- a/xmllint.c +++ b/xmllint.c @@ -806,7 +806,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { } } 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 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { 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 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { 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