I was wondering what type of XSL transformation is available - XSL, DOM, PCRE? I'm quite new to PHP, but I've got the XSL method figured out. However I've got a sneaky suspicion that this isn't enabled on the live servers. Here's the code I'm using:
PHP Code:
function TransformXml($xml_file, $xsl_file, $params)
{
$xp = new XsltProcessor();
// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument;
$xsl->load($xsl_file);
// import the XSL stylesheet into the XSLT process
$xp->importStylesheet($xsl);
// create a DOM document and load the XML data
$xml_doc = new DomDocument;
$xml_doc->load($xml_file);
// add parameters
$namespace = '';
if ($params) {
foreach ($params as $param => $value) {
$xp->setParameter($namespace, $param, $value);
}
}
// transform the XML into HTML using the XSL file
if ($html = $xp->transformToXML($xml_doc)) {
return $html;
} else {
trigger_error('XSL transformation failed.', E_USER_ERROR);
}
}
But this is the error I get:
Fatal error: Class 'XsltProcessor' not found
I've been looking through some phpinfo() on the live server, and comparing that to my dev server, and I reckon I'm missing this section:
xsl
XSL enabled
libxslt Version 1.1.12
libxslt compiled against libxml Version 2.6.17
EXSLT enabled
libexslt Version 1.1.12
Any advice? How else can I do some reasonably easy xml/xsl => html transformations?
Bookmarks