[XML-SIG] Problem with entities

Lars Marius Garshol larsga@garshol.priv.no
16 Apr 2002 17:52:29 +0200


I was off travelling when this was posted, but feel it's worth
returning to.

* Patrick Gaherty
|
| I'm using the XMLGenerator class from saxutils (PyXML 0.7) and I'm
| having problems with entities. To start off with I'm just trying to
| recreate the original XML input file.

You can't do that. The XML parser throws away *heaps* of information
about the original document that you'd need in order to be able to do
this. So if that's what you want you should just stop, because it's
not going to work.

| This works a treat, except I'm losing any entities I've declared in
| my DTD (ie œ). Ideally I'd like them to appear in the output
| untouched.

As Tom Passin said: the generator expects to get parsed text, where
the entities have been replaced by what they represent. So what you
should output is the 'oe' character.

Of course, that would give you the 'oe' character as output, and you
seem to want the entity.

The first answer to that is: you shouldn't represent characters using
entities. It's just The Wrong Thing.

The second answer is that a very strong desire to do The Wrong Thing
is very widespread, and so perhaps we should support it. There are two
ways to do that:

 - add a entity(self, name) method

 - add a literal_text(self, text) method

Comments on this?

-- 
Lars Marius Garshol, Ontopian         <URL: http://www.ontopia.net >
ISO SC34/WG3, OASIS GeoLang TC        <URL: http://www.garshol.priv.no >