|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-01-08 13:01 UTC] cmv@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
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 < '.$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 < $counter])"/>] <xsl:if test="$counter < 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>