Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2006, 05:03 AM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Doubt regarding variable declaration and useage

Hi All,

Is there is a way to declare varaible globally and reassign a value in one template and use it in another template.

For example,
 <xsl:variable name='testvar'></xsl:variable>


 <xsl:template match='test1'>
    <xsl:variable name='testvar'>assignedvalue</xsl:variable>
 </xsl:template>


<xsl:template match='test2'>
      <xsl:value-of select='$testvar'>
</xsl:template>


I tried this but it is not working....

Any one can help me...

regards,
dsekar_nat


__________________
Regards,
dsekar_nat
 
Old July 27th, 2006, 03:00 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT is a purely functional language, which means it has no way of assigning to variables. There's a chapter in my book explaining why this is a good thing and how you need to change your programming habits to adapt.

What you can do is to pass parameters to a template when you call it.

If you explain the problem you are trying to solve, rather than the invalid code you are trying to write, we may be able to help you.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 27th, 2006, 10:19 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes Kay I am able to understand your point. I have solved my issue without using the above mentioned methodolgy.

Regards,
dsekar_nat





Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaration of variable without initialization v_kewlani Other Programming Languages 0 May 24th, 2007 01:51 AM
i get error during declaration of variable srivastavaavivek Forum and Wrox.com Feedback 1 March 12th, 2007 09:42 AM
Declaration Expected kenn_rosie ADO.NET 7 January 17th, 2006 03:58 AM
asp variable declaration bad characters crmpicco Classic ASP Basics 2 August 18th, 2005 07:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.