[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Scope of Local Variables?

Subject: Re: Scope of Local Variables?
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 06 Jun 2002 21:25:07 +0200
span in xsl field name
Hello Ashish,

why do you have two templates matching on "read"? Change it to:

<xsl:template match="read">
<xsl:variable name="rowTag" select="tagToAxis[@axisIDRef='rows']/@tag"/>
<xsl:variable name="columnTag" select="tagToAxis[@axisIDRef='columns']/@tag"/>
<xsl:value-of select='$rowTag'/>
<xsl:value-of select='$columnTag'/>
</xsl:template>



Joerg


Rajput, Ashish S wrote:
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.