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

RE: Can i assign value to a variable and used it in d

Subject: RE: Can i assign value to a variable and used it in different template
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 21 Sep 2004 09:54:54 +0100
xsl variable assign value
> I have the following template 
> <xsl:template name="process-style">	
> 	<xsl:if test="normalize-space($name)='border' and self::table">
> 		<xsl:variable name="bordervalue" select='"$value"'/>
> 	</xsl:if>		
> </xsl:template>

This is pretty confused. Firstly, it can only work if $name is a global
variable, which doesn't match your description. Secondly, $value looks at
first sight like an XPath variable reference, but it is actually just a
string, because you have put it in quotes. Thirdly, you are declaring a
variable bordervalue which is never referenced, and can never be referenced,
because it goes immediately out of scope. Fourthly, if this template only
does anything when the context node is a table element, why haven't you made
it a match="table" template rule?
> Actually i am used this template for processing inline 
> style.(above is a
> part of that).
> name variable contains the attribute name present in style 
> attribute.My aim
> is to
> check whether the name is border,then i store it value to 
> some variable.I
> want to use 
> this variable in  some other templates.

The scoping rules for variables mean you can't do that (just like most other
languages). You need to declare the variable inline, you can't call a
template to do it. You can then pass its value to other templates as a

Michael Kay

Current Thread


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.
First Name
Last Name
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.