Subject: RE: [xsl] Using URL Variable in XSL (with PHP) From: <Trish@xxxxxxxxxxxxxx> Date: Wed, 11 Oct 2006 14:53:29 -0400 |
Try: <xsl:for-each select="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:for-each> Also, you can also use   to get a blank space. Hope this helps, Trish -----Original Message----- From: Leisha Cook [mailto:lcook@xxxxxxxxxxx] Sent: Wednesday, October 11, 2006 2:37 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using URL Variable in XSL, Abel Braaksma | Thread | [xsl] status of FOP, Oct 2006, Wendell Piez |
[xsl] Using URL Variable in XSL (wi, Leisha Cook | Date | Re: [xsl] issue with cross referenc, George Cristian Bina |
Month |