XML Marshalling of objects
Peter Hansen
peter at engcorp.com
Thu Oct 4 01:54:35 EDT 2001
David Bolen wrote:
>
> Markus Schaber <markus at schabi.de> writes:
>
> > <xml "dtd-declaration here">
> > <pickled_data>Here just follows the data stream from
> > pickle()</pickled_data>
> > </xml>
> >
> > Just write the two-liner dtd for it, and you have pickle outputting
> > valid xml, and with almost no speed loss :-)
>
> Even if you make the pickled_data element in your DTD a CDATA you're
> going to have to post-process the pickle output to ensure it doesn't
> include any characters that need to be quoted as entities in the XML
> stream (e.g., "<"). Then of course, you've to to invert this on the
> other side, so there's going to be some cost to the encoding/decoding.
There's always
<xml "dtd-declaration here">
<pickled_data><![CDATA[Here just follows the data stream from pickle()]]></pickled_data>
</xml>
which might be what you meant by CDATA element in a DTD but then again
it might not be (and DTDs are obsolete, aren't they?). That way you
would have to escape only the sequence ]]> if it were to occur in the
data.
--
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com
More information about the Python-list
mailing list