Im new to XSLT and am having some problems trying to format an XML document which has recursive nodes.
My XML Code:
Hopefully my XML shows:
This is easy. The XSLT processor does all the recursion and the looping for you, all you need to do is to specify templates for nodes you want to handle.
-
-
The always is the recursive/iterative step in XSLT. It takes any nodes that fit its select expression and finds templates for them.
Your job is it to craft an appropriate select expression, supply a template for every node you want to handle and otherwise get out of the way. ;-) Resist the urge to cram everything into one big template or use just because it feels convenient - it is not. Separate templates create more reusable and maintainable, less deeply nested code, and XSLT processors are optimized for template handling, so this might even be the more efficient approach.