[xsl] Using an index with a sorted list of elements

Subject: [xsl] Using an index with a sorted list of elements
From: "Hugh Dixon" <hugh.dixon@xxxxxxxxxxxxxx>
Date: Wed, 19 Mar 2003 16:33:04 +1100
I have a number of elements, similar to <element @value/>
I want to find the element that has the biggest value of "value" less
than a value $upperBound.
Eg
<elements>
<element value = "10"/>
<element value = "80"/>
<element value = "100"/>
<element value = "5"/>
</elements>

If $upperBound is 85, I want <element value = "80"/>
If $upperBound is  7, I want <element value = "5"/>

I am trying to do something like:
	<xsl:for-each select="element[$upperBound>./@value][1]">
		<xsl:sort data-type="number" select="./@value"
order="descending"/>
			<xsl:value-of select="."/>
	</xsl:for-each>

However the [1] is being applied before the sort (ie I sort a single
element!)
I cannot figure out where to stick my [1]!!!!

Is this the best way to do this?
What is the correct syntax for what I'm trying to accomplish?
Thanks!!!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread