Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 9th, 2007, 03:04 PM
Authorized User
Points: 235, Level: 4
Points: 235, Level: 4 Points: 235, Level: 4 Points: 235, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2007
Location: , , .
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default How to increment/decrement a parameter in XSL

Hello,
I have a need to increase and decrease a column position variable in XSLT. HTML cells are generated from an xsl:apply-templates construct that recursively traverses hierarchically-arranged elements in the corresponding XML file. The problem I face is not knowing how, in XSLT, to maintain a column position value as the tree nodes are added (and as the template is repeatedly called from itself).

In other words, the column value would grow and shrink depending on the where the element is in the hierarchy. In java I could do this easily, but am struggling to do the same thing in XSLT. Any insights are greatly appreciated. Thanks.

Reply With Quote
  #2 (permalink)  
Old February 9th, 2007, 03:46 PM
mhkay's Avatar
Wrox Author
Points: 18,274, Level: 58
Points: 18,274, Level: 58 Points: 18,274, Level: 58 Points: 18,274, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,932
Thanks: 0
Thanked 282 Times in 277 Posts
Default

You can't change the values of variables in a declarative language. So the answer to your question is that you need to think about the problem a different way. If you describe the problem, rather than the way you would tackle it in Java, then it might be possible to suggest the right approach in XSLT.

However, you're already using recursion so it seems you are part way there. Usually in this kind of problem it's just a question of calculating the values of parameters to pass to the recursive templates.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old February 9th, 2007, 04:24 PM
Authorized User
Points: 235, Level: 4
Points: 235, Level: 4 Points: 235, Level: 4 Points: 235, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2007
Location: , , .
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Totally figured it out on my own. Thanks for assistance ;)

Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Post a parameter to XSL in Safari Jason.Shang Javascript 0 August 18th, 2008 10:06 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 11:32 PM
XSL - Parameter query. Neal XSLT 4 January 24th, 2006 01:27 PM
how to build a JavaScript for loop decrement (--) crmpicco Javascript How-To 2 November 15th, 2005 12:24 PM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 04:15 AM



All times are GMT -4. The time now is 10:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.