On Mon, Jun 25, 2001 at 05:45:59PM -0700, Alice Tull wrote:
Hi all,
I have a problem locating an external entity. My program is at directory
"A",
and both my xml file and my dtd are at directory "A/conf". I'm running
my program from directory "A".
I have a line like this to open an xml file to parse:
xmlParserCtxtPtr ctxt =
xmlCreateFileParserCtxt(".//conf/myconf.xml");
And in "myconf.xml", the reference to the dtd is:
<!DOCTYPE MyFile SYSTEM "../conf/MyFile.dtd" >
Instead of trying the uri ".//conf/../conf/MyFile.dtd", the parser tries
to load "/conf/MyFile.dtd".
hum, right, it's a bug !
orchis:~/tmp -> cat conf/myconf.xml
<!DOCTYPE MyFile SYSTEM "../conf/MyFile.dtd" >
<MyFile/>
orchis:~/tmp -> cat conf/MyFile.dtd
<!ELEMENT MyFile EMPTY>
orchis:~/tmp -> xmllint --noout --valid conf/myconf.xml
orchis:~/tmp -> xmllint --noout --valid ./conf/myconf.xml
orchis:~/tmp -> xmllint --noout --valid .//conf/myconf.xml
.//conf/myconf.xml:1: error: failed to load external entity "/conf/MyFile.dtd"
<!DOCTYPE MyFile SYSTEM "../conf/MyFile.dtd" >
^
.//conf/myconf.xml:2: validity error: Validation failed: no DTD found !
<MyFile/>
^
orchis:~/tmp ->
Poking around the source a bit shows that:
(1) base path = ".//conf", but because "./" is ignored, base path =
"/conf"
Seem the // should be reduced first, it's a bug in the URI normalization code, patch to fix it enclosed, it fixes another '//' normalization bug in this code,
Is this the correct behavior? Shouldn't the parser take care of extra "/" in the uri?
No and yes, thanks a lot for the report ! 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
Attachment:
normalize.patch
Description: Text document