No subject


Thu May 19 09:45:02 EDT 2005


#! rnews 2056
Newsgroups: comp.lang.python
Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!fi.sn.net!newsfeed2.fi.sn.net!newsfeed3.funet.fi!newsfeed1.funet.fi!newsfeeds.funet.fi!newsfeed1.swip.net!swipnet!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp
From: Harry George <harry.g.george at boeing.com>
Subject: Re: ElementTree and xsi to xmlns conversion?
X-Nntp-Posting-Host: cola2.ca.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <xqxsm0jjql1.fsf at cola2.ca.boeing.com>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
Lines: 43
Sender: hgg9140 at cola2.ca.boeing.com
Organization: The Boeing Company
References: <d6gbo5$fm6$1 at vegh.ks.cc.utah.edu> <mailman.193.1116487191.8733.python-list at python.org>
Mime-Version: 1.0
Date: Thu, 19 May 2005 13:24:58 GMT
Xref: news.xs4all.nl comp.lang.python:378110

"Fredrik Lundh" <fredrik at pythonware.com> writes:

[snip]
> 
> are you sure?  the prefix shouldn't matter; it's the namespace URI that's important.
> if you're writing code that depends on the namespace prefix rather than the name-
> space URI, you're not using namespaces correctly.  when it comes to namespaces,
> elementtree forces you to do things the right way:
> 
>     http://www.jclark.com/xml/xmlns.htm
> 
> (unfortunately, the XML schema authors didn't understand namespaces so they
> messed things up:
>     http://www.w3.org/2001/tag/doc/qnameids-2002-04-30
> to work around this, see oren's message about how to control the namespace/prefix
> mapping.  in worst case, you can manually insert xsi:-attributes in the tree, and rely on
> the fact that the default writer only modifies universal names)
> 
> </F> 
> 
> 
> 

First, thanks for ElementTree and cElementTree.  Second, I've read the
docs and see a lot of examples for building trees, but not a lot for
traversing parsed trees.  Questions:

1. Is there a good idiom for namespaces?  I'm currently doing things like:

UML='{href://org.omg/UML/1.3}'
....
packages=ns2.findall(UML+'Package')

2. Is there a similar idiom which works for Paths?   I've tried:

packages=pkg1.findall(UML+'Namespace.ownedElement/'+UML+'Package')

but haven't found the right combination, so I do step-at-a-time descent.

-- 
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718



More information about the Python-list mailing list