php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26815 foreach (DOM) childnodes causes error when using Xinclude
Submitted: 2004-01-06 11:26 UTC Modified: 2004-01-07 10:31 UTC
From: bart at mediawave dot nl Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.0.0b3 (beta3) OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bart at mediawave dot nl
New email:
PHP Version: OS:

 

 [2004-01-06 11:26 UTC] bart at mediawave dot nl
Description:
------------
I used the Xinclude PHP5 example from Bitflux. Then when I tried to iterate through the resulting DOM object I got an access violation.

Reproduce code:
---------------
<?
class VariableStream {
    var $position;
    var $varname;
    function stream_open($path, $mode, $options, &$opened_path) {
        $url = parse_url($path);
        $this->varname = $url["host"];
        $this->position = 0;
        return true;
    }
    function stream_read($count) {
        $ret = substr($GLOBALS[$this->varname], $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }
    function stream_eof() {
        return $this->position >= strlen($GLOBALS[$this->varname]);
    }
    function url_stat() {
        return array();
    }
}

$xmlstring = '<?xml version="1.0"?>
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="var://bar#xpointer(/foo/bar)"/>
</foo>';

stream_wrapper_register("var", "VariableStream");

$bar = '<foo><bar>hello world</bar></foo>';
$dom = new domdocument;
$dom->loadXML($xmlstring);
$dom->xinclude();

print nl2br(htmlspecialchars($dom->saveXML()));

foreach ($dom->documentElement->childNodes AS $node) {
	echo '<br>';
	echo $node->nodeName;
	echo ' - ';
	echo $node->nodeValue;
}
?>

Expected result:
----------------
<?xml version="1.0"?>
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="var://bar#xpointer(/foo/bar)"/>
</foo>

#text - 
bar - hello world
#text - 

Actual result:
--------------
<?xml version="1.0"?>
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<bar xml:base="var://bar">hello world</bar>
</foo>

#text - 
Warning: main() [function.main]: Unsupported node type: 19 in E:\projects\projects\^General\Wrapper\wrap_v5\domtest.php on line 44

- PHP has encountered an Access Violation at 018BC3B2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-06 11:29 UTC] bart at mediawave dot nl
Oops: Expected result should be:

<?xml version="1.0"?>
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<bar xml:base="var://bar">hello world</bar>
</foo>

#text - 
bar - hello world
#text -
 [2004-01-07 10:31 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC