php “XSLTProcessor::setParameter” function

xmltransform.php
<?php
$xml= new DOMDocument();
$xml-> load(“testparam.xml”);

$xsl= new DOMDocument();
$xsl-> load(“testparam.xsl”);

$xsltproc= new XSLTProcessor();
$xsltproc-> importStylesheet($xsl);

$variable= “myvalue”;    //this part for passing parameter ‘myparam’ to xsl
$xsltproc->setParameter(”, ‘myparam’, $variable);

echo $xsltproc->transformToXML($xml);
?>

——————————————————————————————

testparam.xsl

<?xml version=”1.0″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;
<xsl:template match=”/”>
<html>
<body>
–<p style=”color:red;”> Value parameter: <xsl:value-of select=”$myparam”/></p>
–<h2>Parameter works everywhere</h2>
–<table border=”1″>

—–<xsl:for-each select=”mytestnode”>

——–<tr>
———–<td> <xsl:value-of select=”$myparam”/> </td>
——-</tr>

—–</xsl:for-each>
–</table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>