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
(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