home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeXSLSearch this book

D.6. How Do I Implement a for Loop?

The simple answer: you don't. What XSLT calls variables are variables in the mathematical sense of the term. An <xsl:variable> can be assigned an initial value, but it can't be changed. The upshot of this situation is that you can't implement a for loop as you typically do in most procedural programming languages. However, earlier in the book we did implement a stylesheet that emulates a for loop. See Section 4.7, "A Stylesheet That Emulates a for Loop" in Chapter 4, "Branching and Control Elements" for a complete discussion of this example.

It's much more likely that you need to iterate across a group of nodes in an XML document. If that's the case, see Section 4.2.3, "The <xsl:for-each> Element" in Chapter 4, "Branching and Control Elements" for more information.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru