[XML-SIG] prepare_input_source and relative path
Sylvain.Thenault at logilab.fr
Fri Feb 11 09:46:31 CET 2005
On Thursday 10 February à 13:15, Mike Brown wrote:
> Sylvain Thénault wrote:
> > And I've also added the following modification to
> > prepare_input_source since I send it here:
> > @@ -510,7 +510,7 @@
> > source = xmlreader.InputSource()
> > source.setByteStream(f)
> > if hasattr(f, "name"):
> > - source.setSystemId(f.name)
> > + source.setSystemId('file:%s' % f.name)
> > if source.getByteStream() is None:
> > sysid = absolute_system_id(source.getSystemId(), base)
> > source.setSystemId(sysid)
> I'm not sure without seeing it in action, but this does not look
> right to me (the change, as well as its context). I need to look at
> what it's doing more closely.
> If you need to be lenient, be lenient with the base URI. When you
> prepend 'file:' to something, you're making it be absolute, which
> probably isn't what you wanted, and probably won't be ideal.
To be honest, I don't feel really good with this either. What I wished
to solve here is the case where prepare_input_source get a opened file
as argument, which is a really common case since it's happen each time
we do parser.parse(open('myfile.xml')). If the parsed file contains any
reference to external resource, it's system id will be used as base uri,
and that may be a problem if it's just as in the example 'myfile.xml'.
Maybe adding "file:" if exists(abspath(f.name)) would be a good
> > did you take a look at those tests ?
> Not yet, sorry. :) Busy.
ok. It's just that since this is a sensitive part of pyxml, I wished to
get some code review before to check anything in. Now I guess that other
people on this list may also have an opinion on this... ;)
Sylvain Thénault LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
More information about the XML-SIG