[Zope] Using tal:attributes in XML with non-ASCII characters

Dieter Maurer dieter at handshake.de
Sun Mar 19 14:11:51 EST 2006


Andrew Veitch wrote at 2006-3-18 15:56 +0000:
>I'm just trying to think of a way of using tal:attributes with non- 
>ASCII characters using the XML parser.
>
>At first, I just used a straight tal:attributes with the encoding of  
>the template set to UTF-8 but that threw an expat error.

This means that almost surely your "non-ascii" was not encoded
in UTF-8. Encode them this way and it will work.

>My second attempt was to write a function which replaced all the non- 
>ASCII characters with entities such as Ā
>
>Unfortunately his also doesn't work because tal:attributes escapes it  
>into &#256 which then fails.

I have extended our local Zope version to support (beside "text"
and "structure") also "mtext" (for markup text). It does not
escape entity references but still escapes other markup.

>Finally, I tried tal:attributes with my function and the structure  
>keyword but 'structure' isn't supported with tal:attributes.

I have extended our local Zope to support "structure" for
attributes as well.


I could provide patches, if useful.

> ...
>Any ideas would be appreciated.


The correct (recommended) way it to encode your non-ascii
in the encoding you claim to be using. Then the "expat" error
will go away.

-- 
Dieter


More information about the Zope mailing list