Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for-each based on a variable

Status
Not open for further replies.

Rilez

Programmer
Jun 15, 2001
94
GB
Hi there
I'm trying to create a page that displays a schedule of work done graphically (one shift per day). Everything works like a charm but I can only show the days that are actually in the xml document itself so if someone doesn't do a shift on monday for example monday is not shown. basically I want to do the following

for i = 1 to 7
if daynumber = i then
....
else
....
end for

its the for i=... bit that I can't figure out how to do as I can't use a variable which would be my normal first step (variables that don't vary at 4:30 am is NOT a nice thing :) ). I understand that there is the posibility of using functions but cannot think of a way of doing this either. Is it possible to use some sort of array? Is there any other way I can do this.

All help will be appreciated.
 
I'm not sure I follow exactly but perhaps you could do something like this -

First create 7 nodes for the days of the week, and then use them like this:


<xsl:for-each select=&quot;//Root/Day&quot;>
<xsl:choose>
<xsl:when test=&quot;postion() = $daynumber&quot;>

do stuff

</xsl:when>
<xsl:eek:therwise>

do stuff

</xsl:eek:therwise>
</xsl:choose>
</xsl:for-each>

This may or may not help, but i hope it does! Nick (Software Developer)


nick@retrographics.fsnet.co.uk
nick.price@myenable.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top