User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 363,502 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,341 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser:
Views: 601 | Replies: 1 | Solved
Reply
Join Date: May 2008
Posts: 2
Reputation: micksatana is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
micksatana micksatana is offline Offline
Newbie Poster

can i update variable using concat and for-each?

  #1  
May 7th, 2008
hi,

i'm really a newbie in xslt. i try to add string to a variable using concat (there is some how my xslt processor doesn't know string-join, but that's not the point here =P)

this is some part of xml code
  1. <node0>
  2. <node1>
  3. <node1name>xxxx</node1name>
  4. <node2>
  5. <node3>01</node3>
  6. </node2>
  7. <node2>
  8. <node3>02</node3>
  9. </node2>
  10. </node1>
  11. <node1>
  12. <node1name>yyyy</node1name>
  13. <node2>
  14. <node3>03</node3>
  15. </node2>
  16. </node1>
  17. <node1>
  18. <node1name>zzzz</node1name>
  19. <node2>
  20. <node3>04</node3>
  21. </node2>
  22. </node1>
  23. </node0>

this is some part of xslt code
  1. <!-- i select $copareName before and test it already. its value is 'xxxx' -->
  2. <xsl:variable name="strTest" select="''" />
  3. <xsl:for-each select="//node2[parent::node()/node1name=$copareName]">
  4. <xsl:variable name="tmp" select="node3" />
  5. <xsl:variable name="strTest" select="concat($strTest, '/', $tmp)" />
  6. </xsl:for-each>
  7. <xsl:variable name="strTest" select="concat($strTest, '/')" />
  8. <xsl:value-of select="strTest" /><!-- the result from this line is nothing. -->

if everything works fine, the result will be
/01/02/


i also try recursive concat using xsl:template, but that make me even more confuse
Sitting and coding from 12 to 7pm, still couldn't understand why this doesn't work.

anyone pls help me. my assignment deadline is coming real soon. T-T
Last edited by micksatana : May 7th, 2008 at 5:59 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 2
Reputation: micksatana is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
micksatana micksatana is offline Offline
Newbie Poster

Re: can i update variable using concat and for-each?

  #2  
May 7th, 2008
Okay, I just find out that XSLT is declarative, not procedural. - -"
So, that's why i cannot change variable that's already declared.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb XML, XSLT and XPATH Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the XML, XSLT and XPATH Forum

All times are GMT -4. The time now is 3:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC