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

Subject: [xsl] Using URL Variable in XSL (with PHP)
From: "Leisha Cook" <lcook@xxxxxxxxxxx>
Date: Wed, 11 Oct 2006 11:36:36 -0700
This has no doubt been addressed before, but I wasn't quite able to find
a solution to fit my situation. Or to understand any of solutions, at
any rate.

My XML file contains info about a number of people, each of whom has an
ID. I want to users to click on a link which includes the ID as a
variable and display that single person's info.

Here's a simplified version of the XML:

	<person id="1">
		<research>My research is very complicated.</research>
	<person id="2">
		<research>I am interested in the effects of grape soda
on the self-esteem of the African eight-legged spotted

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

fac_profile.php looks like this:

<h1>Research Profile</h1>
if (isset($_GET['id'])) {
$xml = simplexml_load_file('xml/faculty.xml');
$xsl = new DOMDocument;

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

My stylesheet looks like this:

<xsl:stylesheet version="1.0"
<xsl:param name="id" />
	<xsl:template match="/">
		<xsl:if test="faculty/person[@id] = $id">
			  <li>Name:<xsl:text> </xsl:text><xsl:value-of
select="first" /><xsl:text> </xsl:text><xsl:value-of select="last"
			  <li>Title:<xsl:text> </xsl:text><xsl:value-of
select="title" /></li>
			  <li>Research Interests:<xsl:text>
</xsl:text><xsl:value-of select="research" /></li>

I can't get the profile to display. What's wrong with my XSL (or is it
my PHP)? Any help would be greatly appreciated. Thanks.

Current Thread