From:             info at adaniels dot nl
Operating system: Linux
PHP version:      5CVS-2007-05-31 (CVS)
PHP Bug Type:     DOM XML related
Bug description:  getElementById doesn't work after a schemaValidate

Description:
------------
Note that this is about the DOM extension, not DOM XML.

After using schemaValidate on a DOMDocument, the ID attributes should be
marked, so getElementById() should work. This used to work in PHP 5.1.x,
but is broken in current versions.

Reproduce code:
---------------
<?php
    $xml = <<<XML
<root>
  <item id="abc" />
  <item id="def" />
  <item id="xyz" />
</root>
XML;

    $schema = <<<XML
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; >
        <xs:element name="root">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="item" type="item" 
maxOccurs="unbounded"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        
        <xs:complexType name="item">
                <xs:attribute name="id" use="required" type="xs:ID"/>
        </xs:complexType>
</xs:schema>
XML;

        $dom = new DOMDocument();
        $dom->loadXML($xml);
        if (!$dom->schemaValidateSource($schema)) trigger_error("Validation
failed", E_USER_ERROR);

    $node = $dom->getElementById('def');
    echo $node ? 'Node found' : 'Where is it?';
?>

Expected result:
----------------
Node found

Actual result:
--------------
Where is it?

-- 
Edit bug report at http://bugs.php.net/?id=41550&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41550&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41550&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41550&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41550&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41550&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41550&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41550&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41550&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41550&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41550&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41550&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41550&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41550&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41550&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41550&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41550&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41550&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41550&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41550&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41550&r=mysqlcfg

Reply via email to