[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using URL Variable in XSL (with PHP)

Subject: Using URL Variable in XSL (with PHP)
From: "Leisha Cook" <lcook@xxxxxxxxxxx>
Date: Wed, 11 Oct 2006 11:36:36 -0700
php variables in xsl
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


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.