This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Scope of Local Variables?
- From: "Rajput, Ashish S" <ashish dot s dot rajput at lmco dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 06 Jun 2002 13:52:06 -0500
- Subject: [xsl] Scope of Local Variables?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello,
Using the MSXML 4 parser, as well as Instant Saxon 6.5.2 I'm getting an
error of "variable may be out of scope" when trying to use a variable
locally. Listed below are my XML and XSLT files..... am I defining the
variables incorrectly? I'm attempting to call the variables in a sibling.
Please help!
Ashish Rajput
*******************************************
XSLT
*******************************************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:template match="array">
<xsl:for-each select="(./ancestor::*)">></xsl:for-each>
<font color="red"><span style="font-size:medium;
font-weight:bold">
<xsl:value-of select="@name" />
</span></font>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="read">
<xsl:variable name="rowTag"
select="./tagToAxis[./@axisIDRef='rows']/@tag"></xsl:variable>
<xsl:variable name="columnTag"
select="./tagToAxis[./@axisIDRef='columns']/@tag"></xsl:variable>
</xsl:template>
<xsl:template match="read">
<xsl:value-of select='$rowTag'></xsl:value-of>
<xsl:value-of select='$columnTag'></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
***********************************************
XML
***********************************************
<array name="Cross Section Factor">
<fieldAxis fieldAxisID="columns">
<field name="Reflection Type">
<units>
<unitless/>
</units>
<dataFormat>
<float/>
</dataFormat>
</field>
<field name="Value">
<units>
<unitless/>
</units>
<dataFormat>
<float/>
</dataFormat>
</field>
</fieldAxis>
<axis axisID="rows" axisDataType="integer">
<axisUnits>
<unitless/>
</axisUnits>
</axis>
<read encoding="UTF-8">
<tagToAxis tag="d1" axisIDRef="columns"/>
<tagToAxis tag="d0" axisIDRef="rows"/>
</read>
<data>
<d0>
<d1>Radar</d1>
<d1>.5</d1>
</d0>
<d0>
<d1>Sonar</d1>
<d1>.4</d1>
</d0>
<d0>
<d1>Visual</d1>
<d1>.3</d1>
</d0>
<d0>
<d1>InfraRed</d1>
<d1>.2</d1>
</d0>
</data>
</array>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list