xsl-list
[Top] [All Lists]

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

2003-06-03 14:05:13
Grant, Kathryn --- Sr. Technical Writer --- WGO wrote:

Thanks to Oleg and Tom for their earlier help, which got me far enough to ask 
another question.

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. Is it illegal to use a parameter there? If so, does anyone know 
of a different way to get user input from my web page to be accepted as the 
first argument in contains()? If more detail is needed to answer this question, 
please let me know.

"Variables in XSLT are not macros!" (c) xsl-list. When you have a variable holding string, it's just string, no matter what is inside the string and you can't expect this string will be magically interpreted as XPath expression.
In your case there is a workaround though:
<xsl:for-each select="doclist/doc[contains(*[name()=$param1],$param2)]">

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


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



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