Subject: [xsl] Using XSL parameters to construct variables to construct expressions From: "Doug Howell (IT)" <DHOWELL@xxxxxxxxxxxxxxxxxxx> Date: Thu, 20 Mar 2003 16:50:48 -0500 |
(Please forgive me, as I've been away from XSL for a while, and am struggling with a new project.) I'm transforming an XML file via JavaScript, based on user input. Approach 1: I'm currently creating a processor via JavaScript, then sending different parameters/modes to it to get search results. If the user chooses to narrow the search, he/she selects an option and I send a parameter to the stylesheet (processor). What I'd like to do inside the stylesheet is to construct a variable on the fly, based on the parameter values, then use that variable as the expression in the apply-templates select attribute value. Something like this: 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"/> . . . . . . If a parameter is passed in, the parameter would not equal an empty string, so the corresponding predicate expression would become part of the variable. So I could add more predicates depending on the values of other parameters, then use the complete variable in the following apply-templates select statement. This doesn't seem to work, because the variable will evaluate as a string instead of an expression, right? Is there a way around this? Approach 2: I could also change the select attribute via script in the Web page, then select the node (using selectSingleNode) and change its value. Just wondering what the trade-offs would be between these two approaches (if the first approach is even possible, that is). Would it work faster, more efficiently? Thanks, Doug Howell XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Looping through attribute, Jeni Tennison | Thread | [xsl] Re: Using XSL parameters to c, Dimitre Novatchev |
Re: [xsl] How to Process when Row d, Imrran Wahid | Date | RE: Re: [xsl] Looping through attri, cknell |
Month |