[XML-SIG] pDomlette bug/non standard method?

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Mon, 24 Sep 2001 12:32:14 +0200 (CEST)


On Mon, 24 Sep 2001, Alan Kernnedy wrote:

> According to the DOM spec, I should be able to acess the character
> data in a text node through the attribute "nodeValue", which is what
> my code used successfully with 4DOM, e.g
> 
> myData = myTextNode.nodeValue
> 
> Now, having examined the code, it appears that I have to use the
> attribute "data", i.e. I access the contents of a text node using
> 
> myData = myTextNode.data
> 
> Am I missing something here?

Well, I'd say that this is part of the price to pay for the memory
footprint decrease, and the speed improvement you get from switching from
4DOM to pDomlette (and it also explains the 'ette' at the end of
pDomlette). 

The idea is to get a DOM-like object structure, but not with all the
features mentionned in the spec (which make the DOM very heavyweight).

To be more specific to the case at hand, nodeValue is an attribute of the
Node interface, and data is an attribute of the CharacterData interface
(the Text interface inherits from this interface, which in turn inherits
from Node). pDomlette does not have a Node interface, and uses a pythonic
Implicit Interface pattern instead for classes that should implement it.
The consequence of this is that redundant methods/attributes are not
implemented (you'd have to update both data and nodeValue when one of them
is changed, or use __getattr__, and both of these have an impact on
performance or memory usage.

Using data in 4DOM is safe (if you want to preserve compatibility with
this DOM implementation), so I'd suggest you use data to get the contents
of a Text node. 

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).