Bug #65375 [Opn->Nab]: DOMXPath query registerNodeNS produces unexpected behavior

From: Date: Mon, 02 Dec 2013 17:20:11 +0000
Subject: Bug #65375 [Opn->Nab]: DOMXPath query registerNodeNS produces unexpected behavior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183073@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65375&edit=1 ID: 65375 Updated by: mike@php.net Reported by: goetas at lignano dot it Summary: DOMXPath query registerNodeNS produces unexpected behavior -Status: Open +Status: Not a bug Type: Bug Package: DOM XML related Operating System: ubuntu 12.04 PHP Version: 5.4.17 Block user comment: N Private report: N New Comment: If register_node_ns==true then the namespaces of the context node are used. If the context node is not given, the document's root node is used. Previous Comments: ------------------------------------------------------------------------ [2013-08-02 07:12:48] goetas at lignano dot it Description: ------------ registerNodeNS option (default to true) added with php 5.3.3 produces unexpected behavior and BC issue. $registerNodeNS = true seems to remove (overwrite) registered namespaces with DOMXPath::registerNamespace() method, Similar problem has been reported with #55700 Test script: --------------- <?php $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' <ns1:tag xmlns:ns1="http://my.com/ns1" xmlns:ns2="http://my.com/ns2"> <ns1:tag-2/> <ns2:extra/> </ns1:tag>'); $xpath = new DOMXPath($dom); $xpath->registerNamespace("ns2", "http://my.com/ns1"); echo $xpath->query("//ns2:tag-2", null, false)->length."\n"; echo $xpath->query("//ns2:tag-2", null, true)->length,"\n"; /* * registerNodeNS option should skip prefix registration if * same prefix is already registered with registerNamespace() method. */ Expected result: ---------------- 1 1 Actual result: -------------- 1 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65375&edit=1

« previous php.bugs (#183073) next »