xsl-list
[Top] [All Lists]

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

2007-04-26 03:09:33
Andrew Mason <andrew(_at_)katalyst(_dot_)com(_dot_)au> 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   

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--