Subject: RE: [xsl] filter based on parameter, not getting it. From: "Marrow" <marrow@xxxxxxxxxxxxxx> Date: Fri, 20 Sep 2002 23:41:57 +0100 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] filter based on parameter, Carter, Will | Thread | RE: [xsl] filter based on parameter, Michael Kay |
RE: [xsl] filter based on parameter, Carter, Will | Date | Re: [xsl] Re: Re: exponential math , Trevor Nash |
Month |