#18197 [Ana->Csd]: DOMXML module have invalid handling of namespaces
| From: | chregu@php.net | Date: | Wed, 14 Aug 2002 14:28:27 +0000 |
| Subject: | #18197 [Ana->Csd]: DOMXML module have invalid handling of namespaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-16771@lists.php.net to get a copy of this message | ||
ID: 18197
Updated by: chregu@php.net
Reported By: flying@dom.natm.ru
-Status: Analyzed
+Status: Closed
Bug Type: DOM XML related
Operating System: Any
PHP Version: 4.2.1
New Comment:
Fixed in CVS
Log Message:
- Added some namespace support with DomNode->add_namespace(uri, prefix)
and DomDocument->create_element_ns(uri, nodename)
Therefore you have to use create_element_ns, if you want to add
elements with namespace (W3C spec) and maybe declare the namespace
before with add_namespace() on some parent node (no w3c spec :).
your example should work with the following:
$child =
$root->add_child($xml->create_element_ns('http://www.m.com/','child'));
chregu
Previous Comments:
------------------------------------------------------------------------
[2002-08-14 05:16:08] chregu@php.net
it looks like domxml can't create nodes with namespaces right now.
for creating nodes with namespaces, there is the DOM spec method
createElementNS(namespaceURI,name), i will implement this soon.
chregu
------------------------------------------------------------------------
[2002-07-06 06:11:20] flying@dom.natm.ru
DOM XML module handle XML namespaces in a wrong way. Take a look at a
simple example:
<?php
$xml = xmldoc('<?xml version="1.0"?><root
xmlns:m="http://www.m.com/"/>');
$root = $xml->root();
$child = $root->add_child($xml->create_element('m:child'));
echo 'Namespace prefix: '.$child->prefix().'<br>';
echo 'Node name: '.$child->tagname().'<br>';
?>
It is obvious, that result should be:
Namespace prefix: m
Node name: child
But instead we have:
Namespace prefix:
Node name: m:child
Moreover, it is even possible to create nodes with undeclared
namespaces, like:
$child = $root->add_child($xml->create_element('q:child'));
and it will not return any errors. But XML document itself will be
invalid after it, because of undeclared namespace.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18197&edit=1