473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

xinclude and pathnames

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
Sep 13 '06 #1
4 3367
"Tim Arnold" <ti****@sas.comwrote in message
news:ee**********@foggy.unx.sas.com...
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
Sep 14 '06 #2
Tim Arnold wrote in news:ee**********@foggy.unx.sas.com in
comp.lang.python:
"Tim Arnold" <ti****@sas.comwrote in message
news:ee**********@foggy.unx.sas.com...
>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.x ml

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.
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.
Sep 14 '06 #3
Rob Williscroft wrote:
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>

Sep 14 '06 #4
"Fredrik Lundh" <fr*****@pythonware.comwrote in message
news:ma*************************************@pytho n.org...
Rob Williscroft wrote:
>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>
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
Sep 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erdem Guven | last post by:
I try to include some xml documents to another one and validate them. I get 'invalid content starting with element "xi:include".' error message at pointsample.xml line 6 from xml plugin of jedit...
1
by: CB | last post by:
I am using xerces 2.5.0 and xalan 2.6.0, and am following the xinclude instructions on the xerces faq at http://xml.apache.org/xerces2-j/faq-xinclude.html, and I am having no luck. I imagine I...
3
by: rene | last post by:
Hello everybody, i have these 2 xml files ------1.xml------ <?xml version="1.0" encoding="UTF-8"?> <root> <element>1</element> <element>2</element> </root>
1
by: Larry | last post by:
Given the "includer" xml file: <?xml version="1.0"?> <test-includer xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:testns="http://www.w3.org/TR/REC-xml-names"...
9
by: Tjerk Wolterink | last post by:
I have an xml document that conforms to my xschema document. Now i wanted to use xinclude in my xml document. But when i want to validate the xml document to the xschema i get the following...
11
by: john fra | last post by:
Hi, I want to include a part of many XML files into an unique XML file with XInclude. Example! File1.xml, File2.xml, File3.xml... seems to that : <?xml version="1.0" encoding="UTF-8"?>
22
by: Sven-Thorsten Fahrbach | last post by:
Hi Does anybody know of a library that offers a function to split pathnames. It should work somewhat like the following code snippet: ----------------- char *path =...
7
by: shaun roe | last post by:
I should like to use xslt to produce a document like the following: <crate xmlns:xi="http://www.w3.org/2001/XInclude"> <rod id="0"> <slot>1</slot> <xi:include...
2
by: McSwell | last post by:
I have an XML file that looks something like this: ------------------------ <?xml ...?> <!DOCTYPE ...> <src:fragment id="foo" ...> <Ph:Itemsome stuff </Ph:Item> <Ph:Itemsome more stuff...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.