#39980 [Opn->Bgs]: PHP functions that read xml try to validate that the namespace uri exsist,wrong
ID: 39980
Updated by: rrichards@php.net
Reported By: hatkyinc at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Windows xp sp2
PHP Version: 5.2.0
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2006-12-28 19:48:38] hatkyinc at gmail dot com
Description:
------------
A lot of php functions that read xml try to validate that the uri
exsist, which is wrong by w3.org.
If the xmlns uri is not valid the functions don't work at all.
Functions tried:
SimpleXMLElement()
DOMDocument->loadHTMLFile()
I am opening this after opening a problem with w3.org which create the
problematic xml, they realied the fallowing:
http://www.w3.org/2005/10/markup-validator
is a namespace URI, and
there is no
requirement for it to actually point to anything - it's just an
identifier. If
something makes an assumption that it can retrieve anything at all from
a
namespace URI, it needs to be fixed not to assume that, let alone try
it
automatically.
http://www.w3.org/TR/xml-names/
http://www.rpbourret.com/xml/NamespacesFAQ.htm#q12_3
Reproduce code:
---------------
a.xml
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<m:markupvalidationresponse
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:m="http://www.w3.org/2005/10/soap-encoding">
<m:uri>http://www.microsoft.com/en/us/default.aspx</m:uri>
<m:checkedby>http://validator.w3.org/</m:checkedby>
<m:doctype>-//W3C//DTD HTML 4.0 Transitional//EN</m:doctype>
<m:charset>utf-8</m:charset>
<m:validity>false</m:validity>
<m:errors>
<m:errorcount>5</m:errorcount>
<m:errorlist>
<m:error>
<m:line>1</m:line>
<m:col>6012</m:col>
<m:message>there is no attribute
"TABINDEX"</m:message>
</m:error>
<m:error>
<m:line>1</m:line>
<m:col>6116</m:col>
<m:message>document type does not allow element
"DIV" here; missing one of "APPLET",
"OBJECT", "MAP", "IFRAME",
"BUTTON" start-tag</m:message>
</m:error>
<m:error>
<m:line>1</m:line>
<m:col>6154</m:col>
<m:message>document type does not allow element
"DIV" here; missing one of "APPLET",
"OBJECT", "MAP", "IFRAME",
"BUTTON" start-tag</m:message>
</m:error>
<m:error>
<m:line>1</m:line>
<m:col>9671</m:col>
<m:message>there is no attribute
"TABINDEX"</m:message>
</m:error>
<m:error>
<m:line>1</m:line>
<m:col>9744</m:col>
<m:message>there is no attribute
"ONFOCUS"</m:message>
</m:error>
</m:errorlist>
</m:errors>
<m:warnings>
<m:warningcount>0</m:warningcount>
<m:warninglist>
</m:warninglist>
</m:warnings>
</m:markupvalidationresponse>
</env:Body>
</env:Envelope>
$uri ='c:\a.xml';
$handle = fopen($uri, "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
//echo $contents;
$entries = new SimpleXMLElement($contents);
$result=
$entries->children('http://www.w3.org/2003/05/soap-envelope')->Body->children('http://www.w3.org/2003/05/soap-encoding')->markupvalidationresponse;
echo $result->uri ;
Expected result:
----------------
expected to put on screen
http://www.microsoft.com/en/us/default.aspx
Actual result:
--------------
Nothing is put on screen.
if you change a.xml line
<m:markupvalidationresponse
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:m="http://www.w3.org/2005/10/soap-encoding">
xmlns:m= uri to anything that validates this works
example
<m:markupvalidationresponse
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:m="http://www.w3.org/2003/05/soap-encoding">
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39980&edit=1
Thread (4 messages)