From: bart at mediawave dot nl
Operating system: Windows 2000
PHP version: 5.0.0b3 (beta3)
PHP Bug Type: DOM XML related
Bug description: foreach (DOM) childnodes causes error when using Xinclude
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 bug report at http://bugs.php.net/?id=26815&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26815&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26815&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26815&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26815&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26815&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26815&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26815&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26815&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26815&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26815&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26815&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26815&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26815&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26815&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26815&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26815&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26815&r=float