A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

PHP 5 XSL


Introduction: The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library

Requirements: This extension uses libxslt which can be found at http://xmlsoft.org/XSLT/. libxslt version 1.0.18 or greater is required.

Installation: PHP 5 includes the XSL extension by default and can be enabled by adding the argument --with-xsl[=DIR] to your configure line. DIR is the libxslt installation directory.

// xsl document
$xsl = new DomDocument;
$xsl->load($xstemplate);

// xslt processor
$xp = new XsltProcessor();
$xp->importStylesheet($xsl);

// xml document
$xml_doc = new DomDocument;
$xml_doc->load($xmldata);

// perform the transform
$html = $xp->transformToXML($xml_doc);