Re: Re: speed up xslt

From: Date: Thu, 28 May 2009 05:27:49 +0000
Subject: Re: Re: speed up xslt
References: 1 2 3  Groups: php.xml.dev 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

On 28.5.2009 0:21 Uhr, flopin wrote:
> I am just trying to do the same thing...
>
> I my case, the problem is not with the
>
> DomDocument::load(..)
>
> function itself, but with
>
> XsltProcessor::importStylesheet(DomDocument xslt);
>
> which takes too much time since my stylesheets are quite complex (but
> they are not changed very often). This function (correct me if iam
> wrong, dont know exactly how it works) creates some sort of "xslt
> bytecode", which is then executed along with some xml document in
>
> XsltProcessor::transformToDoc/Uri/XML(DomDocument xml);
>
> So, the idea would be to somehow save the XsltProcessor object (and the
> compiled xsl stylesheets), after it parses the input xslt.
> So far, i have tried PHP's serialize/unserialize as well as storing the
> object in memcached, but this approach does not seem to be possible or
> iam doing something wrong


You can't serialize imported/compiled stylesheets, there's no real way
to do it. The NYT xslcache is the only known way to me to make something
like that work.

> The http://code.nytimes.com/projects/xslcache looks
> promising, but i am
> unable to make it work. When i install it and run php, i get
> 
> PHP Warning:  PHP Startup: Unable to load dynamic library
> '/usr/lib/php5/20060613/xslcache.so' -
> /usr/lib/php5/20060613/xslcache.so: undefined symbol:
> xsltGenericErrorContext in Unknown on line 0

Works for me with php 5.2.9 (but not 5.3). It looks like it doesn't link
against libxslt.so. Does the normal xsl extension work? They should be
able to run in parallel.

And about:

>>> I don't want to $xsl->load('my.xsl') hundreds of times...

If it's in the same request, you don't have to do it

***
$proc = new xsltprocessor();
$xsl->load('my.sql');

$proc->importStylesheet($xsl);

while ($xml = getMoreDocuments()) {
	$proc->transformToUri($xml,"/foo/bar...");
}
***

This just loads and compiles the xslt once. Of course, if you do that in
different requests, the xslcache is the only way to speed it up

chregu



> ZyZ wrote:
>> probably this is what you are looking for
>>
>> http://code.nytimes.com/projects/xslcache
>>
>> Uzytkownik "Marc" <[email protected]> napisal w wiadomosci
>> news:[email protected]...
>>> Hi,
>>>
>>> is there any way to speed up xslt transformation in php4/5?
>>> I heared that it is generally a good idea to compile a stylesheet
>>> into memory if you apply small number of stylesheet to
>>> many xml documents, and that is exactly what I want to do.
>>>
>>> Is there a way to improve xslt speed by loading an xslt style-
>>> sheet into memory, serialize it to the harddisc or anything
>>> like this?
>>>
>>> I don't want to $xsl->load('my.xsl') hundreds of times...
>>>
>>> Marc 
> 

-- 
Liip AG  //  Feldstrasse 133 //  CH-8004 Zurich
Tel +41 43 500 39 81 // Mobile +41 76 561 88 60
www.liip.ch // blog.liip.ch // GnuPG 0x5CE1DECB



Thread (5 messages)

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