ID:               41257
 Updated by:       [EMAIL PROTECTED]
 Reported By:      daniel dot oconnor at gmail dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         DOM XML related
 Operating System: Windows, Linux
 PHP Version:      5.2.1
-Assigned To:      
+Assigned To:      rrichards


Previous Comments:
------------------------------------------------------------------------

[2007-05-02 07:37:18] daniel dot oconnor at gmail dot com

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">&lt; &lt; func_image(photograph)
&gt; &gt;</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 this bug report at http://bugs.php.net/?id=41257&edit=1

Reply via email to