Conditional and looping commands, such as if and for, are essential to nearly every programming language on the planet. Conditional structures allow you to execute parts of a program when certain conditions are met. Looping statements enable you to cycle through a series of values or objects and perform actions with them. The practical effect is that both kinds give you greater control and flexibility to do what you are trying to do in your code. Ever wonder how different XSLT is from traditional programming languages? Consider this: When you learn C++, Java, or Visual Basic, conditional and loop statements are some of the first things you learn about. In XSLT, however, conditionals and loops arent as important, primarily because of the way XSLT makes use of template rules. A template rule certainly has something akin to conditional and looping structure built into it: For all the nodes that match its pattern, do something or else skip the template altogether. Having said that, although you can do a heck of a lot in XSLT without ever touching these control structures, there are certain tasks you just cannot perform without them. |