xsl-list
[Top] [All Lists]

Variable scope

2005-05-16 16:44:08
Hi,

I am trying to define a local variable in the template template1,
calculate it in another template get-var [about 30 lines]
and pass in to another template template2.

It seems that this variable somehow gets reset to 0 in template2
and doesn't function correctly.

Is that how it supposed to be (that it gets out of scope) ?

Would you recommend me to make that variable global
(but still calculate it in template get-var),
should that help ?
Or should I get rid of template and put all calculation there as well?


Thank you,
Oleg.

Here is a snippet:


<xsl:template name="get-min">
  <xsl:param name="product"/>
  <xsl:choose>
    <xsl:when test="something">
      ........   30 lines, few auxiliary variables..[set to a value
here, lets say 1]..
      1
     </xsl:when>
   <xsl:otherwise>
        0
   </xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template  name="template1">
.....
<xsl:variable name="min">
  <xsl:choose>
      <xsl:when test="something">
         <xsl:call-template name="get-min">
        <xsl:with-param name="product" select="$product"/>
          </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        0
      </xsl:otherwise>
</xsl:choose>
</xsl:variable>
......

<xsl:call-template name="template2">
  <xsl:with-param name="product" select="$product"/>
   <xsl:with-param name="min-column" select="$min"/>            
</xsl:call-template>
....
</xsl:template>


<xsl:template name="current-estimated-table">
  <xsl:param name="product"/>
   <xsl:param name="min-column"/>
......  .....

<xsl:if test="min-column">  ...do something ...      [min-column becomes 0 here]
</xsl:if>

</xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>