From: Steve B. <Ste...@zv...> - 2002-11-12 20:24:10
|
I've added a new utility sub-package to the TclXSLT CVS repository - xslt::cache. This module takes care of loading the documents for performing an XSL transformation, and caches the documents and stylesheets for those times when the transformation is to be repeated. Example: package require dom package require xslt package require xslt::cache # Transform doc.xml using stylesheet style.xsl with # parameter foo='bar' set result1 [xslt::cache::transform doc.xml style.xsl foo bar] # This time the source and stylesheet will be taken from the cache, # only the transformation itself is repeated set result2 [xslt::cache::transform doc.xml style.xsl foo bar2] --- The command xslt::cache::flush removes entries from the cache. TODO: write up documentation, add info to website. Volunteer(s) needed! It would be useful to extend the package in two ways: the simplest improvement would be to allow documents to be fetched via HTTP in addition to files. A more complex improvement would be to track document dependencies. Source documents may use external entities or XInclude and stylesheets may import/include other stylesheets or use the document() function. If any of these dependent files change then the cache should be invalidated. Thus the cache module needs to discover the document's dependencies and check them at transform time. Most of the hooks are in place to interpose on these functions, someone just needs to add the code to the cache module to build a dependency graph and check it for out-of-date files. Enjoy, Steve Ball -- Steve Ball | XSLT Standard Library | Training & Seminars Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development Ste...@zv... +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099 |