function XML_Template_process($node, $obj, $clean = 1)
{
- if (is_a($obj, 'domnode')) { # overwrite
+ if (is_a($obj, 'DOMNode')) { # overwrite
for ($i = 0; $i < $node->childNodes->length; ++$i) {
$child = $node->childNodes->item($i);
$node->removeChild($child);
}
- if (is_a($obj, 'domdocument')) {
+ if (is_a($obj, 'DOMDocument')) {
$obj = $obj->document_element();
}
if ($child->nodeType == XML_ELEMENT_NODE) {
unset($id);
- $tag = $child->nodeName;
+ $tag = $child->localName;
$attrs = $child->attributes;
+
if (isset($attrs)) {
foreach ($child->attributes as $attr) {
if ($attr->namespaceURI == 'http://template.sesse.net/' && $attr->name == 'id') {
# FIXME: we would want something like \Q and \E here...
if (preg_match('/^' . $tag . '\/(.*)$/', $key, $matches) ||
(isset($id) && preg_match('/^#' . $id . '\/(.*)$/', $key, $matches))) {
- $child->set_attribute($matches[1], $obj[$key]);
+ $child->setAttribute($matches[1], $obj[$key]);
}
if ($processed) {
}
# remove all the <fragment> tags
-
for ($i = 0; $i < $node->childNodes->length; ++$i) {
$child = $node->childNodes->item($i);
- if ($child->name != 'temporary-fragment') {
+ if ($child->localName != 'temporary-fragment') {
continue;
}
- for ($j = 0; $j < $child->childNodes->length; ++$j) {
- $child2 = $child->childNodes->item($j);
+ while ($child->childNodes->length > 0) {
+ $child2 = $child->childNodes->item(0);
$node->appendChild($child2);
}
+ --$i;
$node->removeChild($child);
}
}
# after we've done any required replacements
$doc = $node->ownerDocument;
$parent = $node->parentNode;
- for ($i = 0; $i < $node->childNodes->length; ++$i) {
- $child = $node->childNodes->item($i);
+
+ while ($node->childNodes->length > 0) {
+ $child = $node->childNodes->item(0);
$node->removeChild($child);
- $node->insert_before($child, $node);
+ $parent->insertBefore($child, $node);
}
$parent->removeChild($node);
}
if (isset($nsuri)) {
$attr2 = $doc->createAttribute($attr->name);
} else {
- $attr2 = $doc->createAttributeNS($nsuri, $attr->name);
- $attr2->prefix = $attr->prefix;
+ $attr2 = $doc->createAttributeNS($nsuri, $attr->prefix . ":" . $attr->name);
}
$attr2->value = $attr->value;
$newnode->appendChild($attr2);