This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: resolving relative paths for external entities with xml.sax
Type: behavior Stage: test needed
Components: XML Versions: Python 2.3
process
Status: closed Resolution: out of date
Dependencies: 902037 Superseder:
Assigned To: Nosy List: BreamoreBoy, bartvh, crhode
Priority: normal Keywords:

Created on 2003-08-14 20:31 by bartvh, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (4)
msg60371 - (view) Author: Bart Vanhaute (bartvh) Date: 2003-08-14 20:31
[This is a copy of a message posted on comp.lang.python
for which I did not see any response. After some
reflection, I began to see it as a bug in python, so
here is the bug report.]

I have a set of XML documents that use external entity
definitions for which I am having problems parsing them
using python and xml.sax. The problem is with the
resolution of relative paths in these. 
An example:

dir1/test.xml:
	<?xml version="1.0"?>
	<!DOCTYPE test SYSTEM " ../dir2/test.dtd">
	<test>&ent;</test>

dir2/test.dtd:
	<!ENTITY ent SYSTEM "test.inc">
	<!ELEMENT test (#PCDATA)>

dir2/test.inc:
	external entity test

From what I understand of XML specs, relative paths in
external entities are relative to the location of the
document *in which they are defined*. However, using
xml.sax (which calls expat, I presume), the paths are
resolved relative to the current working directory. So
the parser can not find the test.inc when the current
working directory is e.g. dir1.

I do not see how creating an EntityResolver would help
here: how do I know against what base path I have to
resolve the entity? 

(the same thing can be read without problems with other
xml parser, for instance in Java).

Bart.
msg60372 - (view) Author: Chuck Rhode (crhode) Date: 2004-03-02 17:44
Logged In: YES 
user_id=988879

See also Bugs 902037 and 616431.  -ccr-
msg114256 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-18 17:42
I'll close in a couple of weeks unless someone has a good reason to keep it open.
msg115599 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-04 18:40
No reply to msg114256.
History
Date User Action Args
2022-04-10 16:10:39adminsetgithub: 39067
2010-09-04 18:40:56BreamoreBoysetstatus: pending -> closed
resolution: out of date
messages: + msg115599
2010-08-18 17:42:30BreamoreBoysetstatus: open -> pending
nosy: + BreamoreBoy
messages: + msg114256

2009-02-13 03:51:47ajaksu2setdependencies: + relative on-disk SYSTEM id handling is incorrect
type: behavior
stage: test needed
2003-08-14 20:31:54bartvhcreate