#! 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 <[EMAIL PROTECTED]>
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: <[EMAIL PROTECTED]>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
Lines: 43
Sender: [EMAIL PROTECTED]
Organization: The Boeing Company
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Mime-Version: 1.0
Date: Thu, 19 May 2005 13:24:58 GMT
Xref: news.xs4all.nl comp.lang.python:378110

"Fredrik Lundh" <[EMAIL PROTECTED]> 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.

-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to