@@ -1447,33 +1447,13 @@ static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep
1447
1447
xmlDOMWrapReconcileNamespaces (& dummy_ctxt , nodep , /* options */ 0 );
1448
1448
}
1449
1449
1450
- static bool dom_must_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1451
- {
1452
- xmlNsPtr default_ns = xmlSearchNs (doc , nodep -> parent , NULL );
1453
- return default_ns != NULL && default_ns -> href != NULL && default_ns -> href [0 ] != '\0' ;
1454
- }
1455
-
1456
- static void dom_replace_namespace_by_empty_default (xmlDocPtr doc , xmlNodePtr nodep )
1457
- {
1458
- ZEND_ASSERT (nodep -> ns == NULL );
1459
- /* The node uses the default empty namespace, but the current default namespace is non-empty.
1460
- * We can't unconditionally do this because otherwise libxml2 creates an xmlns="" declaration.
1461
- * Note: there's no point searching the oldNs list, because we haven't found it in the tree anyway.
1462
- * Ideally this would be pre-allocated but unfortunately libxml2 doesn't offer such a functionality. */
1463
- xmlSetNs (nodep , xmlNewNs (nodep , (const xmlChar * ) "" , NULL ));
1464
- }
1465
-
1466
1450
void dom_reconcile_ns (xmlDocPtr doc , xmlNodePtr nodep ) /* {{{ */
1467
1451
{
1468
1452
/* Although the node type will be checked by the libxml2 API,
1469
1453
* we still want to do the internal reconciliation conditionally. */
1470
1454
if (nodep -> type == XML_ELEMENT_NODE ) {
1471
1455
dom_reconcile_ns_internal (doc , nodep , nodep -> parent );
1472
1456
dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1473
- /* Check nodep->ns first to avoid an expensive lookup. */
1474
- if (nodep -> ns == NULL && dom_must_replace_namespace_by_empty_default (doc , nodep )) {
1475
- dom_replace_namespace_by_empty_default (doc , nodep );
1476
- }
1477
1457
}
1478
1458
}
1479
1459
/* }}} */
@@ -1497,30 +1477,12 @@ static void dom_reconcile_ns_list_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlN
1497
1477
1498
1478
void dom_reconcile_ns_list (xmlDocPtr doc , xmlNodePtr nodep , xmlNodePtr last )
1499
1479
{
1500
- bool did_compute_must_replace_namespace_by_empty_default = false;
1501
- bool must_replace_namespace_by_empty_default = false;
1502
-
1503
1480
dom_reconcile_ns_list_internal (doc , nodep , last , nodep -> parent );
1504
-
1505
1481
/* The loop is outside of the recursion in the above call because
1506
1482
* dom_libxml_reconcile_ensure_namespaces_are_declared() performs its own recursion. */
1507
1483
while (true) {
1508
1484
/* The internal libxml2 call will already check the node type, no need for us to do it here. */
1509
1485
dom_libxml_reconcile_ensure_namespaces_are_declared (nodep );
1510
-
1511
- /* We don't have to handle the children, because if their ns's are NULL they'll just take on the default
1512
- * which should've been reconciled before. */
1513
- if (nodep -> ns == NULL ) {
1514
- /* This is an optimistic approach: we assume that most of the time we don't need the result of the computation. */
1515
- if (!did_compute_must_replace_namespace_by_empty_default ) {
1516
- did_compute_must_replace_namespace_by_empty_default = true;
1517
- must_replace_namespace_by_empty_default = dom_must_replace_namespace_by_empty_default (doc , nodep );
1518
- }
1519
- if (must_replace_namespace_by_empty_default ) {
1520
- dom_replace_namespace_by_empty_default (doc , nodep );
1521
- }
1522
- }
1523
-
1524
1486
if (nodep == last ) {
1525
1487
break ;
1526
1488
}
0 commit comments