[xsl] Selecting parent node based upon child node value

Subject: [xsl] Selecting parent node based upon child node value
From: "David Steketee" <dsteketee@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Oct 2006 09:18:28 -0400
I have an XSLT document which generates a calendar, and an XML document
which represents the month and events which occur within the month. I'm
using the XSLT parser in .NET 2.0 which I believe only supports XSLT 1.0.

The XML document is as follows:

<?xml version="1.0" encoding="utf-8"?>
<month start="1" days="31" num="10" year="2006" today="12">
	<name>October 2006</name>

While generating the calendar, I need to determine if an Event node exists
where the EventDate is equal to the day being generated by the calendar XSLT
as it loops through all of the days of the month. If there is an event which
falls on that day, then I need to create a link which passes the EventID of
the Event which contains the Date.

The XSL document contains the following code where I'm attempting to perform
this "query".

      <xsl:when test="$index > $start - 1">
	<xsl:element name="td">
		<xsl:if test="($index - $start + 1) = $today">
			<xsl:attribute name="class">Today</xsl:attribute>

		<xsl:element name="a">
			<xsl:value-of select="$index - $start + 1"/>
$index - $start + 1 is the number of the day being generated which would
match the EventDate of the Event. 

I've found a few examples elsewhere in the archive
(http://www.biglist.com/lists/xsl-list/archives/200207/msg01433.html) but
haven't been able to find anything which does what I need.

I could loop through all the events to determine if there is a match but
this seems wasteful and based upon the link above there seems to be a more
effective approach available, but unfortunately a bit beyond my
understanding of XSLT / XPATH.

Thank you in advance for any suggestions.

David Steketee

Current Thread