diff options
author | godzilla80@gmx.net <> | 2009-04-16 09:26:55 +0000 |
---|---|---|
committer | godzilla80@gmx.net <> | 2009-04-16 09:26:55 +0000 |
commit | 76c718e9afde72ba03c79bcfe39f63f7c8d2b9d0 (patch) | |
tree | b074babb55023b1f10308278f1c5d27c63179e35 | |
parent | 16f3e16a4da781e56064402e0cf48c5a5bae1c78 (diff) |
Fixed Issue #112 - TXmlDocument add support for namespaces: for backward compatibility only if SimpleXml installed
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Xml/TXmlDocument.php | 24 |
2 files changed, 23 insertions, 2 deletions
@@ -19,6 +19,7 @@ CHG: Issue#7 - Clients Scripts are not combined anymore in Debug application mod ENH: Issue#115 - Registry for Prado generated clientside counterparts of serverside controls (Yves Berkholz) ENH: Issue#135 - Add AutoPostBack property to TActiveFileUpload (Bradley) ENH: Issue#117 - TValidationSummary: new display mode "HeaderOnly" that only render value of HeaderText property (Yves) +BUG/ENH: Issue#112 - TXmlDocument add support for namespaces: for backward compatibility only if SimpleXml installed (Yves) ENH: Added caching of message files to TException (Michael) ENH: Updated to scriptaculous 1.8.2 & Prototype 1.6.0.3 ENH: replace is_null() function calls with native language constuct (Yves) diff --git a/framework/Xml/TXmlDocument.php b/framework/Xml/TXmlDocument.php index d7ddf187..7d506852 100644 --- a/framework/Xml/TXmlDocument.php +++ b/framework/Xml/TXmlDocument.php @@ -396,8 +396,27 @@ class TXmlDocument extends TXmlElement $attributes=$this->getAttributes(); $elements->clear(); $attributes->clear(); + + static $bSimpleXml; + if($bSimpleXml === null) + $bSimpleXml = (boolean)function_exists('simplexml_load_string'); + + if($bSimpleXml) + { + $simpleDoc = simplexml_load_string($string); + $docNamespaces = $simpleDoc->getDocNamespaces(false); + $simpleDoc = null; + foreach($docNamespaces as $prefix => $uri) + { + if($prefix === '') + $attributes->add('xmlns', $uri); + else + $attributes->add('xmlns:'.$prefix, $uri); + } + } + foreach($element->attributes as $name=>$attr) - $attributes->add($name,$attr->value); + $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); foreach($element->childNodes as $child) { if($child instanceof DOMElement) @@ -464,7 +483,8 @@ class TXmlDocument extends TXmlElement $element=new TXmlElement($node->tagName); $element->setValue($node->nodeValue); foreach($node->attributes as $name=>$attr) - $element->getAttributes()->add($name,$attr->value); + $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); + foreach($node->childNodes as $child) { if($child instanceof DOMElement) |