C
chris
hi,
sax beginner question i must admit:
i try to filter a simple XHTML document with a standard DTD declaration
(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">) in it.
sax gives the following error
which is an entity.
so i thought i just implement the EntityResolver class and use a local
copy of the DTD
# ========================
class XHTMLResolver(xml.sax.handler.EntityResolver, object):
def resolveEntity(self, publicId, systemId):
return 'http://localhost/xhtml1-transitional.dtd'
reader = xml.sax.make_parser()
reader.setEntityResolver(XHTMLResolver())
# ========================
problem is, it seems expat does not use this resolver as i get the same
error again. i also tried the following, which is not supported anyhow:
reader.setFeature('http://xml.org/sax/features/external-parameter-entities',
True)external parameter entities
is the XHTMLResolver class not the way it should be? or do i have to set
another feature/property?
ultimately i do not want to use the http://localhost copy but i would
like to read the local file (just with open(...) or something) and go
from there. is that possible? do i have to
thanks a lot
chris
sax beginner question i must admit:
i try to filter a simple XHTML document with a standard DTD declaration
(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">) in it.
sax gives the following error
which is an entity.
so i thought i just implement the EntityResolver class and use a local
copy of the DTD
# ========================
class XHTMLResolver(xml.sax.handler.EntityResolver, object):
def resolveEntity(self, publicId, systemId):
return 'http://localhost/xhtml1-transitional.dtd'
reader = xml.sax.make_parser()
reader.setEntityResolver(XHTMLResolver())
# ========================
problem is, it seems expat does not use this resolver as i get the same
error again. i also tried the following, which is not supported anyhow:
reader.setFeature('http://xml.org/sax/features/external-parameter-entities',
True)external parameter entities
is the XHTMLResolver class not the way it should be? or do i have to set
another feature/property?
ultimately i do not want to use the http://localhost copy but i would
like to read the local file (just with open(...) or something) and go
from there. is that possible? do i have to
thanks a lot
chris