Variable Scope

Subject: Variable Scope
From: Stuart Wilson <coracle@xxxxxxxxxxxxxx>
Date: Thu, 9 Nov 2000 12:15:30 +0000
  I've been looking through the FAQ and have a question about one of the 
examples under the "Basic Troubleshooting/Tables" section. The input is

<?xml version='1.0'?>

and the XSL includes

<xsl:template match="TASKS/TASK/COMPONENTS">
  <xsl:variable name="t-size" select="count(COMPONENT)"/>
  <xsl:variable name="half" select="ceiling($t-size div 2)"/>

  <xsl:for-each select="COMPONENT[position() &lt;= $half]">
   <xsl:variable name="here" select="position()"/>
      <TD><xsl:value-of select="."/><xsl:value-of select="$here"/></TD>
	  <xsl:when test="../COMPONENT[$here+$half]">
	    <xsl:value-of select="../COMPONENT[$here+$half]"/>


What I'm not clear about is why the 'here' variable is updatable as the 
for-each iterates, it was my understanding that variable values cannot be 
Could someone explain ?

Thank you.

Totalise - the Users ISP
To become a member and a shareholder

"Get the latest Ericsson 2618, Nokia 6210 and Samsung M100 at our 
Mobile Store, Visit"    

 XSL-List info and archive:

Current Thread