Re: Fwd: Re: [xsl] suggestions for per request xslt performance?

Subject: Re: Fwd: Re: [xsl] suggestions for per request xslt performance?
From: Nic James Ferrier <nferrier@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Apr 2007 11:10:10 +0100
Andrew Mason <andrew@xxxxxxxxxxxxxxx> writes:

>> 3. if you have any kind of persistent store with PHP you can cache the
>> stylesheet. 
> It's not the stylesheet that is the issue, it's the time taken to load the 
> stylesheet into the xslt processor.  Creating the DOMDocument from the 
> stylesheet is quick. Processing the stylesheet is fast. The importStylesheet 
> function is probably comparitively fast too, however it's still too expensive 
> on a /request basis.
>
> One of the other people on the list suggested memcached which might be an 
> option for caching the processor. 

That's what I was getting at. You need the libxslt transformContext
support tho as I recall...

My python transform wrapper looks like this:

        try:
            stylesheet = libxslt.newStylesheet()
            stylesheet = stylesheet.parseStylesheetProcess(stylesheet_dom)
        except Exception, e:
            logger.error("failed to parse xslt: " + str(e))
            raise ProcessException(e)
        else:
            try:
                transform_context = stylesheet.newTransformContext(src_dom)
                result_dom = stylesheet.applyStylesheetUser(src_dom, {}, transform_context)
            except Exception, e:
                logger.error("failed to run XSLT")
                raise ProcessException(e)

I can cache the stylesheet_dom (which is what I do rather than caching
the processor).

You say "importStylesheet" I'm not sure what that means.

Have you tried breaking the stylesheet creation down into:

1.  create stylesheet source dom
2.  create processor from that dom?

You normally do that with:

    parseStylesheetDoc(doc)

but you can also do it as I've done the above.

-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   

Current Thread