xsl-list
[Top] [All Lists]

RE: RE: Parameter not working in contains() function

2003-06-03 14:09:41
I'm using JavaScript on a web page to pass parameters (user 
input) to an XSL file. The parameters are global. I'm trying 
to use them in this for-each statement:

<xsl:for-each select="doclist/doc[contains($param1,$param2)]">

$param1 comes from a dropdown list on the web page and will 
always be one of the children of doc. If I manually replace 
$param1 with one possible value, the XSL works (i.e., 
<xsl:for-each select="doclist/doc[contains(title,$param2)]">. 

But when I use the $param1 as the first argument in the 
contains function, I get no results.

This is because $param1 presumably contains a string, namely 'title',
and so what you're getting is
 <xsl:for-each select="doclist/doc[contains('title',$param2)]">.

One way to do what you're trying to do would be
 <xsl:for-each 
select="doclist/doc[contains(*[local-name()=$param1],$param2)]">. 

I think that should work.

Lars


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



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