xinclude and pathnames

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Arnold

    #1

    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_syntaxterm s.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\curren t\en\xml\asdf\a sdf_syntaxterms .xml

    if relative paths worked, I could imagine
    <xi:include href="asdf_synt axterms.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


  • Tim Arnold

    #2
    Re: xinclude and pathnames

    "Tim Arnold" <tiarno@sas.com wrote in message
    news:ee9231$mpj $1@foggy.unx.sa s.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_syntaxterm s.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\curren t\en\xml\asdf\a sdf_syntaxterms .xml
    >
    if relative paths worked, I could imagine
    <xi:include href="asdf_synt axterms.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


    Comment

    • Rob Williscroft

      #3
      Re: xinclude and pathnames

      Tim Arnold wrote in news:eebkgl$u90 $1@foggy.unx.sa s.com in
      comp.lang.pytho n:
      "Tim Arnold" <tiarno@sas.com wrote in message
      news:ee9231$mpj $1@foggy.unx.sa s.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_syntaxterm s.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\curre nt\en\xml\asdf\ asdf_syntaxterm s.xml
      >>
      >if relative paths worked, I could imagine
      ><xi:include href="asdf_synt axterms.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.

      Comment

      • Fredrik Lundh

        #4
        Re: xinclude and pathnames

        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>

        Comment

        • Tim Arnold

          #5
          Re: xinclude and pathnames

          "Fredrik Lundh" <fredrik@python ware.comwrote in message
          news:mailman.99 .1158253686.104 91.python-list@python.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


          Comment

          Working...