[XML-SIG] DocumentFragment ??

Andrew Clover and-xml at doxdesk.com
Tue May 4 08:48:17 EDT 2004


Kevin Thackray <kevin.thackray at clarisys.fr> wrote:

>    newDoc = Document()

> class Header(DocumentFragment):
>    DocumentFragment.__init__(self)

minidom makes no promises about using its internal classes directly 
rather than through the W3C standard DOM interfaces (createDocument and 
so on)*.

Instantiating Node objects manually in later versions of minidom is 
likely to result in broken objects that can cause exceptions like these. 
In particular, you can't construct a DocumentFragment without telling it 
which Document it belongs to. Normally this would happen in the 
Document.createDocumentFragment method.

Subclassing the DOM objects from minidom (or the other implementations I 
know of) is unsupported. You would have to either override all the 
relevant factory methods, or write back your extended versions into 
their namespace. Both approaches would require in-depth knowledge of the 
implementation's internal data structures, and would be incompatible 
across versions.

I suggest using a containment relationship between Header and 
DocumentFragment, instead of inheritance.


* - except in earlier versions of the Reference Manual, where Document
     was specified to be directly instantiable.

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/



More information about the XML-SIG mailing list