Re: [xsl] Using URL Variable in XSL (with PHP)

Subject: Re: [xsl] Using URL Variable in XSL (with PHP)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 11 Oct 2006 23:14:26 +0200
Leisha Cook wrote:

The link would be "../fac_profile.php?id=1"


$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);

[...]
<xsl:param name="id" />

I am not sure of the magic that PHP can perform for you, but shouldn't you be setting the parameter before starting the process? You declare a parameter but never set it. Perhaps it should be done like this in PHP:


$proc->setParameter("id", $_GET['id']);

[...]	
	<xsl:if test="faculty/person[@id] = $id">
[...]

This should be [@id = $id], as Trish pointed out. The difference being, "a person (with an attribute 'id') with a content that matches the value of $id" (your code) and "a person which has an 'id' attribute with a value that matches the value of the 'id' parameter".



Hth,


Cheers,
-- Abel Braaksma
-- http://www.nuntia.com

Current Thread