[XML-SIG] DOM handling with parsed element

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Fri, 14 Dec 2001 09:37:24 +0100 (CET)


On Thu, 13 Dec 2001, Thomas B. Passin wrote:

> Presumably in the next release of pyxml, all these NS functions will require
> None instead of '' for a missing namespace.

2 things : 
 * in the next release of PyXML, the non NS methods of 4DOM will delegate
the call to the NS methods with None as the namespace uri, so this should
be the end of the nightmare.
 * right now, a good way of writing code that won't require any changes
when upgrading to PyXML-0.7 is

try:
    from xml.dom import EMPTY_NAMESPACE
except:
    EMPTY_NAMESPACE = ''

and then use
elt.getAttributeNS(EMPTY_NAMESPACE,'foo')

This supposes that pyexpat has been used to build the DOM, which is the
default. With validation enabled, you have to set EMPTY_NAMESPACE to None.

In 0.7 everyone will be using None., and things will be much cleaner.

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).