Quantcast

Zend_Xml_Parser & Zend_Xml_Writer Proposal feedback

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Zend_Xml_Parser & Zend_Xml_Writer Proposal feedback

vince.
Hey,

I was wondering if anyone willing to give some feedback about the proposal i made @link http://framework.zend.com/wiki/display/ZFPROP/Zend_Xml+-+Vadim+Gabriel

I am not sure how often this is used by other developers but i use this very often. I am also not sure if this is something that was already made or talked about, I couldn't find anything about it.

Thanks, Vince.

--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Xml_Parser & Zend_Xml_Writer Proposal feedback

weierophinney
Administrator
-- Vadim Gabriel <[hidden email]> wrote
(on Friday, 24 April 2009, 06:25 PM +0300):
> I was wondering if anyone willing to give some feedback about the proposal i
> made @link http://framework.zend.com/wiki/display/ZFPROP/
> Zend_Xml+-+Vadim+Gabriel
>
> I am not sure how often this is used by other developers but i use this very
> often. I am also not sure if this is something that was already made or talked
> about, I couldn't find anything about it.

You may want to see how Zend_Config_Xml and Zend_Config_Writer_Xml work,
as they already do much of this. As an example:

    $xml =<<<EOX
    <?xml version="1.0"?>
    <foo>
        <bar>Bar</bar>
        <baz>
            <foo>Foo</foo>
            <bar>Bar</bar>
        </baz>
    </foo>
    EOX;
    $config = new Zend_Config_Xml($xml);
    $arr = $config->toArray();
    echo var_export($arr, 1), "\n";

    $writer = new Zend_Config_Writer_Xml();
    $writer->setFilename('php://stdout')
        ->setConfig($config);
    ob_start();
    $writer->write();
    $genXml = ob_get_clean();
    echo var_export($genXml, 1), "\n";

It's not flawless, but if you run the above, you'll see that the first
instance transforms the XML to an array, the second transforms a config
to XML. (You can transform an array to a config object by simply doing
$config = new Zend_Config($array); ) It may be useful to add a method to
the Zend_Config_Writer base class to allow retrieving the generated text
(instead of writing it directly to file) -- this would obviate the need
to do the output buffering hack above.

Otherwise, it kinda makes sense -- casting a SimpleXML object to an
array is non-recursive, and there are no native PHP libraries for
casting an array to an XML document. However, if what you want to do can
be accomplished with the config objects already, I'm not sure how much
need there is for an extra component.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Xml_Parser & Zend_Xml_Writer Proposal feedback

Vince42
Yo,

and later on there will be a Zend_Xsl and Zend_Xsd proposal - that would
rock :)

@Matthew

Wouldn't it be reasonable to create an (abstract) base class and let
Zend_Config_Xml and Zend_Config_Xml_Writer (new name :P) inherit that one?

--
Cheers,                        \\|//
Vince                          (o o)
----------------------------ooO-(_)-Ooo-------------------------
 '''   (o)_(o)                                        [ ][0][ ]
 ô¿ô   (=°o°=)   World Domination by Copy and Paste   [ ][ ][0]
  -    (")_(")                                        [0][0][0]

 ()  ascii ribbon campaign - against html e-mail
 /\  www.asciiribbon.org   - against proprietary attachments
                                   Ooo.
---------------------------.ooO----(  )-------------------------
                           (  )    (_/
                            \_)


signature.asc (202 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Xml_Parser & Zend_Xml_Writer Proposal feedback

vince.
In reply to this post by weierophinney
Hey,

Yea, I thought this will have similarity but yea there is no need to add another component if there is already one that does it. Although i personally use this in my projects, There is no need for duplicating functionality. I guess this can be archived. :)

Thanks for taking a look at it.

Vince.

On Fri, Apr 24, 2009 at 7:33 PM, Matthew Weier O'Phinney <[hidden email]> wrote:
-- Vadim Gabriel <[hidden email]> wrote
(on Friday, 24 April 2009, 06:25 PM +0300):
> I was wondering if anyone willing to give some feedback about the proposal i
> made @link http://framework.zend.com/wiki/display/ZFPROP/
> Zend_Xml+-+Vadim+Gabriel
>
> I am not sure how often this is used by other developers but i use this very
> often. I am also not sure if this is something that was already made or talked
> about, I couldn't find anything about it.

You may want to see how Zend_Config_Xml and Zend_Config_Writer_Xml work,
as they already do much of this. As an example:

   $xml =<<<EOX
   <?xml version="1.0"?>
   <foo>
       <bar>Bar</bar>
       <baz>
           <foo>Foo</foo>
           <bar>Bar</bar>
       </baz>
   </foo>
   EOX;
   $config = new Zend_Config_Xml($xml);
   $arr = $config->toArray();
   echo var_export($arr, 1), "\n";

   $writer = new Zend_Config_Writer_Xml();
   $writer->setFilename('php://stdout')
       ->setConfig($config);
   ob_start();
   $writer->write();
   $genXml = ob_get_clean();
   echo var_export($genXml, 1), "\n";

It's not flawless, but if you run the above, you'll see that the first
instance transforms the XML to an array, the second transforms a config
to XML. (You can transform an array to a config object by simply doing
$config = new Zend_Config($array); ) It may be useful to add a method to
the Zend_Config_Writer base class to allow retrieving the generated text
(instead of writing it directly to file) -- this would obviate the need
to do the output buffering hack above.

Otherwise, it kinda makes sense -- casting a SimpleXML object to an
array is non-recursive, and there are no native PHP libraries for
casting an array to an XML document. However, if what you want to do can
be accomplished with the config objects already, I'm not sure how much
need there is for an extra component.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/



--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/



Loading...