[Twisted-Python] Re: [XML-SIG] Can anyone recommend a sensible XML parser for Python?

Fred L. Drake, Jr. fdrake at acm.org
Tue Sep 10 00:40:55 EDT 2002

Uche Ogbuji writes:
 > Wouldn't it be better for Python/XML to offer a *separate*, specialized 
 > function for cloning nodes, rather than doing weird things with cloneNode?

Why?  I'd rather make cloneNode() do the right thing, and it seems
rather clear what that should be.  Certainly more clear than for
DocumentType nodes.  ;-)

 > I see.  It sounds as if a general document duplication function
 > would be of use to you.  I agree that this would be useful.  I'm
 > willing to write one and add it to xml.dom.ext.
 > But I don't think this is a use case for node.cloneNode.

I think it's a perfectly valid use case for Document.cloneNode().

 > Then again, the poor state of PyXML documentation in general weakens that 
 > point of mine, doesn't it?  Ah well.

There is that.  ;-)  Perhaps before making something stop working (for
some definition of "work"), the documentation should be checked for
contracts and updated if some under-specified behavior should be
consider beyond the contract.  Removing features tends to be frowned
upon in the Python world, especially if the documentation for what
something should do is just plain missing -- it becomes really hard to
say what isn't in the contract, because nobody said what *is* in the

 > There are still some parties interested in Twisted who are upset
 > that it requires Python 2.1; in fact, I felt guilty doing 2.1
 > support because I am likely going to have to backport portions of
 > it to 1.5.2 for some people.

Hey, at least PyXML makes that part easy, since Python 2.0 support is
still in it's contract!  ;-)  On the other hand, it's painful because
we end up with cruft like xml.dom.minicompat to make things work
reasonably with newer Pythons and still work for older versions.  I'm
waiting for the day we can assume there are new-style objects, and
everything works.

 > I think you take the wrong gloss on my words.  I think Linus
 > Torvalds himself would take years to write a complete and correct
 > XML parser.  It's the nature of the beast (XML), not the
 > programmer.

Hear ye, hear ye!

 > As I said, I am very skeptical of the result.  I'll be impressed
 > when you tell me your home-brew XML parser passes the OASIS
 > conformance suite.

Heck, even Expat doesn't pass that yet!  (We are making progress,


Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation

More information about the Twisted-Python mailing list