#41257 [NEW]: lookupPrefix, lookupNamespaceURI do not work as expected
| From: | daniel dot oconnor at gmail dot com | Date: | Wed, 02 May 2007 07:37:18 +0000 |
| Subject: | #41257 [NEW]: lookupPrefix, lookupNamespaceURI do not work as expected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112158@lists.php.net to get a copy of this message | ||
From: daniel dot oconnor at gmail dot com
Operating system: Windows, Linux
PHP version: 5.2.1
PHP Bug Type: *General Issues
Bug description: lookupPrefix, lookupNamespaceURI do not work as expected
Description:
------------
DOMDocument should extend DOMNode
(http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document), and should be
able to find any xmlns defined in the top level element.
Currently, DOMDocument->lookupPrefix() and
DOMDocument->lookupNamespaceURI() will never return any values other than
null; or warn developers they are using the wrong method.
Additionally, DOMDocument->lookupPrefix & friends should be able to
recognise xmlns defined in the root node of a document.
Reproduce code:
---------------
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<office:document-content office:class="text" office:version="1.0"
xmlns:chart="http://openoffice.org/2000/chart"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dom="http://www.w3.org/2001/xml-events"
xmlns:dr3d="http://openoffice.org/2000/dr3d"
xmlns:draw="http://openoffice.org/2000/drawing"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:form="http://openoffice.org/2000/form"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns:meta="http://openoffice.org/2000/meta"
xmlns:number="http://openoffice.org/2000/datastyle"
xmlns:office="http://openoffice.org/2000/office"
xmlns:ooo="http://openoffice.org/2004/office"
xmlns:oooc="http://openoffice.org/2004/calc"
xmlns:ooow="http://openoffice.org/2004/writer"
xmlns:script="http://openoffice.org/2000/script"
xmlns:style="http://openoffice.org/2000/style"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:table="http://openoffice.org/2000/table"
xmlns:text="http://openoffice.org/2000/text"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<office:body>
<table:table table:name="Table13" table:style-name="Table13">
<table:table-column table:style-name="Table13.A" />
<table:table-row table:style-name="Table13.1">
<table:table-cell table:style-name="Table13.A1"
table:value-type="string">
<text:p text:style-name="P84">Important Notes and
Qualifications</text:p>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="P88">< < func_image(photograph)
> ></text:p>
</office:body>
</office:document-content>';
$document = new DOMDocument('1.0', 'UTF-8');
$document->loadXML($xml);
foreach
($document->getElementsByTagNameNS('http://openoffice.org/2000/table',
'table') as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
print "\n\n";
foreach ($document->getElementsByTagName('*') as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
print "\n\n";
foreach ($document->getElementsByTagNameNS('*', '*') as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
print "\n\n";
foreach
($document->getElementsByTagNameNS('http://openoffice.org/2000/table',
'*')
as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
print "\n\n";
foreach
($document->getElementsByTagNameNS('http://openoffice.org/2000/table',
'*')
as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
print "\n\n";
foreach
($document->getElementsByTagNameNS('http://openoffice.org/2000/table',
'table') as $element) {
echo 'local name: ', $element->localName, ', prefix: ',
$element->prefix, ' xmlns (element):',
$element->lookupNamespaceURI($element->prefix), ' xmlns (document):',
$document->lookupNamespaceURI($element->prefix), "\n";
}
Expected result:
----------------
$document->lookupNamespaceURI() and $element->lookupNamespaceURI() should
return identical results.
Actual result:
--------------
local name: table, prefix: table xmlns
(element):http://openoffice.org/2000/table xmlns
(document):
--
Edit bug report at http://bugs.php.net/?id=41257&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41257&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41257&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41257&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41257&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41257&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41257&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41257&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41257&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41257&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41257&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41257&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41257&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41257&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41257&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41257&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41257&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41257&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41257&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41257&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41257&r=mysqlcfg