[XML-SIG] Subclassing xml.dom.minidom

Nicholas M. Kirsch nick@isilon.com
Thu, 8 May 2003 09:10:27 -0700 (PDT)


> Depending on just which node types you want to affect, this may be
> fairly easy, or it may be more painful.  Changing Text nodes will be
> most difficult if you intend to use xml.dom.xmlbuilder without further
> subclassing.
>
> At the very least, you can expect to subclass the DOMImplementation
> and Document classes (to control the factory functions) and the
> specific node types you want to affect.
>
> I'll be glad to try and answer further questions, but you'll need to
> be more specific.

My desire is to modify the behavior of getAttribute and add inheritance
functionality such that an element inherits its parents attributes (if not
defined) and other wackiness.

I have subclassed DOMImplementation and Document, but using
xml.dom.minidom things still don't work properly. I modified
xml.dom.expatbuilder.theDOMImplementation to be an instance of my
DOMImplementation. When I use xml.dom.minidom.parse, I successfully
retrieve an instance of my Document. However, the Elements are not
subclasses, despite having overriden the Document.createElement method.

Looking at expatbuilder.py, I have found quite a few cases in which it
instantiates an Element by using minidom.Element() instead of
theDOMImplementation.createElement. The same behavior is repeated for
Attributes and Text. This seems like a bug to me?!

Am I going about this incorrectly?

Thanks.

Nick