xsl-list
[Top] [All Lists]

RE: Parameters in XPath

2003-01-07 11:43:22
What I'm trying to accomplish with the Filter
parameter is to dynamically pass into the stylesheet a
XPath expression to be evaluated.
For example:

<xsl:param name="Filter" select="@rebate>9.99 and 
@shippingMethod='Ground' and @cost<199.99"/>

<xsl:apply-templates
select="/Cat[(_at_)CatId=$Cat]/Prod[$Filter]"/>


And I think several people explained (a) that you can't do this, except
with the xx:evaluate() extension that several processors provide, and
(b) that if you do use these extensions, the select attribute must be a
string containing the expression, not the expression itself: so you need
to write:

<xsl:variable name="defaultFilter">@rebate &gt; 9.99 and 
@shippingMethod='Ground' and @cost &lt; 199.99</xsl:variable>

<xsl:param name="Filter" select="string($defaultFilter)"/>

If you write it your way, $Filter will be the value of the expression,
not the expression itself.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>