[issue2124] xml.sax and xml.dom fetch DTDs by default

Martin v. Löwis report at bugs.python.org
Wed Feb 4 00:12:09 CET 2009


Martin v. Löwis <martin at v.loewis.de> added the comment:

> Where in the following sequence am I supposed to receive the document 
> locator?
> 
> parser = xml.sax.make_parser()
> parser.setEntityResolver(CachingEntityResolver())
> doc = xml.dom.minidom.parse('file.xml', parser)

This is DOM parsing, not SAX parsing.

> The content handler is being created deep inside xml.dom.  It does, in 
> fact, store the document locator, but not in any place that I can easily 
> access without breaking several layers of abstraction.

So break layers of abstraction, then. Or else, use dom.expatbuilder,
and ignore SAX/pulldom for DOM parsing.

> Or, as a more general question: How can I get a DOM tree that includes 
> external entities?  If there's an easy way to do it, the documentation 
> does not make it clear at all.

This tracker is really not the place to ask questions; use python-list
for that.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2124>
_______________________________________


More information about the Python-bugs-list mailing list