Loops

May 25, 2010 at 9:18 AM

Having created a custom Timesheet application, I needed to create a report of all outstanding timesheets for users - i.e. users who either hadn't submitted their forecast time entries, or not entered any data at all.

I created a DVWP that would look through the data and show where there was data that was still set to "forecast", but couldn't report where there was no data - well not by using a simple out-of-the-box DVWP.

I therefore created an XSLT that built up an XML node set of all the possible dates (the "week ending" dates) from a dynamic starting point (each user has a start date set before which they cannot add time). This website got me started with understanding how to implement a loop in XSLT: http://snippets.dzone.com/posts/show/930. Basically, it's a recursive call-template. For my purposes, I modified it to be a "while" loop (while date <= today). On each time round the loop, rather than adding 1 to a numeric loop counter, I added a week to a date (hence my post about date functions a moment ago!!).

Hope that helps someone else as it helped me!

Alex