RE: [xsl]: Setting the value of variables, conditionally.

Subject: RE: [xsl]: Setting the value of variables, conditionally.
From: Mark Nahabedian <naha@xxxxxxxxxx>
Date: Fri, 13 Jul 2001 17:22:04 -0400 (Eastern Daylight Time)
Aparna Joshi writes:
 > Thanks, Mike!
 > 
 > But, is there any other way because, I have many variables and many
 > conditions. And, I am trying to minimize the conditional checking to have
 > something like :-
 >    <xsl:when>... set variable....</xsl:when> 
 > But this shows only the default value once it is out of the <xsl:when>
 > scope.

The conditional branch could be used to select among a number of
either result tree fragments (RTFs) or text strings.  These RTFs or
strings would be used to encode the values of all of the variables to
be set.  The result of the conditional would be saved to a temporary
variable from which the values of the variables you care about would
then be extracted.

If the data values are simple enough you could encode them in order in
a string with the values for each variable separated from one another
by some character guaranteed not to occur in any value.

Otherwise you could encode them in an RTF with one node for each
variable to be set.  You will need to use the often mentioned
node-set() extension function to convert the RTF to a node set before
you can extract data from it.  Consult the list archives to see how to
use node-set() and to determine what namespace it lives i nfor the
XSLT processor you're using.




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


Current Thread