Subject: [xsl] Xsl:if to determine if any node matches From: "David Steketee" <dsteketee@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 13 Oct 2006 09:16:54 -0400 |
I have an XSL file which generates a calendar and an XML file which represents the month and events which occur during the month. The XML file representing the events is: <?xml version="1.0" encoding="utf-8"?> <month start="1" days="31" num="10" year="2006" today="12"> <name>October 2006</name> <Events> <Event> <GroupGUID>7F4616F5-BEB6-4A68-87E9-3FAD45BD25CB</GroupGUID> <EventID>1</EventID> <EventTitle>Fundraiser</EventTitle> <StartDate>2006-10-09T00:00:00</StartDate> <EndDate>2006-10-11T00:00:00</EndDate> <Depth>1</Depth> <Date> <EventDateID>1</EventDateID> <EventDate>2006-10-09T00:00:00</EventDate> <EventStartTime>2006-10-09T09:00:00</EventStartTime> <EventEndTime>2006-10-09T21:00:00</EventEndTime> </Date> <Date> <EventDateID>2</EventDateID> <EventDate>2006-10-11T00:00:00</EventDate> <EventStartTime>2006-10-11T09:00:00</EventStartTime> <EventEndTime>2006-10-11T21:00:00</EventEndTime> </Date> </Event> <Event> <GroupGUID>7F4616F5-BEB6-4A68-87E9-3FAD45BD25CB</GroupGUID> <EventID>2</EventID> <EventTitle>Fundraiser</EventTitle> <StartDate>2006-10-12T00:00:00</StartDate> <EndDate>2006-10-12T00:00:00</EndDate> <Depth>1</Depth> <Date> <EventDateID>1</EventDateID> <EventDate>2006-10-12T00:00:00</EventDate> <EventStartTime>2006-10-12T09:00:00</EventStartTime> <EventEndTime>2006-10-12T21:00:00</EventEndTime> </Date> </Event> </Events> </month> In the XSL I attempt to determine if the current date in the loop exists in the event list. ($index-$start+1 represents the current date) <xsl:choose> <xsl:when test="(substring(//EventDate/., 9, 2) = $index - $start +1)"> <xsl:element name="a"> <xsl:attribute name="href">javascript:viewDate(<xsl:value-of select="$index - $start +1"/>);</xsl:attribute> <xsl:value-of select="$index - $start + 1"/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="a"> <xsl:attribute name="href">javascript:void(0);</xsl:attribute> <xsl:value-of select="$index - $start + 1"/> </xsl:element> </xsl:otherwise> </xsl:choose> The problem I've encountered is the test only seems to match the first instance of the /Events/Event/Date/EventDate as opposed to any of the instances of EventDate. So my resulting HTML has the 9th highlighted, but not the 11th or 12th. I could loop through all of the EventDates using for each, but that would seem wasteful to loop through a potentially large XML for every day of the month. Does anyone have any thoughts on why it's only matching the first instance of EventDate? David Steketee ____________________ technology consultant http://www.visualstructures.com/ (P) 917-432-4459
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL and XML Help, Cho, Minho | Thread | [xsl] Newbie Question: Creating Err, Badari |
RE: [xsl] XSL and XML Help, Cho, Minho | Date | Re: [xsl] XSL and XML Help, Abel Braaksma |
Month |