This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Conditional Assigining
- To: "Sri ni" <srini75 at hotmail dot com>
- Subject: Re: [xsl] Conditional Assigining
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 16 May 2001 19:41:01 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <F84a3sgmOFDCxuSjL5S00009500@hotmail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Sri,
> <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"/>
You cannot use variables in this way within XSLT. A variable's scope
is limited to its following siblings and their descendants, and you
cannot reassign a different value to the variable (unless you use an
extension element like saxon:assign).
If you want to get the value of the sectionID of that first Section
element, then that's what you should set the value of the variable to:
<xsl:variable name="ID" select="Section[parentID = '0'][1]" />
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list