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

RE: filter based on parameter, not getting it.

Subject: RE: filter based on parameter, not getting it.
From: "Marrow" <marrow@xxxxxxxxxxxxxx>
Date: Fri, 20 Sep 2002 23:41:57 +0100
filterparam
Hi Will,

Not sure if this is what you want - but try...

== XSL ==========================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="filterparam"/>
<xsl:variable name="ifilter"
select="//person[string-length($filterparam) = 0] |
//person[string-length($filterparam) != 0][cat = $filterparam]"/>

<xsl:template match="/">
  <table>
  	<xsl:for-each select="$ifilter">
    	<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>
</xsl:template>

</xsl:stylesheet>
== end of XSL ===================================

Hope this helps
Marrow 
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Carter, Will
Sent: 20 September 2002 23:21
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  filter based on parameter, not getting it.

okay, here is my attempt...not working...very frustrating.

my error: Can not convert #STRING to a NodeList!

<xsl:param name="filterparam"/>

<!-- try to take the if condition out of the test template -->
<xsl:template match="/">
<xsl:choose>
	<xsl:when test="string-length($filterparam) = 0">
		<xsl:call-template name="test">
			<!-- trying to call the test template with no
filter -->
			<xsl:with-param name="filter"
select="//person"></xsl:with-param>
		</xsl:call-template>
	</xsl:when>
	<xsl:otherwise>
		<xsl:call-template name="test">
			<!-- trying to call the test template with the
filterparam as the filter -->
			<xsl:with-param name="filter"
select="//person[cat = $filterparam]"></xsl:with-param>
		</xsl:call-template>
	</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template name="test" match="/">
<xsl:param name="filter"/>
<xsl:variable name="filter" select="$filter"/>
<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>
</xsl:template>





 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.