]> git.sesse.net Git - xml-template/commitdiff
Yet more cloning fixes for PHP. *sigh*
authorsgunderson@bigfoot.com <>
Sat, 12 Aug 2006 22:16:46 +0000 (00:16 +0200)
committersgunderson@bigfoot.com <>
Sat, 12 Aug 2006 22:16:46 +0000 (00:16 +0200)
php/xml-template.php

index 51f86a56fa1a02cdc90b0cb3220f069b9f92eb89..1a7434ae99947db0d62c56f411ea10cdd8f30484 100644 (file)
@@ -37,10 +37,7 @@ function XML_Template_process($node, $obj, $clean = 1)
                                $attrs = $child->attributes();
                                if (isset($attrs)) {
                                        foreach ($child->attributes() as $attr) {
-                                               // PHP's DOMXML module forgets the prefix information when
-                                               // cloning nodes, so we'll have to avoid the namespace check
-                                               // here, unfortunately
-                                               if (/* $attr->namespace_uri() == 'http://template.sesse.net/' && */ $attr->name() == 'id') {
+                                               if ($attr->namespace_uri() == 'http://template.sesse.net/' && $attr->name() == 'id') {
                                                        $id = $attr->value();
                                                        if ($clean) {
                                                                // FIXME: this won't work since we're not in the right namespace
@@ -159,7 +156,10 @@ function own_clone_node($node, $doc)
                if (isset($attrs)) {
                        foreach ($node->attributes() as $attr) {
                                $attr2 = $doc->create_attribute($attr->name(), $attr->value());
-                               $attr2->set_namespace($attr->namespace_uri(), $attr->prefix());
+                               $nsuri = $attr->namespace_uri();
+                               if (isset($nsuri)) {
+                                       $attr2->set_namespace($nsuri, $attr->prefix());
+                               }
                                $newnode->append_child($attr2);
                        }
                }