[xsl] Re: Using XSL parameters to construct variables to construct expressions

Subject: [xsl] Re: Using XSL parameters to construct variables to construct expressions
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 21 Mar 2003 06:53:22 +0100
> XML snippet:
> <process>
>      <number>1</number>
>      <name>evaluate</name>
>      <descrip>[Description.]</descrip>
> </process>
>
> XSL snippet:
> <!-- default value of params is empty string; if user chooses a
processArea option, I'll send the parameter to the stylesheet and set this
value -->
> <xsl:param name="processArea" /><!-- if sent, value will be 1, 2, 3 or
4 -->
> . . .
> . . .
> <xsl:variable name="selectStatement">/process-report/process
>      <xsl:if test="$processArea != ''">[starts-with(number,<xsl:value-of
select="$processArea"/>)]</xsl:if>
> </xsl:variable>
> . . .
> . . .
> <xsl:apply-templates select="$selectStatement"/>
>

This is a FAQ:  Standard XSLT 1.0 and 2.0 do not support dynamic evaluation
of string representation of an XPath expression.

And in this case dynamic evaluation is not necessary -- use:

 <xsl:apply-templates select="process[starts-with(number, $processArea)]"/>



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL





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


Current Thread