I'm trying to pass a parameter to XSL from PHP... I'm running Apache 2.0.51, PHP 4.3.9, and Sablotron 1.0....
Basically I am passing a parameter to the php doc (i.e. links.php?cat=1) and I then want to pass it on to the XSL so it can use it...
I don't get any errors, but the "cat" paramater is always empty... like it's not getting passed... What am I missing? I've googled for help with XSL parameters with PHP and according to the 5 sites I found, I'm doing it right...
Here's the PHP
<?php
$params[cat] = $HTTP_GET_VARS[cat];
$xml = 'links.xml';
$xsl ='list.xsl';
$xh = xslt_create();
$result = xslt_process($xh, $xml, $xsl, NULL, NULL, $params);
if ($result) {
print $result;
} else {
print "Error #" . xslt_errno($xh);
print " , " . xslt_error($xh);
}
xslt_free($xh);
?>
Here is the XSL doc
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:param name="cat"/>
<html>
<head>
<title>Links</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<xsl:for-each select="links/category[@id=$cat]/subcategory">
<tr>
<td>
<xsl:value-of select="title"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Here is a snipet of my XML doc:
<?xml version="1.0"?>
<links>
<category id="1">
<title>Linux</title>
<subcategory>
<title>Distributions</title>
<link>
<title>Gentoo</title>
<address>http://www.gentoo.org</address>
</link>
</subcategory>
</category>
</links>