Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: resolving relative paths for external entities with xml.sax

Reply
Thread Tools

Re: resolving relative paths for external entities with xml.sax

 
 
Uche Ogbuji
Guest
Posts: n/a
 
      08-22-2003
Bart <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> On Fri, 15 Aug 2003 06:24:02 -0700, Uche Ogbuji wrote:
>
> >> 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, for one, need to see your Python code to tell, because if you're
> > using the APIs rightly parsing the first file as a URI rather than,
> > say, reading it in as a string first), then you should not have the
> > problem you report.

>
> something like:
> from xml.sax import make_parser
> from xml.sax.saxutils import XMLGenerator
> reader = make_parser()
> reader.setContentHandler(XMLGenerator())
> reader.parse('test.xml')
>
> this is run in the test1 dir.
>
> I also tried using absolute paths, xml.sax.InputSource, 'file:' URLs and
> combinations of these.
>
> The result is either:
> OSError: [Errno 2] No such file or directory: 'test.inc'
> or (when using 'file://tmp/xmltest/test1/test.xml'):
> OSError: [Errno 2] No such file or directory: '/tmp/xmltest/test1/test.inc'
> or (when using 'file:test.xml'):
> OSError: [Errno 2] No such file or directory: '/test.inc'


Ignore my last posting. Silly me: I threw out all the context.

This is a bug. I'll try to make time to look into it (I don't get to
pitch into PyXML enough these days).


> In the meantime, I found a discussion in bugzilla for python.xml about the
> prepare_input_source method in xml.sax.xmlutils (see
> http://sourceforge.net/tracker/index...73&atid=106473)
> but i am not sure it is really relevant.


It's certainly relevant, and I plan to make that a starting point.
Thanks.

--Uche
http://uche.ogbuji.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BUG: debugger is case-sensitive to paths when resolving assembly refrences PJ6 ASP .Net 0 09-21-2006 04:40 PM
asp.net application not resolving relative paths rjbr ASP .Net 2 07-12-2006 10:14 AM
resolving relative ~ paths Stephen Woolhead ASP .Net Building Controls 1 02-03-2005 03:28 AM
Stopping Xerces-j parser from resolving entities on its own Vineeth XML 1 10-09-2004 05:35 PM
HTML::Entities::encode() returning wrong(?) entities Jim Higson Perl Misc 3 07-25-2004 09:13 PM



Advertisments