[Twisted-Python] Strange DOMTemplate error

Glyph Lefkowitz glyph at twistedmatrix.com
Fri Sep 20 13:51:07 EDT 2002

On Fri, 20 Sep 2002 05:20:41 -0400, Alex Levy <alexander.levy at tufts.edu> wrote:
> I have been toying around with DOM Templates, practically using the example 
> code off the web page (with a few minor changes), and I found something 
> very strange.

This should be fixed in the next release of Twisted, as DOMTemplate now uses
Twisted's internal representation of DOM trees, which is considerably more
relaxed about this kind of input.

> I received xml.sax._exceptions.SAXParseException whenever I placed the string
> '&copy;' inside my template HTML.  This, as it turns out, applied to just
> about any HTML special character.  I tested it with &copy; &nbsp; &foo; and a
> range of others.  It also broke (although with a different error) whenever I
> tried using numeric character codes, like &#153;.

"Special characters" in "HTML" are known in XML lingo as "entity references",
and they are hewn cold from the bones of the stillborn deep within the bowels
of satan's lair by the three arch demons.  You may have seen them featured in
the popular video-game adaption of the W3C's standardization process, "Diablo

Moral: try to avoid using them if you want your HTML to be processed by any
"real" XML tools.  As I said, Twisted will handle these more gently in the
future because there's not really any good reason to reject them, but be aware
that you're breaking the standard.

> Is this a 'feature', or some strange bug?  Figured I'd mention it here.

That depends on your personal opinion of "web standards".  Me, I'd say it's a
bug. :-)

 |    <`'>    |  Glyph Lefkowitz: Traveling Sorcerer   |
 |   < _/ >   |  Lead Developer,  the Twisted project  |
 |  < ___/ >  |      http://www.twistedmatrix.com      |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020920/8b134a4f/attachment.pgp 

More information about the Twisted-Python mailing list