Subject: [xsl] filter based on parameter, not getting it. From: "Carter, Will" <WCarter@xxxxxxxxxxxxxxxx> Date: Fri, 20 Sep 2002 14:56:50 -0500 |
Hi, I am trying to filter based on a parameter. If the filterparam is empty, don't do any filtering. If filterparam is something, that's what to filter on. xml.xml --------------------------------------------------------- <people> <person name="george"> <cat>zoro</cat> <dog>butch</dog> <fish>jaws</fish> </person> <person name="jennifer"> <cat>felix</cat> <dog>fido</dog> <fish>moby</fish> </person> <person name="simon"> <cat>tom</cat> <dog>scooby</dog> <fish>conroy</fish> </person> </people> --------------------------------------------------------- This code doesn't work: --------------------------------------------------------- <xsl:param name="filterparam"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="string-length($filterparam) = 0"> <xsl:variable name="filter" select="//person"/> </xsl:when> <xsl:otherwise> <xsl:variable name="filter" select="//person[cat = $filterparam]"/> </xsl:otherwise> </xsl:choose> <table> <xsl:for-each select="$filter"> <tr> <td><xsl:value-of select="cat"/></td> <td><xsl:value-of select="dog"/></td> <td><xsl:value-of select="fish"/></td> </tr> </xsl:for-each> </table> --------------------------------------------------------- here is my command line entry: java org.apache.xalan.xslt.Process -in xml.xml -xsl filterprob.xsl -param filterparam zoro -out output.html my error: Could not find variable with the name of filter I wanted my output to be: zoro butch jaws I realize that the error is caused because the variable is set up in the choose. if I move the variable statements outside the choose, it works...but then I am not checking if filterparam is empty or not. thanks for any help you could provide. will XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] variable in filter doesn', Nik Krimm | Thread | RE: [xsl] filter based on parameter, Passin,Thomas B. (To |
Re: [xsl] Muenchian method on nodes, J.Pietschmann | Date | [xsl] Match values? (sorry so big), RShonk |
Month |