The following code is a wrapper to support calls to some of the old xslt_* functions:
<?
if (PHP_VERSION >= 5) {
function xslt_create() {
return new XsltProcessor();
}
function xslt_process($xsltproc,
$xml_arg,
$xsl_arg,
$xslcontainer = null,
$args = null,
$params = null) {
$xml_arg = str_replace('arg:', '', $xml_arg);
$xsl_arg = str_replace('arg:', '', $xsl_arg);
$xml = new DomDocument;
$xsl = new DomDocument;
$xml->loadXML($args[$xml_arg]);
$xsl->loadXML($args[$xsl_arg]);
$xsltproc->importStyleSheet($xsl);
if ($params) {
foreach ($params as $param => $value) {
$xsltproc->setParameter("", $param, $value);
}
}
$processed = $xsltproc->transformToXML($xml);
if ($xslcontainer) {
return @file_put_contents($xslcontainer, $processed);
} else {
return $processed;
}
}
function xslt_free($xsltproc) {
unset($xsltproc);
}
}
$arguments = array(
'/_xml' => file_get_contents("newxslt.xml"),
'/_xsl' => file_get_contents("newxslt.xslt")
);
$xsltproc = xslt_create();
$html = xslt_process(
$xsltproc,
'arg:/_xml',
'arg:/_xsl',
null,
$arguments
);
xslt_free($xsltproc);
print $html;
?>