Re: [RfC] XML_Serializer

From: Date: Tue, 29 Jul 2003 21:02:56 +0000
Subject: Re: [RfC] XML_Serializer
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18904@lists.php.net to get a copy of this message
Hi, I like the code much better with the changes. So, I am +1 for the code, and -1 for the missing docs, which leaves me at +0. I'd like to see what you've written below as point 2 transformed into in-code docs, and the first 2 examples included with the first release, that should be enough for an initial release to be clear to anyone who installs it. I'm a big +1 for an XML_Util class, although I'm not a big fan of static methods for this class, it should be possible to extend them. XML_Util should be small and simple, any extra functionality should be implemented in child classes like XML_Transformer_Util (which is why static methods wouldn't be good). This is to prevent dependency bloat. Regards, Greg Stephan Schmidt wrote:
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


« previous php.pear.dev (#18904) next »