@@ -1497,33 +1497,13 @@ static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep
1497
1497
xmlDOMWrapReconcileNamespaces (& dummy_ctxt , nodep , /* options */ 0 );
1498
1498
}
1499
1499
1500
- static bool dom_must_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1501
- {
1502
- xmlNsPtr default_ns = xmlSearchNs (doc , nodep -> parent , NULL );
1503
- return default_ns != NULL && default_ns -> href != NULL && default_ns -> href [0 ] != '\0' ;
1504
- }
1505
-
1506
- static void dom_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1507
- {
1508
- ZEND_ASSERT (nodep -> ns == NULL );
1509
- /* The node uses the default empty namespace, but the current default namespace is non-empty.
1510
- * We can't unconditionally do this because otherwise libxml2 creates an xmlns="" declaration.
1511
- * Note: there's no point searching the oldNs list, because we haven't found it in the tree anyway.
1512
- * Ideally this would be pre-allocated but unfortunately libxml2 doesn't offer such a functionality. */
1513
- xmlSetNs (nodep , xmlNewNs (nodep , (const xmlChar * ) "" , NULL ));
1514
- }
1515
-
1516
1500
void dom_reconcile_ns (xmlDocPtr doc , xmlNodePtr nodep ) /* {{{ */
1517
1501
{
1518
1502
/* Although the node type will be checked by the libxml2 API,
1519
1503
* we still want to do the internal reconciliation conditionally. */
1520
1504
if (nodep -> type == XML_ELEMENT_NODE ) {
1521
1505
dom_reconcile_ns_internal (doc , nodep , nodep -> parent );
1522
1506
dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1523
- /* Check nodep->ns first to avoid an expensive lookup. */
1524
- if (nodep -> ns == NULL && dom_must_replace_namespace_by_empty_default (doc , nodep )) {
1525
- dom_replace_namespace_by_empty_default (doc , nodep );
1526
- }
1527
1507
}
1528
1508
}
1529
1509
/* }}} */
@@ -1547,30 +1527,12 @@ static void dom_reconcile_ns_list_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlN
1547
1527
1548
1528
void dom_reconcile_ns_list (xmlDocPtr doc , xmlNodePtr nodep , xmlNodePtr last )
1549
1529
{
1550
- bool did_compute_must_replace_namespace_by_empty_default = false;
1551
- bool must_replace_namespace_by_empty_default = false;
1552
-
1553
1530
dom_reconcile_ns_list_internal (doc , nodep , last , nodep -> parent );
1554
-
1555
1531
/* The loop is outside of the recursion in the above call because
1556
1532
* dom_libxml_reconcile_ensure_namespaces_are_declared() performs its own recursion. */
1557
1533
while (true) {
1558
1534
/* The internal libxml2 call will already check the node type, no need for us to do it here. */
1559
1535
dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1560
-
1561
- /* We don't have to handle the children, because if their ns's are NULL they'll just take on the default
1562
- * which should've been reconciled before. */
1563
- if (nodep -> ns == NULL ) {
1564
- /* This is an optimistic approach: we assume that most of the time we don't need the result of the computation. */
1565
- if (!did_compute_must_replace_namespace_by_empty_default ) {
1566
- did_compute_must_replace_namespace_by_empty_default = true;
1567
- must_replace_namespace_by_empty_default = dom_must_replace_namespace_by_empty_default (doc , nodep );
1568
- }
1569
- if (must_replace_namespace_by_empty_default ) {
1570
- dom_replace_namespace_by_empty_default (doc , nodep );
1571
- }
1572
- }
1573
-
1574
1536
if (nodep == last ) {
1575
1537
break ;
1576
1538
}
0 commit comments