empty EntityResolver for SAX

C

christof hoeke

hi,
(the following description is a bit convoluted, sorry about that. i hope
you understand it anyway...)

i thought of providing an empty EntityResolver to my parse function that
if i encounter xml files with DTDs in them these will not be processed.


class EmptyEntityResolver(xml.sax.handler.EntityResolver):

def resolveEntity(self, publicId, systemId):
return "http://localhost/empty.txt"

p = xml.sax.make_parser()
p.setContentHandler(handler)
p.setEntityResolver(EmptyEntityResolver())

i could use
p.setFeature('http://xml.org/sax/features/external-general-entities',False)
of course but i thought something like the above might be better for my
purpose.


my problem now is that something like
return None
does not work. only the above with the dummy empty.txt file needs to be
present.

is there a simpler way of returning an empty InputSource?


thanks a lot
chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top