note 45415 added to ref.xsl
| From: | jw at jwscripts dot com | Date: | Mon, 06 Sep 2004 09:23:19 +0000 |
| Subject: | note 45415 added to ref.xsl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76094@lists.php.net to get a copy of this message | ||
The following code is a wrapper to support calls to some of the old xslt_* functions:
<?
if (PHP_VERSION >= 5) {
// Emulate the old xslt library functions
function xslt_create() {
return new XsltProcessor();
}
function xslt_process($xsltproc,
$xml_arg,
$xsl_arg,
$xslcontainer = null,
$args = null,
$params = null) {
// Start with preparing the arguments
$xml_arg = str_replace('arg:', '', $xml_arg);
$xsl_arg = str_replace('arg:', '', $xsl_arg);
// Create instances of the DomDocument class
$xml = new DomDocument;
$xsl = new DomDocument;
// Load the xml document and the xsl template
$xml->loadXML($args[$xml_arg]);
$xsl->loadXML($args[$xsl_arg]);
// Load the xsl template
$xsltproc->importStyleSheet($xsl);
// Set parameters when defined
if ($params) {
foreach ($params as $param => $value) {
$xsltproc->setParameter("", $param, $value);
}
}
// Start the transformation
$processed = $xsltproc->transformToXML($xml);
// Put the result in a file when specified
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;
?>
----
Manual Page -- http://www.php.net/manual/en/ref.xsl.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45415
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45415&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45415&report=yes
Search -- http://master.php.net/manage/user-notes.php