GNOME Bugzilla – Bug 105994
URI are mismatch for identical documents
Last modified: 2009-08-15 18:40:50 UTC
String 765: Please, change ctxt->myDoc->URL = xmlStrdup((const xmlChar *) ctxt->input->filename); to ctxt->myDoc->URL = xmlStrdup(xmlSaveUri(xmlParseURI(ctxt->input- >filename))); , else in some cases identical documents would be parse several times in XSLT.
I suggest next code for 'xmlNormalizeWindowsPath' function. It is necessary for forming equal URL's for same documents. xmlChar * xmlNormalizeWindowsPath(const xmlChar *path) { int len, i = 0; xmlChar *ret; xmlURIPtr uri; if (path == NULL) return(NULL); if((uri = xmlParseURI(path)) != NULL) { xmlFreeURI(uri); return xmlStrdup(path); } uri = xmlCreateURI(); uri->path = xmlStrdup(path); len = xmlStrlen(uri->path); while (i < len) { if (uri->path[i] == '\\') uri->path[i] = '/'; i++; } ret = xmlSaveUri(uri); xmlFreeURI(uri); return(ret); }
I have partially fixed this. The first proposition about changing ctxt->myDoc->URL = ... leaks memory, so I changed it a little bit. The xmlNormalizeWindowsPath has been obsoleted and the new xmlCanonicPath now takes over its place. It works similarily to what you propose above, so I think your problem is solved. About the actual problem you mentioned, namely that identical documents are being parsed multiple times, that has not been solved with the above, and I doubt that can be solved in a short term. I'll therefore assign this report to pending, the problem needs a general analysis.
For the first change: Please check, that your change works!!! After this change I have a new bug - if filename is non-wellformed (for example spaces in path) it is not works. In other words filename must be parseable as URI. For this requirement I make changes in xmlNormalizeWindowsPath, it solve problems in my application, but it is not solve problem in library. I suppose, that solve of problem requires accurate separation between URL's and paths in whole library. This problem I see then I try preload big XML-document, which uses in several transformers. I load document using xmlParseFile() and place it in transformer using xsltNewDocument. And as result the doc->URL mismatchs with URL of document loaded by xsl:document() function durning transformation.
This should be closed in libxml2 release 2.5.4 and libxslt release 1.0.27, thanks, Daniel