$processed = false;
if ($child->node_type() == XML_ELEMENT_NODE) {
+ unset($id);
+
$tag = $child->node_name();
$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
- // $child->remove_attribute($attr->name());
+ $attr->unlink_node();
}
}
}
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);
}
}