[XML-SIG] handle_entityref not being called
Mon, 31 May 1999 13:52:11 +0200
On Sun, May 30 1999 "A.M. Kuchling" wrote:
> Michelle Mills Strout writes:
> > I am using the XMLParser class which is part of the xmllib. I would like
> > to define my own entity references of the form "β". In the process
> > of doing this I found that the function handle_entityref isn't actually
> > called with an entity reference is called. I stepped through the
> > following function with the debugger.
> The version of xmllib.py in Python 1.5.2 does seem to ignore
> handle_entityref(). Entities are handled in the internal method
> called goahead(), where, if an entity reference is found, the
> self.entitydefs dictionary is checked, and, if no corresponding key is
> found, the unknown_entityref() function is called. Perhaps the
> handle_entityref() method is obsolete; Sjoerd?
It looks like it is. I made this change quite a long time ago, so I
don't know exactly why I made it. I think it has to do with having to
rescan the result of the substitution. This is needed to make
definitions such as
<!ENTITY lt "&<">
work. Even if the ENTITY tag isn't recognized, you can define the lt
entity as having the value "&<" in self.entitydefs.
So the way to have you own entities is to add them to the
self.entitydefs dictionary. But watch out, the default value for that
dictionary is a class variable, so you may want to copy the old value
into an instance variable before you start modifying.
> The version of xmllib.py in the omnibus XML package is older,
> and actually does call handle_entityref(), which is why I'm assuming
> that the method was made vestigial (though not deleted) in version
I deleted the definition from the TestXMLParser but forgot to delete
it from the main XMLParser.
-- Sjoerd Mullender <email@example.com>