From:             [EMAIL PROTECTED]
Operating system: Windows 2000
PHP version:      4.0.6
PHP Bug Type:     DOM XML related
Bug description:  DOM XML hangs while trying to execute a lot of XPath expressions

Environment:
 - Windows 2000 Server (SP2)
 - Apache 1.3.22
 - PHP 4.0.6 (windows binaries from www.php.net) running as CGI

 Here is a small test case: 

test.xml:
=========
<?xml version="1.0"?>
<root>
    <node>
        <child id="1"/>
        <child id="2"/>
        <child id="3"/>
    </node>
</root>

test.php
========
<?php
$xml = xmldoc(join('',file('test.xml')));
$xml->xpath_init();
$ctx = xpath_new_context($xml);
for ($i=0;$i<100;$i++)
{
    echo $i."<br>";
    $nodes = xpath_eval($ctx,'count(//child[@id &lt; '.$i.'])');
};
?>

 As you can see, this code just tries to execute 100 XPath expressions for
the same DOM XML object. And it hangs after ~12 iterations.

 This bug available only on Windows, this test case works well on Linux.

 It also seems to not work properly in PHP 4.1.0.

 Also this expression seems to be evaluated wrong, because it returns
'false' value instead of number of nodes. Here is small XSLT template,
which generates correct results:

test.xsl
========
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="text"/>

<xsl:template name="loop">
    <xsl:param name="counter">1</xsl:param>
    [<xsl:value-of select="$counter"/> - <xsl:value-of
select="count(//child[@id &lt; $counter])"/>]
    <xsl:if test="$counter &lt; 100">
        <xsl:call-template name="loop"><xsl:with-param name="counter"
select="$counter + 1"/></xsl:call-template>
    </xsl:if>
</xsl:template>

<xsl:template match="/">
    <xsl:call-template name="loop"/>
</xsl:template>

</xsl:stylesheet>


-- 
Edit bug report at: http://bugs.php.net/?id=14884&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to