@@ -1496,33 +1496,13 @@ static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep
14961496 xmlDOMWrapReconcileNamespaces (& dummy_ctxt , nodep , /* options */ 0 );
14971497}
14981498
1499- static bool dom_must_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1500- {
1501- xmlNsPtr default_ns = xmlSearchNs (doc , nodep -> parent , NULL );
1502- return default_ns != NULL && default_ns -> href != NULL && default_ns -> href [0 ] != '\0' ;
1503- }
1504-
1505- static void dom_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1506- {
1507- ZEND_ASSERT (nodep -> ns == NULL );
1508- /* The node uses the default empty namespace, but the current default namespace is non-empty.
1509- * We can't unconditionally do this because otherwise libxml2 creates an xmlns="" declaration.
1510- * Note: there's no point searching the oldNs list, because we haven't found it in the tree anyway.
1511- * Ideally this would be pre-allocated but unfortunately libxml2 doesn't offer such a functionality. */
1512- xmlSetNs (nodep , xmlNewNs (nodep , (const xmlChar * ) "" , NULL ));
1513- }
1514-
15151499void dom_reconcile_ns (xmlDocPtr doc , xmlNodePtr nodep ) /* {{{ */
15161500{
15171501 /* Although the node type will be checked by the libxml2 API,
15181502 * we still want to do the internal reconciliation conditionally. */
15191503 if (nodep -> type == XML_ELEMENT_NODE ) {
15201504 dom_reconcile_ns_internal (doc , nodep , nodep -> parent );
15211505 dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1522- /* Check nodep->ns first to avoid an expensive lookup. */
1523- if (nodep -> ns == NULL && dom_must_replace_namespace_by_empty_default (doc , nodep )) {
1524- dom_replace_namespace_by_empty_default (doc , nodep );
1525- }
15261506 }
15271507}
15281508/* }}} */
@@ -1546,30 +1526,12 @@ static void dom_reconcile_ns_list_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlN
15461526
15471527void dom_reconcile_ns_list (xmlDocPtr doc , xmlNodePtr nodep , xmlNodePtr last )
15481528{
1549- bool did_compute_must_replace_namespace_by_empty_default = false;
1550- bool must_replace_namespace_by_empty_default = false;
1551-
15521529 dom_reconcile_ns_list_internal (doc , nodep , last , nodep -> parent );
1553-
15541530 /* The loop is outside of the recursion in the above call because
15551531 * dom_libxml_reconcile_ensure_namespaces_are_declared() performs its own recursion. */
15561532 while (true) {
15571533 /* The internal libxml2 call will already check the node type, no need for us to do it here. */
15581534 dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1559-
1560- /* We don't have to handle the children, because if their ns's are NULL they'll just take on the default
1561- * which should've been reconciled before. */
1562- if (nodep -> ns == NULL ) {
1563- /* This is an optimistic approach: we assume that most of the time we don't need the result of the computation. */
1564- if (!did_compute_must_replace_namespace_by_empty_default ) {
1565- did_compute_must_replace_namespace_by_empty_default = true;
1566- must_replace_namespace_by_empty_default = dom_must_replace_namespace_by_empty_default (doc , nodep );
1567- }
1568- if (must_replace_namespace_by_empty_default ) {
1569- dom_replace_namespace_by_empty_default (doc , nodep );
1570- }
1571- }
1572-
15731535 if (nodep == last ) {
15741536 break ;
15751537 }
0 commit comments