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

Discussion in 'Python' started by Uche Ogbuji, Aug 22, 2003.

  1. Uche Ogbuji

    Uche Ogbuji Guest

    Bart <> wrote in message news:<>...
    > 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.php?func=detail&aid=616431&group_id=6473&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
    Uche Ogbuji, Aug 22, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vineeth
    Replies:
    1
    Views:
    586
    Frank Meyer
    Oct 9, 2004
  2. rjbr
    Replies:
    2
    Views:
    502
    =?Utf-8?B?QWxveXNpdXMgTWFyaWEgU2VsdmFt?=
    Jul 12, 2006
  3. PJ6
    Replies:
    0
    Views:
    346
  4. Stephen Woolhead

    resolving relative ~ paths

    Stephen Woolhead, Feb 3, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    106
    Stephen Woolhead
    Feb 3, 2005
  5. Jim Higson
    Replies:
    3
    Views:
    223
    Eric Amick
    Jul 25, 2004
Loading...

Share This Page