p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   How to increment/decrement a parameter in XSL (http://p2p.wrox.com/showthread.php?t=53863)

tclotworthy February 9th, 2007 03:04 PM

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.


mhkay February 9th, 2007 03:46 PM

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

tclotworthy February 9th, 2007 04:24 PM

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



All times are GMT -4. The time now is 01:55 PM.

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