Stefan Behnel | 8 Sep 13:48

Re: Resolving entities

Kovid Goyal wrote:
> My application needs to process XML files that do not have DTD
> declarations but that contain entities.

In this case your document is not well-formed, i.e. not XML.

http://www.w3.org/TR/REC-xml/#sec-references

> Can I inform XMLParser of the entities somehow?

No, there isn't currently a way to work around such a broken document.
libxml2 follows the XML spec strictly in that it rejects references to
undeclared entities in the absence of a DTD.

ElementTree lacks DTD support and instead allows you to specify entities
through a parser local "entity" dictionary. lxml could potentially support
a similar interface by intercepting the entity reference resolving at the
SAX layer ("getEntity()" callback function), but that's not implemented.
Please file a wishlist bug.

Stefan

Gmane