[XML-SIG] Handling of character entity references
Randall Nortman
randall@wonderclown.com
Mon, 26 May 2003 14:46:23 -0500
On Mon, May 26, 2003 at 01:54:10PM -0400, Mark E. wrote:
> Randall Nortman wrote:
> >On Mon, May 26, 2003 at 09:46:14AM -0400, Mark E. wrote:
>
> >Everything parsed fine, but "é" was translated to nothing (no
> >character in that spot at all) on output. I suspect the skippedEntity
> >method needs to actually *do* something other than just print that it
> >is skipping an entity
>
> I'm not familiar with the DOM part of pyxml, but from a quick
> examination of the DOM code, it seems to me like the skippedEntity
> handler should create a "entity reference" object and add it to the
> document.
Well, I dug around until I figured out how XmlDomGenerator works, and
the following code was what was necessary:
def skippedEntity(self, name):
"""Found an undefined entity. Preserve it here."""
self._completeTextNode()
self._nodeStack[-1].appendChild(self._ownerDoc\
.createEntityReference(name))
The rest of the code was essentially as you had provided. Of course,
now it seems to pass ALL entities through unchanged; skippedEntity
seems to be called even if I pull in the XHTML Latin-1 entity set in
my DOCTYPE section. I suspect this is due to the feature_external_ges
and UseForeignDTD magic you performed in your example, which I do not
fully understand. This behavior is OK for now, but what if I actually
want to enable some entities to be parsed and substituted in the
future? I may wish to break my source files into pieces, for example,
and have them reassembled on parse. Will this affect external entities
like that?
Thanks for your help,
Randall Nortman