From: sgunderson@bigfoot.com <> Date: Sat, 12 Aug 2006 22:16:46 +0000 (+0200) Subject: Yet more cloning fixes for PHP. *sigh* X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=fb3de693de0c047712fe39b947539917bf5d9f93;p=xml-template Yet more cloning fixes for PHP. *sigh* --- diff --git a/php/xml-template.php b/php/xml-template.php index 51f86a5..1a7434a 100644 --- a/php/xml-template.php +++ b/php/xml-template.php @@ -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); } }