[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using URL Variable in XSL (with PHP)
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: <faculty> <person id="1"> <first>Joe</first> <last>Smith</last> <title>Professor</title> <research>My research is very complicated.</research> </person> <person id="2"> <first>Mary</first> <last>Jones</last> <title>Chair</title> <research>I am interested in the effects of grape soda on the self-esteem of the African eight-legged spotted dachshund.</research> </person> </faculty> The link would be "../fac_profile.php?id=1" fac_profile.php looks like this: <h1>Research Profile</h1> <?php if (isset($_GET['id'])) { $xml = simplexml_load_file('xml/faculty.xml'); $xsl = new DOMDocument; $xsl->load('xslt/fac_profile.xsl'); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); } ?> My stylesheet looks like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="id" /> <xsl:template match="/"> <xsl:if test="faculty/person[@id] = $id"> <ul> <li>Name:<xsl:text> </xsl:text><xsl:value-of select="first" /><xsl:text> </xsl:text><xsl:value-of select="last" /></li> <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> </ul> </xsl:if> </xsl:template> </xsl:stylesheet> 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|