php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19333 incorrect handling of xml namespace
Submitted: 2002-09-10 09:05 UTC Modified: 2002-09-10 23:59 UTC
From: pavlomr at hotmail dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4CVS-2002-09-10 OS: SuSE Linux 7.3
Private report: No CVE-ID: None
 [2002-09-10 09:05 UTC] pavlomr at hotmail dot com
environment as in #19266
example:
<?php
$x1="<?xml version='1.0' encoding='iso8859-1' ?>
<root1 xml:lang='de' xmlns:xml='http://www.w3.org/XML/1998/namespace'>
<node xml:lang='en'>1 En node</node>
<node xml:lang='de'>1 De node</node>
<node>1 Default node</node>
</root1>
";
$x2="<?xml version='1.0' encoding='iso8859-1' ?>
<root2 xml:lang='en'  xmlns:xml='http://www.w3.org/XML/1998/namespace'>
<node xml:lang='en'>2 En node</node>
<node xml:lang='de'>2 De node</node>
<node> 2 Default node</node>
</root2>
";
$d1=domxml_open_mem($x1);
$d2=domxml_open_mem($x2);

$r1=$d1->document_element();
$r2=$d2->document_element();
$r1->append_child($r2->clone_node(1));

echo $d1->dump_mem();

?>

produce:
<?xml version="1.0" encoding="iso8859-1"?>
<root1 xml:lang="de">
<node xml:lang="en">1 En node</node>
<node xml:lang="de">1 De node</node>
<node>1 Default node</node>
<root2 lang="en">
<node lang="en">2 En node</node>
<node lang="de">2 De node</node>
<node> 2 Default node</node>
</root2></root1>
------------------------------------
xml prefix of xml:lang is lost !
it's independent from xmlns declaration.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-10 11:29 UTC] chregu@php.net
Hi

The Namespace xml is defined per default and does not have to be declared explicitely.

If the parser does not understand this, then it's its fault and it does not correpsond to the w3c-specs.

chregu
 [2002-09-10 12:28 UTC] pavlomr at hotmail dot com
It is strange , that in previous snapshot (4CVS-2002-09-06) output was correct (but segfaults).
And $d2->dump_mem() produce correct output.
 [2002-09-10 23:59 UTC] chregu@php.net
Nevertheless it's ok, what domxml (resp. libxml2) does. 
If you take another namespase than xmlns:xml='http://www.w3.org/XML/1998/namespace', you'll see that it will be perfectly preserved. 

The "xml" namespace does not have to be declared, as it's always associated to 'http://www.w3.org/XML/1998/namespace' per default.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC