[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Variables in XSL!
No, it is not possible to assign to a variable in XSL / XSLT. XSL is intentionally designed to be free from side-effects, meaning a sections could be evaluated in any order. Obviously, assignment to a variable would break this. For an explanation of why this is a good thing, see Michael Kay's XSLT 2nd Edition, p. 37-38. So, obviously XSL is a very different kind of language. When you think VBScript, you are thinking about _procedural_ programming languages. XSL is a _declarative_ language. This doesn't mean you can't achieve the behavior you want, it just means that you have to think about it in a different way. When you write i=i+1 you are iterating over a set of values, which you can't do in XSL. But you can use recursion which is provided by the <xsl:apply-templates> and <xsl:for-each> tags. Again see Michael Kay's book, the section on Computational Stylesheets, p. 608-627, esp. p. 620 which virtually restates your problem. Cheers, Stuart -----Original Message----- From: Peter Thornqvist [mailto:thornqvist_peter@h...] Sent: Tuesday, November 27, 2001 20:03 To: xml-dev@l... Subject: Variables in XSL! Hi! Is it possible to have variables/counters in XSL, like in vbscript: i=i+1 etc?. I would like to keep track of when the 10th value comes and then do a line break... /Peter _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://lists.xml.org/ob/adm.pl>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|