question on performance with php5/xml/xslt streams IO

From: Date: Fri, 07 May 2004 16:32:25 +0000
Subject: question on performance with php5/xml/xslt streams IO
Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-371@lists.php.net to get a copy of this message
I have an xsl stylesheet that merges the content of multiple remotely located xml files into a single xml file. An xml doc passed to a stylesheet contains the URI for each source file, as in: <files> <file>http://www.somewhere.com/file1.xml</file> ... <file>http://www.somewhere.com/file12.xml</file> </files> The xsl stylesheet grabs each remote file URI from the xml passed to it in a for-each loop, then does it stuff with each, as in: <xsl:for-each select="//file"> <xsl:variable name="file" select="document(text())" /> ... do stuff here </xsl:for-each> Each remote xml source file that gets fetched with the "select=document()..." expression is in fact quite small (a single, one-line element) but processing takes FOREVER when doing it with PHP5, as in: $xsl = new domDocument(); $xsl->load('mystylesheet.xsl'); $xml = new domDocument(); $xml->load('mysource.xml'); $xslt = new XsltProcessor(); $xslt->importStylesheet($xsl); print $xslt->transformToXml($xmlDom); If I do this transform with xsltproc on the command line, the whole thing is done in just over 2 seconds (an eyeballed figure, yes, but...). If I do this transfom in PHP5 as above, it takes over 20 seconds to complete. The latency with streams and remote URI sources is so pronounced that I'm using: $transformResult = shell_exec('xsltproc mystylesheet.xsl mysource.xml'); ...instead of the PHP5 dom/xslt functions to get acceptable performance in a production script. I'm puzzled as to how I should understand this, and what I could be doing differently. It seems to me that it's a performance issue related to PHP5 and streams, and not to dom or xslt functions. Or is there something going on in the PHP5 dom/xml/xslt side that is not going on in xsltproc that I need to understand and can do something about? Sorry for long-windedness, trying to be throrough in describing things. Thanks in advance for any response. -- Bill Hoffman xbhoff@pacbell.net from phpinfo(): PHP Version => 5.0.0RC2 Registered PHP Streams => php, file, ftp, gopher, telnet, dict, ldap, http, https, ftps, compress.zlib CURL support => enabled ( * config --with-curlwrappers) CURL Information => libcurl/7.11.0 OpenSSL/0.9.7b ipv6 zlib/1.1.4 DOM/XML => enabled DOM/XML API Version => 20031129 libxml Version => 2.6.8 HTML Support => enabled XPath Support => enabled XPointer Support => enabled Schema Support => enabled RelaxNG Support => enabled libXML support => active libXML Version => 2.6.8 libXML streams => enabled XML Support => active XML Namespace Support => active libxml2 Version => 2.6.8 XSL => enabled libxslt Version => 1.1.6 libxslt compiled against libxml Version => 2.6.8 EXSLT => enabled libexslt Version => 1.1.6

« previous php.xml.dev (#371) next »