#26815 [Opn->Csd]: foreach (DOM) childnodes causes error when using Xinclude
| From: | rrichards@php.net | Date: | Wed, 07 Jan 2004 15:31:05 +0000 |
| Subject: | #26815 [Opn->Csd]: foreach (DOM) childnodes causes error when using Xinclude | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-52936@lists.php.net to get a copy of this message | ||
ID: 26815
Updated by: rrichards@php.net
Reported By: bart at mediawave dot nl
-Status: Open
+Status: Closed
Bug Type: DOM XML related
Operating System: Windows 2000
PHP Version: 5.0.0b3 (beta3)
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2004-01-06 11:29:15] 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-06 11:26:09] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26815&edit=1