xinclude and pathnames

T

Tim Arnold

I'm using ElementTree to access some xml configuration files, and using the
module's xinclude capability. I've got lines like this in the parent xml
file (which lives in the same directory as the included xml file):
<xi:include href="/dept/app/doc/current/en/xml/asdf/asdf_syntaxterms.xml"/>

When I started the project it was Unix-only; this worked fine. Now I have
users who want to use the system on Windows and of course that directory
path doesn't exist on Windows, but it is available on the network using a
name like \\ladida\current\en\xml\asdf\asdf_syntaxterms.xml

if relative paths worked, I could imagine
<xi:include href="asdf_syntaxterms.xml" /> would work.
Also,the file can be read via an http server.

My question: is there a way to make xinclude work with relative paths or
perhaps urls?
Any ideas welcome--to me it looks like I'll have to restructure this part of
the system since I've basically programmed myself into a corner.

thanks,
--Tim Arnold
 
T

Tim Arnold

Tim Arnold said:
I'm using ElementTree to access some xml configuration files, and using
the module's xinclude capability. I've got lines like this in the parent
xml file (which lives in the same directory as the included xml file):
<xi:include
href="/dept/app/doc/current/en/xml/asdf/asdf_syntaxterms.xml"/>

When I started the project it was Unix-only; this worked fine. Now I have
users who want to use the system on Windows and of course that directory
path doesn't exist on Windows, but it is available on the network using a
name like \\ladida\current\en\xml\asdf\asdf_syntaxterms.xml

if relative paths worked, I could imagine
<xi:include href="asdf_syntaxterms.xml" /> would work.
Also,the file can be read via an http server.

My question: is there a way to make xinclude work with relative paths or
perhaps urls?
Any ideas welcome--to me it looks like I'll have to restructure this part
of the system since I've basically programmed myself into a corner.

Replying to my own post. With no replies I assume that means either (a) I
didn't explain the problem very well, or (b) I really have programmed myself
into a corner and there's no other way to happiness except to rethink the
problem.

That is, is there really no way to share xinclude'd files between *nix and
Windows platforms.

Anyone been down this road before?
thanks,
--Tim Arnold
 
R

Rob Williscroft

Tim Arnold wrote in in
comp.lang.python:

According to the docs: http://effbot.org/zone/element-xinclude.htm

The default handler just sees the href value as a filename, so you
should be able to use a relative path if you os.chdir() to the working
directory before processing you xml file.

I just ran a 3 line sample to make sure os.chdir() works with network
paths, which it did.

Rob.
 
F

Fredrik Lundh

Rob said:
The default handler just sees the href value as a filename, so you
should be able to use a relative path if you os.chdir() to the working
directory before processing you xml file.

and if that's not good enough, writing a custom loader is trivial (see
the default_loader implementation in ElementInclude.py for details).

</F>
 
T

Tim Arnold

Fredrik Lundh said:
and if that's not good enough, writing a custom loader is trivial (see the
default_loader implementation in ElementInclude.py for details).

</F>

Thanks for the information--I just tested Rob's idea, which works fine for
my case. You guys saved me a bunch of hair-pulling. I'm going to check out
the default_loader implementation too.

--Tim Arnold
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top