I have a project that I’m working that uses XSLT to display data from the db (db2). I’m making some variables like…..
<xsl:variable name="RatePerLoadedMiles1">
<xsl:call-template name="ratePerLoadedMiles">
<xsl:with-param name="summaryRow" select="$SummaryRow1" />
<xsl:with-param name="numerator" select="$OperatingExpense1"/>
</xsl:call-template>
</xsl:variable>
Now the template is stored in an existing and functioning xslt file that simply stores templates for reuse.
My question is… When I call the variable $RatePerLoadedMiles1 am I getting a value return or the content of whats between the <xsl:variable> and </xsl:variable>? So if I pass it values that evaluate to 5. Will I now have 5 stored or will I have the contents of the variable tag that will evaluate to 5 each time. I’m less concerned with the error message it’s simply provided because it was request. My main concern is to the question above.
If it matters I’m calling the variable like….
<td class="rightAligned">
<xsl:copy-of select="$RatePerLoadedMiles1" />
</td>
and I’m also using it do some additional calculations with….
<td class="rightAligned"><!-- RPLM -->
<xsl:call-template name="formatAsPercent">
<xsl:with-param name="numberToFormat">
<xsl:call-template name="divideNumbers">
<xsl:with-param name="numerator" select="$RatePerLoadedMiles1 +
$RatePerLoadedMilesBefore +
$RatePerLoadedMilesAfter" />
<xsl:with-param name="denominator" select="3" />
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</td>
The output is from the browser…
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;
Trident/4.0; EasyBits GO v1.0; SLCC2; .NET CLR 2.0.50727; .NET CLR
3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; MDDR;
FDM) Timestamp: Tue, 9 Aug 2011 14:24:01 UTCMessage: A reference to variable or parameter ‘RatePerLoadedMiles’
cannot be resolved. The variable or parameter may not be defined, or
it may not be in scope.Line: 1385 Char: 2 Code: 0 URI:
http://costanalysis:13000/costAnalysis/protected/javascript/xWireClientFull.jsb
The answer to your question is that the variable RatePerLoadedMiles1 stores the value 5 (as an RTF, as @Michael Kay described). It is not re-evaluated when
$RatePerLoadedMiles1is referenced.If it is giving you the error message you posted, then you apparently forgot the
1on the end when referencing it somewhere, because the error message saysRatePerLoadedMiles.