Re: AW: [PEAR-DEV] [RfC] XML_Serializer

From: Date: Wed, 30 Jul 2003 20:46:40 +0000
Subject: Re: AW: [PEAR-DEV] [RfC] XML_Serializer
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18978@lists.php.net to get a copy of this message
<schst@php-tools.net> wrote : > Hi, > >> $array = array('nodes' => array('node1' => 10, 'node2' >> => >> 20)); $conf = new Config(); $root =& >> $conf->parseConfig($array, 'phparray'); echo >> $root->toString('xml'); > OK, I admit, that's quite easy... > > I would recommend that you change Config, so it's able to store type > information in XML files. > It's nice to know if a value is false or zero... Good idea. > Did you take a look at patConfiguration? It's an XML based config class > and can be downloaded from http://www.php-tools.net, there I > use a > define tag to specify the types of the values... Yes, it's very good but has a different logic as Config. It doesn't handle attributes the same way and maybe is not as flexible under some circumstances. I especially liked the XPath like access to directives and want to add such a feature to Config soon. It's a pity we didn't work on it together when we started our projects... >> You get my +1, my preference would go for XML_Common instead >> of XML or XML_Util, just like it is with HTML_Common. > I thought of this, too. But HTML_Common is more like a base class for > other HTML_* and that's not what XML_Util is for... So people might get > a bit confused... You could plan to make it a base class for other XML related packages, the same way as HTML_Common, even if older packages don't use it yet. You will notice that XML packages often use the same methods over and over again. They could simply extend XML_Common. In fact, I would favor this solution. If it's only an helper class, a collection of useful methods that needs to be called statically, it can also be called XML_Helper. Anyway, I won't block the process for that, call it XML_Util if you prefer. About the XML_Serializer, it looks to me that XML_Converter might be clearer as serializer implies some sort of debugging output IMO. Did you try Derick's XDebug ? It can serialize your php variables into XML. Example: $conf['storage']['driver'] = 'sql'; $conf['storage']['params']['phptype'] = 'mysql, oracle'; $conf['storage']['params']['hostspec'] = 'localhost'; $conf['storage']['params']['username'] = false; $conf['storage']['params']['password'] = 'true'; Will output: <var name='conf'><array> <var name='storage'><array> <var name='driver'><string>sql</string></var> <var name='params'><array> <var name='phptype'><string>mysql, oracle</string></var> <var name='hostspec'><string>localhost</string></var> <var name='username'><bool>0</bool></var> <var name='password'><string>true</string></var></array> </var></array> </var></array> </var> This is the kind of serialization done by XDebug in XML mode. In that regard, what you propose is more a converter than a serializer ? Bertrand Mansion Mamasam

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