[XML-SIG] Converting to saxlib.py
Fri, 17 Apr 1998 09:56:54 -0400 (EDT)
As a trial, I'm converting the xmllib-based script I use for
processing my quotation collections to both SAX and DOM interfaces. I
did the SAX translation using the last experimental release of
saxlib.zip, and came across a few things:
* drv_xmllib.py doesn't override xmllib.py's unknown_entityref
and unknown_charref functions, so errors like &asdfasdf; are quietly
* The parse() method takes a systemID and does
urllib.urlopen() on it. Shouldn't there also be a way to pass in a
file-like object, and just have the parser read from it. This could
be done either by adding an optional 'infile' parameter to parse() and
only using urlopen() if it's omitted, or by adding a completely
* I've never written a formal DTD for my quotations; currently, the
files look like this:
<quotation>One trouble with being efficient is that it makes everybody
hate you so.
<source>The Calgary Eyeopener, March 18, 1916</source>
The new xmllib.py in Python 1.5.1, and the DOM package, both complain
about having multiple top-level objects. This also made my existing
script break, so I put everything inside a <collection> element.
Anyway, saxlib.py doesn't complain about this; should it, or should
that be left to the handleElement function written by the user?
Beyond that, the conversion from using xmllib.py to the SAX driver was
Next step: writing a DOM version...
A.M. Kuchling http://starship.skyport.net/crew/amk/
Thus the metric system did not really catch on in the States, unless you count
the increasing popularity of the nine-millimeter bullet.
-- Dave Barry