diff options
Diffstat (limited to 'ext/dom/node.c')
-rw-r--r-- | ext/dom/node.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/ext/dom/node.c b/ext/dom/node.c index 03e64c1897..6363e30f03 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -178,15 +178,29 @@ const zend_function_entry php_dom_node_class_functions[] = { /* {{{ */ static void dom_reconcile_ns(xmlDocPtr doc, xmlNodePtr nodep) /* {{{ */ { - xmlNsPtr nsptr; + xmlNsPtr nsptr, nsdftptr, curns, prevns = NULL; if (nodep->type == XML_ELEMENT_NODE) { /* Following if block primarily used for inserting nodes created via createElementNS */ - if (nodep->nsDef != NULL && nodep->nsDef->href != NULL) { - if((nsptr = xmlSearchNsByHref(doc, nodep->parent, nodep->nsDef->href)) && - (nodep->nsDef->prefix == NULL || xmlStrEqual(nsptr->prefix, nodep->nsDef->prefix))) { - dom_set_old_ns(doc, nodep->nsDef); - nodep->nsDef = NULL; + if (nodep->nsDef != NULL) { + curns = nodep->nsDef; + while (curns) { + nsdftptr = curns->next; + if (curns->href != NULL) { + if((nsptr = xmlSearchNsByHref(doc, nodep->parent, curns->href)) && + (curns->prefix == NULL || xmlStrEqual(nsptr->prefix, curns->prefix))) { + curns->next = NULL; + if (prevns == NULL) { + nodep->nsDef = nsdftptr; + } else { + prevns->next = nsdftptr; + } + dom_set_old_ns(doc, curns); + curns = prevns; + } + } + prevns = curns; + curns = nsdftptr; } } xmlReconciliateNs(doc, nodep); |