[Python-Dev] serializing Python as XML

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sun, 24 Sep 2000 19:56:04 +0200


> whether a package exists to serialize Python data structures as XML,

Zope has a variant of pickle where pickles follow an XML DTD (i.e. it
pickles into XML). I believe the current implementation first pickles
into an ASCII pickle and reformats that as XML afterwards, but that is
an implementation issue.

> so that lists of dictionaries of tuples of etc. can be exchanged
> with other XML-aware tools.

See, this is one of the common XML pitfalls. Even though the output of
that is well-formed XML, and even though there is an imaginary DTD (*)
which this XML could be validated against: it is still unlikely that
other XML-aware tools could make much use of the format, at least if
the original Python contained some "interesting" objects
(e.g. instance objects). Even with only dictionaries of tuples: The
Zope DTD supports cyclic structures; it would not be straight-forward
to support the back-referencing in structure in some other tool
(although certainly possible).

XML alone does not give interoperability. You need some agreed-upon
DTD for that. If that other XML-aware tool is willing to adopt to a
Python-provided DTD - why couldn't it read Python pickles in the first
place?

Regards,
Martin

(*) There have been repeated promises of actually writing down the DTD
some day.