[XML-SIG] Skipped entities under SAX
"Martin v. Löwis"
martin at v.loewis.de
Thu Apr 22 14:26:34 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.
It's a SAX thing, and yes, it is exactly that. It is the implementation
of 4.4.3 of XML 1.0:
If a non-validating processor does not include the replacement text, it
MUST inform the application that it recognized, but did not read, the
entity.
> 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.
Why are you saying this? It works for me just fine:
import xml.sax,xml.sax.handler
class Handler(xml.sax.ContentHandler):
def skippedEntity(self, e):
print "Skipping",e
p = xml.sax.make_parser()
h = Handler()
p.setContentHandler(h)
p.setFeature(xml.sax.handler.feature_external_ges, False)
p.feed("<!DOCTYPE foo SYSTEM 'demo.dtd'><foo>&unknown;</foo>")
This prints
Skipping unknown
Regards,
Martin
More information about the XML-SIG
mailing list