[XML-SIG] Skipped entities under SAX
Walter Dörwald
walter.doerwald at livinglogic.de
Thu Apr 22 06:26:48 EDT 2004
Derek Fountain wrote:
> I've been exploring the PyXML SAX parser, and I've come across the handler for
> skipped entities. i.e. the skippedEntity method in the ContentHandler object.
>
> Puzzlement here. What exactly is a skipped entity? It's not mentioned in the
> XML spec, as far as I can see. The name suggests that it's an entity which
> the parser comes across and doesn't know how to handle, so it passes over it.
> Sort of:
>
> This odd &wierdthing; in the text
>
> where the weirdthing entity isn't declared.
>
> I'm only guessing the above, and it seems that the expat parser doesn't
> entertain such ideas. AFAICT, if it comes across an entity which it doesn't
> recognise, it throws an error.
>
> So what is a skipped entity, and when would I receive a call to the
> skippedEntity method in my SAX handler?
For ExpatParser you can overwrite reset like this:
class ExpatParser(expatreader.ExpatParser):
def reset(self):
expatreader.ExpatParser.reset(self)
self._parser.UseForeignDTD(True)
Before parsing you have to call:
parser.setFeature(handler.feature_external_ges, False)
Then ExpatParser will pass entity references to skippedEntity().
Bye,
Walter Dörwald
More information about the XML-SIG
mailing list