Processing XSLT client-side isn’t for everyone, not all browsers support it, and out of those that do, there are a few that still don’t do it well.
Of course you have the option of Saxon or various Apache modules, but what if you want a little more control, from within your web application? Easy, PHP has an XSLT Processor “built in”.
Quick Example;
<?php
$dom = new DomDocument();
$dom->load( 'test.xml' );
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load( 'xslt/layout.xsl', LIBXML_NOCDATA);
$xslt->importStylesheet( $XSL );
print $xslt->transformToXML( $dom );
?>
It’s as easy as that.
Mike Hughes.
Leave a Reply