View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Xml
{zone-data}

{zone-data:proposer-list}
[Daniele Orlando|mailto:d.orlando.0<at>zend<dot>com]
{zone-data}

{zone-data:revision}
0.1 - 1 August 2006: Initial Release
{zone-data}

{zone-data:overview}
Zend_Xml is a component that allow you to read nodes, create roots, append childs, set attributes, create texts in a XML resource, simply passing an XPath string or an array of strings with few or no parameters.
For instance, recursive operation on different xml node can be done passing an array of xpath strings.
In the same way, passing an xpath string and an array of node name strings, we can add many childs in just one function call.
This is possible combining the simplicity of the XPath syntax with the DOM versatility.
Simply useful.
{zone-data}

{zone-data:references}
* [XPath|http://www.w3.org/TR/xpath]
* [PHP DOM|http://www.php.net/dom]
{zone-data}

{zone-data:requirements}
Zend_Xml is a low level library for XML Document creation and manipulation.
* This component *will not* supports conversion in other markup languages or document types.
* This component *must* supports all PHP DOM methods.
{zone-data}

{zone-data:dependencies}
* Zend_Exception
{zone-data}

{zone-data:operation}
Instantiate Zend_Xml with the root name(s) of the xml document and, if required, the external stylesheet.
Now, you are ready to build your XML document quickly and with total control on every operation.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Base operations support
* Milestone 2: Full support for PHP DOM methods
* Milestone 3: Support for pre-existent DOMDocument and SimpleXML objects
* Milestone 4: Performance tuning
{zone-data}

{zone-data:class-list}
* Zend_Xml - xml creation and manipulation class
* Zend_Xml_Exception - exception handler
{zone-data}

{zone-data:use-cases}
||UC-01||
Creation of a new XML document with an external stylesheet:

{code}
<?php

$xml = new Zend_Xml( 'Service' , 'http://www.domain.dom/xsl/stylesheet.xsl' ) ;

?>

<?xml version="1.0" encoding="UTF-8"?>
<?xmlstylesheet type="text/xsl" encoding="UTF-8" href="http://www.domain.dom/xsl/stylesheet.xsl" indent="yes"?>
<Service/>
{code}

||UC-02||
Basic editing:

{code}
<?php

$xml = new Zend_Xml( 'Service' ) ;
$xml->appendChild( '//' , array('username'=>'Daniele Orlando') , array('type'=>'string') ) ;

?>

<?xml version="1.0" encoding="UTF-8"?>
<Service>
<username type="string">
Daniele Orlando
</username>
</Service>
{code}

||UC-03||
Recursive operations:

{code}
<?php

$xml = new Zend_Xml( 'Service' ) ;
$xml->appendChild( '//' , array('users'=>'','devel'=>'') ) ;
$xml->appendChild( array('//users','//devel') , array('username'=>'Daniele Orlando') , array('type'=>'string') ) ;
$xml->setAttribute( '//users' , array('level'=>'restricted') ) ;

?>

<?xml version="1.0" encoding="UTF-8"?>
<Service>
<users level="restricted">
<username type="string">
Daniele Orlando
</username>
</users>
<devel>
<username type="string">
Daniele Orlando
</username>
</devel>
</Service>
{code}

{zone-data}

{zone-data:skeletons}
The complete class is in "Attachments"
{code}
<?php

class Zend_Xml
{
public $Dom ;

public function __construct( $roots = null , $stylesheet = null ) ;

public function getNode( $xpath , $index = null ) ;

public function existsNode( $xpath , $index = null ) ;

public function appendRoot( $roots ) ;

public function appendChild( $xpaths , $childs , array $attributes = array() , $text = null ) ;

public function setAttribute( $xpaths , $attributes ) ;

public function createText( $xpaths , $texts ) ;
}

?>
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>