[Patches] [Patch #102477] DOM enhancements

noreply@sourceforge.net noreply@sourceforge.net
Thu, 14 Dec 2000 10:22:07 -0800


Patch #102477 has been updated. 

Project: python
Category: XML
Status: Closed
Submitted by: fdrake
Assigned to : fdrake
Summary: DOM enhancements

Follow-Ups:

Date: 2000-Dec-14 10:22
By: fdrake

Comment:
On Node.normalize():  Looking again, I don't think so.  Removed in the checkin.

Checked in as the following revisions:

Lib/xml/dom/minidom.py		1.15
Lib/xml/dom/pulldom.py		1.12
Lib/test/test_minidom.py		1.16
Lib/test/output/test_minidom		1.11
-------------------------------------------------------

Date: 2000-Dec-14 04:54
By: loewis

Comment:
This patch looks ok now, please install it.

One question still on normalize: Is it really necessary to copy self.childNodes before iterating over it?
-------------------------------------------------------

Date: 2000-Dec-13 14:29
By: fdrake

Comment:
New version of the patch; I *think* I've addressed Martin's concerns.  (I do not agree that AttributeError(name) is better than AttributeError, name though, and did not change that.)

Outstanding problems/limitations:

createDocumentNS() has not been implemented.

createDocument() does not create the root element.  This is related to a limitation in pulldom:  it creates the document before the root element is seen, and operation of DOMEventStream.expandNode() seems to rely on this.  This needs to be restructured somehow.

pulldom.PullDOM & friends rely on using the parentNode attribute before nodes have been added to the tree, including write access to the attribute.  This will not work with all DOM implementations and violates the DOM API.  I think we can work around this, but that's yet another large chunk of changes.

(And I think this is already a huge improvement over what's checked in, so I'd like to move on this.)
-------------------------------------------------------

Date: 2000-Nov-22 13:39
By: fdrake

Comment:
This modifies PullDOM.__init__() to accept a Document object as a parameter, and changes PullDOM.startDocument() to use that object or create a one using minidom if necessary.  This allows all existing client code to continue to work unchanged, while supporting use of alternate DOM implementations.
-------------------------------------------------------

Date: 2000-Nov-22 22:24
By: fdrake

Comment:
Revised patch based on Greg Stein's note that the original would not create a new Document instance for each call to startDocument(); this version takes a document factory instead of a document object, and creates a new document with each call to startDocument().

-------------------------------------------------------

Date: 2000-Nov-27 13:38
By: gvanrossum

Comment:
Fred, please pick someone to review this and assign it to them.
-------------------------------------------------------

Date: 2000-Nov-27 15:03
By: fdrake

Comment:
[Changed summary line to reflect updated patch.  Assigning to Martin since he cares about this stuff.  ;-)  ]

xml.dom.minidom changes:

This improves the Node.normalize() method based on Martin's suggestions, but does not address all of his concerns (re-linking siblings in particular).  Test suite is updated to test that empty Text nodes are removed.

Minor improvement to an AttributeError that should not normally ever be seen by users.

Adds minimal support for DocumentType and DOMImplementation.

Partially fixes problem that documentElement was not properly supporting remove/replace; this should make it a little better, but sacrifices performance of using .documentElement to get it; the performance loss can be corrected by extending more methods in the Document class and removing the dynamic lookup of the documentElement attribute.

xml.dom.pulldom changes:

The PullDOM class now uses a DOMImplementation for the documentFactory object.  It's not clear that the createDocument method is used correctly, but the DOM Level 2 documentation for DOMImplementation is seriously lacking.

-------------------------------------------------------

Date: 2000-Nov-29 07:13
By: fdrake

Comment:
Uploading fixed patch, since something appearantly went wrong with the last upload.

Removed attempted use of cStringIO; that doesn't work with Unicode that can't be encoded using the default encoding for strings (often 7-bit ASCII), so we always use the original StringIO module.
-------------------------------------------------------

Date: 2000-Dec-03 03:32
By: loewis

Comment:
Comments in patch order:
- AttributeError: Is it better style to write AttributeError(key)?
- normalize: If the first text node is empty, I believe it won't be removed (unless the next node is also a text node)
- Doctype.unlink  is unnecessary; that is handled in Node (in general, each
   unlink should handle only the attributes introduced in this inheritance level)
- hasFeature: I think we cannot claim conformance to "xml" yet; that would require
  CDATASection, Notation, Entity, EntityReference and ProcessingInstruction support.
- Document: Shouldn't implementation point to the DOMImplementation instance that created the Document?
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=102477&group_id=5470