|
Subject: Re: [xsl] Conditional Assigining From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx> Date: Wed, 16 May 2001 12:56:27 -0400 |
You can't do that in xslt. Once you create a variable (within a certain
scope) you can't change it.
What you do instead is either to call the same template recursively, passing
in the test value in a parameter, or calling a template repeatedly with a
mode attribute, again passing in your test value as a parameter.
Tom P
[Sri ni]>
> <xsl:variable name="ID">-1</xsl:variable>
> <xsl:for-each select="Section[parentID='0']">
> <xsl:if test="$ID=-1">
> <xsl:variable name="ID" select="sectionID" />
> </xsl:if>
> id <xsl:value-of select="$ID"/>
>
> Output:
> -----------
> id = -1. In the first instance.
>
> **********************
> Please have a look on the above XML. The scope of the ID is getting lost
> once i get exit from the if loop which is not i want. The value of the
> global variable ID has to be set inside IF and then that should be visible
> to outer functions as well.
>
>
> All i want is similar to this one.
> int x = 0;
> while ( true) {
> if ( x == 0 ){
> x = 1;
> }
> x = 2;
> }
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Conditional Assigining, Michael Kay | Thread | [xsl] nested templates?, Alex Black |
| RE: [xsl] nested templates?, Wendell Piez | Date | Re: [xsl] translate function, Mike Brown |
| Month |