|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] is the variable really out of scope??
All,
I have the following problem defined by microsoft IE: the variable 'i' is undefined and may be out of scope I read through the faq and tried to find an answer to the scope issue. I found that the faq mentions that a variable within a choose statement has a scope confined to that xsl element. However, it does not mention the scope of the variables external to the xsl element. Is there a better way for me to tackle this problem other than creating three separate templates for my choose statement? Please look specifically at the 'w' and 'h' variables and their updates based on 'k' and 'i'. To help clarify my problem, I have provided my xsl script: <xsl:template match="/">
<xsl:call-template name="calcOpt" />
</xsl:template> <xsl:template name="calcOpt">
<xsl:param name="N" select="23" /> <!-- pseudo-code
N = value in
s = sqrt(N)
k = s mod 1 // fractional portion of square root
i = s - k if 0 < k < 0.5
w = i
h = i+1
else if k >= 0.5
w = i+1
h = i+1
else
w = i
h = i
-->N = <xsl:value-of select="$N" /><br /> <xsl:variable name="s">4.79</xsl:variable>
s = <xsl:value-of select="$s" /><br /> <xsl:variable name="k" select="$s mod 1" />
k = <xsl:value-of select="$i" /><br /> <xsl:variable name="i" select="$s - $k" />
i = <xsl:value-of select="$k" /><br /> <xsl:variable name="w">
<xsl:choose>
<xsl:when test="($k > 0.5) and ($k < 0.5)">
<xsl:value-of select="$i+1" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$i" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
w = <xsl:value-of select="$w" /><br /> <xsl:variable name="h">
<xsl:choose>
<xsl:when test="($k = 0)">
<xsl:value-of select="$i" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$i+1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
h = <xsl:value-of select="$h" /><br />
</xsl:template>
_________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








