Req #55700 [Opn]: Disable automatic registration on a DOMXpath object.
| From: | pajoye@php.net | Date: | Thu, 15 Sep 2011 12:19:52 +0000 |
| Subject: | Req #55700 [Opn]: Disable automatic registration on a DOMXpath object. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163560@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55700&edit=1
ID: 55700
Updated by: pajoye@php.net
Reported by: thomas at weinert dot info
Summary: Disable automatic registration on a DOMXpath object.
Status: Open
Type: Feature/Change Request
Package: DOM XML related
PHP Version: 5.3.8
-Assigned To:
+Assigned To: rrichards
Block user comment: N
Private report: N
New Comment:
hi Rob!
Can you take a look pls? Afaict it is not BC but this behavior never really works
:)
Previous Comments:
------------------------------------------------------------------------
[2011-09-15 11:16:33] thomas at weinert dot info
Description:
------------
DOMXpath currently registers namespaces of the current context or the document element
automatically. This results in broken and inconsistent results (Bug #49490). An argument has been
added to evaluate() and query() to change this behavior. The current situation is that the argument
and the context argument has ALWAYS to be used to have predictable results.
A better way would be an option on the DOMXpath object.
An option would not only mean less code, it will also allow to just change one part (initialization
of ones DOMXpath instance), without the need to modify all occurrences evaluate()/query() in
existing source.
Test script:
---------------
<?php
$dom = new DOMDocument();
$dom->loadXML(
'<foobar><a:foo xmlns:a="urn:a">'.
'<b:bar xmlns:b="urn:b"/></a:foo>'.
'</foobar>'
);
$xpath = new DOMXPath($dom);
// disable automatic namespace registration
$xpath->enableRegisterNodeNS = FALSE;
$context = $dom->documentElement->firstChild;
$xpath->registerNamespace('a', 'urn:b');
var_dump(
$xpath->evaluate(
'descendant-or-self::a:*',
$context
)->item(0)->tagName
);
?>
Expected result:
----------------
string(5) "b:bar"
Actual result:
--------------
string(5) "a:foo"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55700&edit=1