Re: [xslt] document() can't open files with spaces in filename
- From: Daniel Veillard <veillard redhat com>
- To: xslt gnome org
- Subject: Re: [xslt] document() can't open files with spaces in filename
- Date: Sun, 8 Jul 2001 14:34:18 -0400
On Sun, Jul 08, 2001 at 06:05:51PM +0200, Bernhard Zwischenbrugger wrote:
> The thing I want to do, is to make one document
> from parts of this 500 Files (this will be the site navigation).
Oh, I had forgotten this problem.
> Do you think that the problem with libxml I/O
> will be fixed in near future (one month would be ok)?
> Or is the better way to rename all this Files and
> make %20 instead of spaces?
No as pointed the right way to proceed is to make the references
proper URI-References and fix libxml to handle those.
Well I have made a patch to the I/O layer so that it unescape
the URI given before trying to generate an input from it, the patch
is enclosed.
Once applied the test passes which the change that the reference
in test.xml is properly unescaped as "doc%20file.xml":
orchis:~/XSLT/tests/documents -> xsltproc test.xsl test.xml
It work's
It work's
orchis:~/XSLT/tests/documents ->
I think that's the most sensible way to process. If needed there is
an URI escaping routine in the libxml toolbox:
http://xmlsoft.org/html/libxml-uri.html#XMLURIESCAPESTR
Daniel
--
Daniel Veillard | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Sep 17-18 2001 Brussels Red Hat TechWorld http://www.redhat-techworld.com
Index: xmlIO.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlIO.c,v
retrieving revision 1.48
diff -c -r1.48 xmlIO.c
*** xmlIO.c 2001/07/04 22:54:28 1.48
--- xmlIO.c 2001/07/08 18:20:26
***************
*** 62,67 ****
--- 62,68 ----
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlIO.h>
+ #include <libxml/uri.h>
#include <libxml/nanohttp.h>
#include <libxml/nanoftp.h>
#include <libxml/xmlerror.h>
***************
*** 883,890 ****
#endif
(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret;
! int i;
void *context = NULL;
if (xmlInputCallbackInitialized == 0)
xmlRegisterDefaultInputCallbacks();
--- 884,892 ----
#endif
(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret;
! int i = 0;
void *context = NULL;
+ char *unescaped;
if (xmlInputCallbackInitialized == 0)
xmlRegisterDefaultInputCallbacks();
***************
*** 894,906 ****
/*
* Try to find one of the input accept method accepting taht scheme
* Go in reverse to give precedence to user defined handlers.
*/
! for (i = xmlInputCallbackNr - 1;i >= 0;i--) {
! if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
! (xmlInputCallbackTable[i].matchcallback(URI) != 0)) {
! context = xmlInputCallbackTable[i].opencallback(URI);
! if (context != NULL)
! break;
}
}
if (context == NULL) {
--- 896,928 ----
/*
* Try to find one of the input accept method accepting taht scheme
* Go in reverse to give precedence to user defined handlers.
+ * try with an unescaped version of the URI
*/
! unescaped = xmlURIUnescapeString(URI, 0, NULL);
! if (unescaped != NULL) {
! for (i = xmlInputCallbackNr - 1;i >= 0;i--) {
! if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
! (xmlInputCallbackTable[i].matchcallback(unescaped) != 0)) {
! context = xmlInputCallbackTable[i].opencallback(unescaped);
! if (context != NULL)
! break;
! }
! }
! xmlFree(unescaped);
! }
!
! /*
! * If this failed try with a non-escaped URI this may be a strange
! * filename
! */
! if (context == NULL) {
! for (i = xmlInputCallbackNr - 1;i >= 0;i--) {
! if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
! (xmlInputCallbackTable[i].matchcallback(URI) != 0)) {
! context = xmlInputCallbackTable[i].opencallback(URI);
! if (context != NULL)
! break;
! }
}
}
if (context == NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]