XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2004, 05:51 AM
Gunjan Sharma Gunjan Sharma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 Gunjan Sharma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation xsl:variable

Hi Friends,
I stuck into a problem, could any body suggest me how can we assign the value to a global variable in the template or it's not allowed in xsl.I am trying...

<xsl:variable name="out" select="$l+1"/>

here out is global variable which i declared above the template & "l" is a local variable.

Thanks
Gunjan

Reply With Quote
  #2  
Old June 1st, 2004, 07:32 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
i hope this is what u r looking for

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="no" encoding="utf-8"/>
<xsl:variable name="in" select="1000"/>
<xsl:template match="/">
<xsl:variable name="out" expr="$in + 1"/>
<xsl:value-of select="$out"/>
</xsl:template>

</xsl:stylesheet>


---------------------
with regards
niha

Reply With Quote
  #3  
Old June 2nd, 2004, 02:27 AM
Gunjan Sharma Gunjan Sharma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 Gunjan Sharma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What i want?

Thanks niha for the reply what exactly i am trying to do is like that

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="no" encoding="utf-8"/>
<xsl:variable name="out" select="1000"/>
<xsl:template match="/">
<xsl:variable name="in" select="6"/>

<!-- Now i want to manipulate the value of "out" so i can use it for diffrent purpose in the template -->

<xsl:variable name="out" expr="$in +1"/>
</xsl:template>

</xsl:stylesheet>


Hope now you can understand

Thanks
Gunjan

Reply With Quote
  #4  
Old June 2nd, 2004, 04:22 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
sorry i could not understand

sorry i could not understand actually..
bcoz i copied ur code and executed it is working fine to me
anyway sorry i could not be more helpful
------------------------



<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="no" encoding="utf-8"/>
<!--<xsl:variable name="in" select="1000"/>
<xsl:template match="/">
<xsl:variable name="out" expr="$in + 1"/>
<xsl:value-of select="$out"/>
</xsl:template>-->


<xsl:variable name="out" select="1000"/>
<xsl:template match="/">
<xsl:variable name="in" select="8"/>

<!-- Now i want to manipulate the value of "out" so i can use it for diffrent purpose in the template -->

<xsl:variable name="out" expr="$in +1"/>


<xsl:value-of select="$out"/>
<br/>

<xsl:value-of select="$out+1"/>

</xsl:template>





</xsl:stylesheet>


---------------------
regards
niha

Reply With Quote
  #5  
Old June 2nd, 2004, 04:40 AM
Gunjan Sharma Gunjan Sharma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 Gunjan Sharma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
please Just tell me that?

Is it possible in XSL that we assign the value to a global variable & later in the template we modify it's value.

Thanks
Gunjan

Reply With Quote
  #6  
Old June 2nd, 2004, 06:33 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
xslt variables can not be updated

hi
according to XSLT Programmers reference Michael Kays book
" unlike variables in many programming languages, XSLT variables can not be updated. Once they are given a innitial value, they retain that value until they go out of scope" (pg no:: 336)

in ur case global variable means its scope is in entire that program so you can not updated it - this is whats my opinion anyway...if anyone out there got another theory would like to hear

hope this info helps

with regards
niha

Reply With Quote
  #7  
Old June 2nd, 2004, 07:34 AM
Gunjan Sharma Gunjan Sharma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 Gunjan Sharma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Thanx niha that's what i just want to confirm.

Regards
Gunjan

Reply With Quote
  #8  
Old June 3rd, 2004, 07:27 AM
mikkri mikkri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 67 mikkri User rank is Private First Class (20 - 50 Reputation Level)mikkri User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 24 m 52 sec
Reputation Power: 5
Hello,

Small tip.
Usually you can use template calls or even recursive calls instead changing variable value. So use template parameter instead variable.
__________________
Java, DB, XML Consultant
www.mikkri.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xsl:variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT