#42026 [Fbk->Bgs]: Incorrect handling of default namespaces
| From: | rrichards@php.net | Date: | Wed, 18 Jul 2007 11:59:18 +0000 |
| Subject: | #42026 [Fbk->Bgs]: Incorrect handling of default namespaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115175@lists.php.net to get a copy of this message | ||
ID: 42026
Updated by: rrichards@php.net
Reported By: mail_ben_schmidt at yahoo dot com dot au
-Status: Feedback
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Mac OS X
PHP Version: 5.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Works as it should. Not specifying a namespace returns un-prefixed
elements (no or default namespace), as no namespace testing is performed
other than checking for no prefix. There is no default namespace for
attributes.
Previous Comments:
------------------------------------------------------------------------
[2007-07-18 11:12:26] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Some fixes were already done regarding namespaces.
------------------------------------------------------------------------
[2007-07-18 11:12:22] mail_ben_schmidt at yahoo dot com dot au
Irrelevant to the bug itself, but one of my numbers that were meant to
be helpful in the code example was wrong. Should have read:
<other:elem attr="abc"/>1
<other:elem ns:attr="abc"/>0
<other:elem other:attr="abc"/>1
------------------------------------------------------------------------
[2007-07-18 11:09:01] mail_ben_schmidt at yahoo dot com dot au
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 this bug report at http://bugs.php.net/?id=42026&edit=1