Bug #53181 [Com]: XPath bugs when selecting attributes with namespace
| From: | ivan dot enderlin at hoa-project dot net | Date: | Mon, 06 Dec 2010 10:06:20 +0000 |
| Subject: | Bug #53181 [Com]: XPath bugs when selecting attributes with namespace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156785@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53181&edit=1
ID: 53181
Comment by: ivan dot enderlin at hoa-project dot net
Reported by: ivan dot enderlin at hoa-project dot net
Summary: XPath bugs when selecting attributes with namespace
Status: Bogus
Type: Bug
Package: *XML functions
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Some news about libxml2 developers?
Previous Comments:
------------------------------------------------------------------------
[2010-10-27 12:10:37] pajoye@php.net
That's an issue in libxml2. PHP uses libxml2, but we don't develop it.
No need to duplicate the entry.
Will ping one of the dev to see what's going on there.
------------------------------------------------------------------------
[2010-10-27 11:54:46] ivan dot enderlin at hoa-project dot net
Description:
------------
XPath (and possibly libxml2) has a bug when selecting attributes with a
namespace. We must use the namespace-uri() function to solve this
problem whereas using a registered prefix does not work.
A bug has been reported to Gnome in 2008:
<https://bugzilla.gnome.org/show_bug.cgi?id=562557>
but it's still
opened and not resolved.
Test script:
---------------
<?php
$xml = '<?xml version="1.0" encoding="utf-8"?>' .
"\n\n" .
'<foo xmlns="http://ns1" xmlns:x="http://ns2">' . "\n" .
' <bar a="b" x:c="d" e="f" g="h" />'
. "\n" .
'</foo>';
$sxe = simplexml_load_string($xml);
$sxe->registerXPathNamespace('', 'http://ns1');
$sxe->registerXPathNamespace('x', 'http://ns2');
echo $xml . "\n\n" .
'â //@* found(' .
count($sxe->xpath('//@*')) . ')' . "\n" .
'â //@x:* (x registered as http://ns2) found(' .
count($sxe->xpath('//@x:*')) . ')' . "\n" .
'â //@*[namespace-uri() = "http://ns2"]
found(' .
count($sxe->xpath('//@*[namespace-uri() = "http://ns2"]')) . ')' .
"\n";
Expected result:
----------------
<?xml version="1.0" encoding="utf-8"?>
<foo xmlns="http://ns1" xmlns:x="http://ns2">
<bar a="b" x:c="d" e="f" g="h" />
</foo>
â //@* found(4)
â //@x:* (x registered as http://ns2) found(1)
â //@*[namespace-uri() = "http://ns2"] found(1)
Actual result:
--------------
<?xml version="1.0" encoding="utf-8"?>
<foo xmlns="http://ns1" xmlns:x="http://ns2">
<bar a="b" x:c="d" e="f" g="h" />
</foo>
â //@* found(4)
â //@x:* (x registered as http://ns2) found(4)
â //@*[namespace-uri() = "http://ns2"] found(1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53181&edit=1