[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: variable incrementing problems

Subject: RE: variable incrementing problems
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 28 Jun 1999 13:30:29 +0100
xsl variable incrementing
You cannot use xsl:variable to assign a new value to an existing variable:
what your code is doing is to create a new variable of the same name, and
when this goes out of scope (at </xsl:if>) your code picks up the earlier
variable in preference.

Instead of:

    <xsl:variable name="FolderRowspan">
	<xsl:value-of select="count(subfolder)*2+1"/>
    </xsl:variable>
    <xsl:if test="count(highligth)+count(subfolder/highligth) &gt; 0">
	<xsl:variable name="FolderRowspan">
	    <xsl:value-of select="$FolderRowspan+1"/></xsl:variable>
    </xsl:if>

Try this:

	<xsl:variable name="FolderRowSpan1">
	<xsl:choose>
	<xsl:when test="count(highligth)+count(subfolder/highligth) &gt; 0">
		1</xsl:when>
	<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>
    	<xsl:variable name="FolderRowspan">
		<xsl:value-of select="count(subfolder)*2 + 1 +
$FolderRowSpan1"/>
    	</xsl:variable>

Or you could exploit the convenient fact that number() converts false to 0
and true to 1 by writing:

    	<xsl:variable name="FolderRowspan">
		<xsl:value-of select="count(subfolder)*2 + 1 +
			 number(count(highligth)+count(subfolder/highligth)
&gt; 0)"/>
    	</xsl:variable>

Mike Kay

(Incidentally, the reason I didn't allow nested variables of the same name
in SAXON was for implementation convenience, but I'm beginning to think it
was a good idea, as it traps this kind of error. Comments anyone?). 

> -----Original Message-----
> From: Eugeny Kuzakov [mailto:kev@xxxxxxxxx]
> Sent: 28 June 1999 11:57
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: variable incrementing problems
> 
> 
> hi*
> 
> I am need correctly calculate rowspan attribute in result 
> html-document.
> I am have problems with it.
> 
> Question:
> 	In debug2 comment value of FolderRowspan variable correctly
> 	incrementes into need value.
> 	But after exit from <xsl:if> tag it keep previous value.
> 	What can I do?
> Thanks.
> 
> --
> 	Best wishes, Eugeny Kuzakov
> 		Laboratory 321 ( Omsk, Russia )
> 		kev@xxxxxxxxx
> 		ICQ#: 5885106
> 
> 
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.