#41550 [Opn->Asn]: getElementById doesn't work after a schemaValidate

From: Date: Thu, 31 May 2007 21:33:57 +0000
Subject: #41550 [Opn->Asn]: getElementById doesn't work after a schemaValidate
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113245@lists.php.net to get a copy of this message
ID: 41550 Updated by: tony2001@php.net Reported By: info at adaniels dot nl -Status: Open +Status: Assigned Bug Type: DOM XML related Operating System: Linux PHP Version: 5CVS-2007-05-31 (CVS) -Assigned To: +Assigned To: rrichards Previous Comments: ------------------------------------------------------------------------ [2007-05-31 15:17:02] info at adaniels dot nl 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 this bug report at http://bugs.php.net/?id=41550&edit=1

« previous php.bugs (#113245) next »