#42026 [NEW]: Incorrect handling of default namespaces
From: mail_ben_schmidt at yahoo dot com dot au
Operating system: Mac OS X
PHP version: 5.2.3
PHP Bug Type: SimpleXML related
Bug description: Incorrect handling of default namespaces
Description:
------------
When getting children/attributes without using methods to specify a
namespace explicity, non-prefixed names are returned, but not prefixed
ones, even if the prefixed names are in the same namespace.
(Note that in fixing this bug there is a subtlety: the default namespace
for attributes is inherited from the element in which they appear.)
Reproduce code:
---------------
$str=<<<DONE
<?xml version="1.0" encoding="utf-8"?>
<root
xmlns="http://localhost/a"
xmlns:ns="http://localhost/a"
xmlns:other="http://localhost/b"
>
<elem attr="abc"/>1
<elem ns:attr="abc"/>1
<elem other:attr="abc"/>0
<ns:elem attr="abc"/>1
<ns:elem ns:attr="abc"/>1
<ns:elem other:attr="abc"/>0
<other:elem attr="abc"/>0
<other:elem ns:attr="abc"/>0
<other:elem other:attr="abc"/>1
</root>
DONE;
$xml = simplexml_load_string($str);
foreach ($xml->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
foreach ($xml->children('http://localhost/a')->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
foreach ($xml->children('http://localhost/b')->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
Expected result:
----------------
110110 110110 101
Actual result:
--------------
100 100100 100
--
Edit bug report at http://bugs.php.net/?id=42026&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42026&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42026&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42026&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42026&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42026&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42026&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42026&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42026&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42026&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42026&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42026&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42026&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42026&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42026&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42026&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42026&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42026&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42026&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42026&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42026&r=mysqlcfg
Thread (10 messages)
- mail_ben_schmidt at yahoo dot com dot au