If you're using XSLT from within PHP, you can pass parameters to it by XSLTProcessor::setParameter()
. You'll have to declare that parameter in XSL with
<xsl:param name="«param name»"/>
For example...
PHP:
// $xsl, $xml -- DOMDocument objects
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
$proc->setParameter(''/*default namespace*/, 'test_param', $aValue);
$proc->setParameter('', 'session_name', session_name());
$proc->setParameter('', 'session_id', session_id());
echo $proc->transformToXML($xml);
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="test_param"/>
<xsl:param name="session_name"/>
<xsl:param name="session_id"/>
<xsl:template match="/">
<p>Your test parameter is: <xsl:value-of select="$test_param"/></p>
<p>Your session name is: <xsl:value-of select="$session_name"/></p>
<p>Your session ID is: <xsl:value-of select="$session_id"/></p>
<p>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('http://example.com/index.php?',$session_name,'=',$session_id)"/>
</xsl:attribute>
Link with session
</a>
</p>
</xsl:template>
</xsl:stylesheet>