diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Fault.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Fault.php --- Polycast_XmlWriter/XmlRpc/Fault.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Fault.php 2009-10-08 12:16:27.000000000 +0200 @@ -283,18 +283,17 @@ class Zend_XmlRpc_Fault 'faultCode' => $this->getCode(), 'faultString' => $this->getMessage() ); - - $value = Zend_XmlRpc_Value::getXmlRpcValue($faultStruct)->saveXML(); + $value = Zend_XmlRpc_Value::getXmlRpcValue($faultStruct); + $valueDOM = new DOMDocument('1.0', $this->getEncoding()); + $valueDOM->loadXML($value->saveXML()); - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', $this->getEncoding()); - $xml->startElement('methodResponse'); - $xml->startElement('fault'); - $xml->writeRaw($value); - $xml->endElement(); // fault - $xml->endElement(); // methodResponse - return $xml->flush(); + // Build response XML + $dom = new DOMDocument('1.0', $this->getEncoding()); + $r = $dom->appendChild($dom->createElement('methodResponse')); + $f = $r->appendChild($dom->createElement('fault')); + $f->appendChild($dom->importNode($valueDOM->documentElement, 1)); + + return $dom->saveXML(); } /** diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Request.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Request.php --- Polycast_XmlWriter/XmlRpc/Request.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Request.php 2009-10-08 12:16:27.000000000 +0200 @@ -406,28 +406,24 @@ class Zend_XmlRpc_Request $args = $this->_getXmlRpcParams(); $method = $this->getMethod(); - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', $this->getEncoding()); - $xml->startElement('methodCall'); - $xml->startElement('methodName'); - $xml->text($method); - $xml->endElement(); // methodName - + $dom = new DOMDocument('1.0', $this->getEncoding()); + $mCall = $dom->appendChild($dom->createElement('methodCall')); + $mName = $mCall->appendChild($dom->createElement('methodName', $method)); + if (is_array($args) && count($args)) { - $xml->startElement('params'); + $params = $mCall->appendChild($dom->createElement('params')); foreach ($args as $arg) { /* @var $arg Zend_XmlRpc_Value */ - $xml->startElement('param'); - $xml->writeRaw($arg->saveXML()); - $xml->endElement(); // param + $argDOM = new DOMDocument('1.0', $this->getEncoding()); + $argDOM->loadXML($arg->saveXML()); + + $param = $params->appendChild($dom->createElement('param')); + $param->appendChild($dom->importNode($argDOM->documentElement, 1)); } - $xml->endElement(); // params } - $xml->endElement(); // methodCall - - return $xml->flush(); + + return $dom->saveXML(); } /** diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Response.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Response.php --- Polycast_XmlWriter/XmlRpc/Response.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Response.php 2009-12-03 22:20:22.000000000 +0100 @@ -223,17 +223,18 @@ class Zend_XmlRpc_Response */ public function saveXML() { - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', $this->getEncoding()); - $xml->startElement('methodResponse'); - $xml->startElement('params'); - $xml->startElement('param'); - $xml->writeRaw($this->_getXmlRpcReturn()->saveXML()); - $xml->endElement(); // param - $xml->endElement(); // params - $xml->endElement(); // methodResponse - return $xml->flush(); + $value = $this->_getXmlRpcReturn(); + $valueDOM = new DOMDocument('1.0', $this->getEncoding()); + $valueDOM->loadXML($value->saveXML()); + + $dom = new DOMDocument('1.0', $this->getEncoding()); + $response = $dom->appendChild($dom->createElement('methodResponse')); + $params = $response->appendChild($dom->createElement('params')); + $param = $params->appendChild($dom->createElement('param')); + + $param->appendChild($dom->importNode($valueDOM->documentElement, true)); + + return $dom->saveXML(); } /** diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value/Array.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Array.php --- Polycast_XmlWriter/XmlRpc/Value/Array.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Array.php 2009-12-03 22:20:22.000000000 +0100 @@ -56,24 +56,20 @@ class Zend_XmlRpc_Value_Array extends Ze public function saveXML() { if (!$this->_as_xml) { // The XML code was not calculated yet - - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', 'UTF-8'); - $xml->startElement('value'); - $xml->startElement('array'); - $xml->startElement('data'); - + $dom = new DOMDocument('1.0'); + $value = $dom->appendChild($dom->createElement('value')); + $array = $value->appendChild($dom->createElement('array')); + $data = $array->appendChild($dom->createElement('data')); + if (is_array($this->_value)) { - foreach ($this->_value as $name => $val) { + foreach ($this->_value as $val) { /* @var $val Zend_XmlRpc_Value */ - $xml->writeRaw($val->saveXML()); + $data->appendChild($dom->importNode($val->getAsDOM(), true)); } } - $xml->endElement(); // data - $xml->endElement(); // array - $xml->endElement(); // value - $this->_as_xml = $this->_stripXmlDeclaration($xml->flush()); + + $this->_as_dom = $value; + $this->_as_xml = $this->_stripXmlDeclaration($dom); } return $this->_as_xml; diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value/Base64.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Base64.php --- Polycast_XmlWriter/XmlRpc/Value/Base64.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Base64.php 2009-12-03 22:20:22.000000000 +0100 @@ -73,15 +73,15 @@ class Zend_XmlRpc_Value_Base64 extends Z */ public function saveXML() { - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', 'UTF-8'); - $xml->startElement('value'); - $xml->startElement($this->_type); - $xml->text($this->_value); - $xml->endElement(); // type - $xml->endElement(); // value - $this->_as_xml = $this->_stripXmlDeclaration($xml->flush()); + if (! $this->_as_xml) { // The XML was not generated yet + $dom = new DOMDocument('1.0', 'UTF-8'); + $value = $dom->appendChild($dom->createElement('value')); + $type = $value->appendChild($dom->createElement($this->_type)); + $type->appendChild($dom->createTextNode($this->_value)); + + $this->_as_dom = $value; + $this->_as_xml = $this->_stripXmlDeclaration($dom); + } return $this->_as_xml; } diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value/Boolean.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Boolean.php --- Polycast_XmlWriter/XmlRpc/Value/Boolean.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Boolean.php 2009-12-03 22:20:22.000000000 +0100 @@ -69,16 +69,13 @@ class Zend_XmlRpc_Value_Boolean extends public function saveXML() { if (! $this->_as_xml) { // The XML was not generated yet - - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', 'UTF-8'); - $xml->startElement('value'); - $xml->startElement($this->_type); - $xml->text($this->_value); - $xml->endElement(); // type - $xml->endElement(); // value - $this->_as_xml = $this->_stripXmlDeclaration($xml->flush()); + $dom = new DOMDocument('1.0', 'UTF-8'); + $value = $dom->appendChild($dom->createElement('value')); + $type = $value->appendChild($dom->createElement($this->_type)); + $type->appendChild($dom->createTextNode($this->_value)); + + $this->_as_dom = $value; + $this->_as_xml = $this->_stripXmlDeclaration($dom); } return $this->_as_xml; diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value/Scalar.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Scalar.php --- Polycast_XmlWriter/XmlRpc/Value/Scalar.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Scalar.php 2009-12-03 22:20:22.000000000 +0100 @@ -45,16 +45,13 @@ abstract class Zend_XmlRpc_Value_Scalar public function saveXML() { if (!$this->_as_xml) { // The XML code was not calculated yet - - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', 'UTF-8'); - $xml->startElement('value'); - $xml->startElement($this->_type); - $xml->text($this->getValue()); - $xml->endElement(); // type - $xml->endElement(); // value - $this->_as_xml = $this->_stripXmlDeclaration($xml->flush()); + $dom = new DOMDocument('1.0'); + $value = $dom->appendChild($dom->createElement('value')); + $type = $value->appendChild($dom->createElement($this->_type)); + $type->appendChild($dom->createTextNode($this->getValue())); + + $this->_as_dom = $value; + $this->_as_xml = $this->_stripXmlDeclaration($dom); } return $this->_as_xml; diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value/Struct.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Struct.php --- Polycast_XmlWriter/XmlRpc/Value/Struct.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value/Struct.php 2009-12-03 22:20:22.000000000 +0100 @@ -47,6 +47,7 @@ class Zend_XmlRpc_Value_Struct extends Z parent::__construct($value); } + /** * Return the XML code that represent struct native MXL-RPC value * @@ -55,27 +56,21 @@ class Zend_XmlRpc_Value_Struct extends Z public function saveXML() { if (!$this->_as_xml) { // The XML code was not calculated yet - - $xml = new XmlWriter(); - $xml->openMemory(); - $xml->startDocument('1.0', 'UTF-8'); - $xml->startElement('value'); - $xml->startElement('struct'); - + $dom = new DOMDocument('1.0'); + $value = $dom->appendChild($dom->createElement('value')); + $struct = $value->appendChild($dom->createElement('struct')); + if (is_array($this->_value)) { foreach ($this->_value as $name => $val) { /* @var $val Zend_XmlRpc_Value */ - $xml->startElement('member'); - $xml->startElement('name'); - $xml->text($name); - $xml->endElement(); // name - $xml->writeRaw($val->saveXML()); - $xml->endElement(); // member + $member = $struct->appendChild($dom->createElement('member')); + $member->appendChild($dom->createElement('name', $this->_escapeXmlEntities($name))); + $member->appendChild($dom->importNode($val->getAsDOM(), 1)); } } - $xml->endElement(); // struct - $xml->endElement(); // value - $this->_as_xml = $this->_stripXmlDeclaration($xml->flush()); + + $this->_as_dom = $value; + $this->_as_xml = $this->_stripXmlDeclaration($dom); } return $this->_as_xml; diff --exclude .git --exclude .svn -rup Polycast_XmlWriter/XmlRpc/Value.php ZendFramework-1.9.3PL1/Zend/XmlRpc/Value.php --- Polycast_XmlWriter/XmlRpc/Value.php 2009-12-03 22:19:59.000000000 +0100 +++ ZendFramework-1.9.3PL1/Zend/XmlRpc/Value.php 2009-12-03 15:27:12.000000000 +0100 @@ -119,7 +119,7 @@ abstract class Zend_XmlRpc_Value public function getAsDOM() { if (!$this->_as_dom) { - $doc = new DOMDocument('1.0', 'UTF-8'); + $doc = new DOMDocument('1.0'); $doc->loadXML($this->saveXML()); $this->_as_dom = $doc->documentElement; } @@ -127,9 +127,9 @@ abstract class Zend_XmlRpc_Value return $this->_as_dom; } - protected function _stripXmlDeclaration($xml) + protected function _stripXmlDeclaration(DOMDocument $dom) { - return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $xml); + return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $dom->saveXML()); } /**