[Python-Dev] Encoding of code in XML

David Ascher DavidA@ActiveState.com
Wed, 19 Apr 2000 10:43:26 -0700


> What is wrong with encoding ]]> in the XML way by using an extra
> CDATA.  In other words split up the CDATA section into two in the
> middle of the ]]> sequence:
>
> import string
> def encode_cdata(str):
>     return '<![CDATA[' + \
> 	   string.join(string.split(str, ']]>'), ']]]]><![CDATA[>')) + \
> 	   ']]>'

If I understand what you're proposing, you're splitting a single bit of
Python code into N XML elements.  This requires smarts not on the decode
function (where they should be, IMO), but on the XML parsing stage (several
leaves of the tree have to be merged).  Seems like the wrong direction to
push things.  Also, I can imagine cases where the app puts several scripts
in consecutive CDATA elements (assuming that's legal XML), and where a merge
which inserted extra ]]> would be very surprising.

Maybe I'm misunderstanding you, though....

--david ascher