Save time rendering XSL(in php), Use an XSL builder

I love XSL. Its a wonderful tool for rendering HTML,XHTML,XML. Imports improve readability and helps you organize your XSL’s in an orderly fashion. But lets face it: Imports are a bit slow especially on networked storage like NFS.

I tried searching for a decent solution. But could not find one.

So I built an XSL builder for my platform(artist community platform) to reduce the time taken rendering from XML to HTML using XSL. It succeeded in lowering the time it takes to render by as much as 25 to 35% on the production site.

It also includes a nifty way of building  different xsl files that contains only the templates you need to increase speed even more. (check out the README)

Now I have both flexibility (XSL is awesome!) and a lot more speed.

Its open source!(GPLv3) (copyleft , so if you have any changes you made, please send them to me )

You can download it here

It contains both a CLI version and the class that does the building (For platform integration!)

CLI version

An example of how to use the CLI version:

./xslbuildercli.php input=/full/path/to/your/xslfiles/index.xsl

This will return the built XSL to stdout. (more examples on how to build to files and how to use the modes to create seperate files for seperate uses, check out the README)

Just the class

If you plan to do some other cool stuff like online XSL editing this might be interesting.

require_once(‘xslbuilder.php’);

$newXSL = xslbuilder::buildXSLFile(‘/full/path/to/your/xsl/index.xsl’);

//or

xslbuilder::buildXSLFile(‘/full/path/to/your/xsl/index.xsl’,
                             ‘/full/path/to/your/xsl/built/index.xsl’);

 

Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.