DOM creation

Uche Ogbuji uche at ogbuji.net
Wed Feb 14 09:12:30 EST 2001


Venkatesh Prasad Ranganath wrote:

> I have a question on how DOM for a XML document conforming to DOM 2 should be
> constructed?
> 
> Now if there are no namespaces specified in the document then should attributes
> be added to DOM using
> setAttributeNS('', Name, Value)
> or
> setAttribute(Name, Value)?
> 
> The problem I am facing is when reading in a XML document with no explicit
> namespace specified in it through PyXML the attributes are added to the DOM
> using setAttributeNS with an empty NameSpace.  So, I wanted to clarify if this
> is a problem with PyXML or is this how other DOM Constructors work.

This is correct behavior.  Of course, if you use the
xml.dom.ext.reader.Sax reader, you get a tree with no namespace
specifiers at all, which is also correct.

If you plan to migrate to namespaces in future, or to mix namespace with
non-namespace behavior, I'd suggest sticking to the PyExpat and Sax2
readers and using the DOm Level 2 methods (with appended "NS").

> waiting for reply,

This reminds me.  I'm not sure I sent a reply to your last enquiry.

I had a few questions, such as which Reader you were trying to use (It
looked as if you didn't paste all of your example code in).

However, I'd suggest trying the latest 4Suite 0.10.2 beta that was
announced (since I noticed you're using XPath), and see if you still
have those problems.  If so, pleace copy follow-ups to
xml-sig at python.org, which I check more regularly than this newsgroup.

Thanks.

-- 
Uche Ogbuji
Personal:   uche at ogbuji.net		http://uche.ogbuji.net
Work:       uche.ogbuji at fourthought.com	http://Fourthought.com



More information about the Python-list mailing list