[lxml-dev] Resolving entities
Stefan Behnel
stefan_ml at behnel.de
Mon Sep 8 13:48:02 CEST 2008
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
More information about the lxml-dev
mailing list