[RfC] XML_Serializer
| From: | Stephan Schmidt | Date: | Tue, 29 Jul 2003 20:11:02 +0000 |
| Subject: | [RfC] XML_Serializer | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-18902@lists.php.net to get a copy of this message | ||
Hi,
I modified the XML_Serializer class I proposed yesterday:
1. No more static method calls.
2. The Serializer can now be used for two things:
a) Serialize any data to XML, like generating an RDF or DocBook document
from an object
(http://www.php-tools.de/PEAR/XML/examples/serializeRDF.php)
b) Serialize any data, so it can later be unserialized by a class called
XML_Unserializer, on which I'll start working after I uploaded the first
version. In this mode you just have to set the typeHints option to true,
which will cause the serializer to add the type of the value and if
needed the classname and the original key (integers may not be used as
tagnames)
(http://www.php-tools.de/PEAR/XML/examples/serializeObject.php)
This information is enough to rebuild the original data structure.
3. Options can be set in the constructor
4. Added XML declaration (optional), typeHints (optional), encoding
(optional)
Examples can be found at:
Sourcecode:
http://www.php-tools.de/PEAR/XML/XML_Serializer.phps
Serialize an array, not intended to be unserialized
http://www.php-tools.de/PEAR/XML/examples/serializeArray.php
http://www.php-tools.de/PEAR/XML/examples/serializeArray.phps
Serialize an array to RDF, not intended to be unserialized
http://www.php-tools.de/PEAR/XML/examples/serializeRDF.php
http://www.php-tools.de/PEAR/XML/examples/serializeRDF.phps
Serialize nested object, intended to be unserialized
http://www.php-tools.de/PEAR/XML/examples/serializeObject.php
http://www.php-tools.de/PEAR/XML/examples/serializeObject.phps
I will still have to work on some issues and implement some other
features (__sleep() and __wakeup() for object, custom serialization for
object, serialization of scalar values,...) but I think I could release
a first beta version this weekend and then start working on the
Unserializer part. This shouldn't be to hard, as I already did a similar
class...
So now's the right time to give some feedback, especially on the topic
of file structure and an additional XML_Util (or just XML) package that
has methods commonly needed by XML classes.
Stephan