|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using an index with a sorted list of elements
Hugh,
> 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.
I would try to think about it more like this. Let me sort the values first,
and then grab the value I want (i.e. small easy steps will get me there
sooner).
<x:for-each select="//*[@value < $upperBound]">
<x:sort data-type="number" order="descending" select="@value"/>
<x:if test="position() = 1"><x:value-of
select="@value"/></x:if>
</x:for-each>
To break it down, this selects every node that has a @value less than the
upper bound, and then sorts based on that value attribute in a descending
order. Then, it selects the first one. There's probably another, slicker
way to do this with the [1], but I think this will work for you.
bix
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








