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

filter based on parameter, not getting it.

Subject: filter based on parameter, not getting it.
From: "Carter, Will" <WCarter@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Sep 2002 14:56:50 -0500
filterparam
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.