[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Select single node having highest attribute value

Subject: Select single node having highest attribute value
From: "Nick Fitzsimons" <nick@xxxxxxxxxxxxxx>
Date: Tue, 18 Oct 2005 18:51:32 +0100 (BST)
select single node
I'm probably losing it being unable to get my head round this one (it's
been a long week, and it's only Tuesday...), but maybe somebody can set me
right, and then I can leave work and get my dinner :-)

I have a set of nodes which are in a random order (simplified example
captures all the needful):

<blocks>
   <block priority="23">Something</block>
   <block priority="-17">Nothing</block>
   <block priority="29">Anything</block>
   <block priority="12">Everything</block>
</block>

I want to apply a template to the node "block" having the highest numeric
value for the attribute named "priority", using XSLT 1.0. So in the case
above, I'd process <block priority="29">Anything</block>.

Something like

<xsl:apply-templates select="blocks/block[maximum-value-of(@priority)]" />

would be perfect, but as we know, the world isn't perfect.

FYI:

I can't use any extension functions (the client doesn't want to take the
risk of being stuck in the future, when I'm long gone);

The lower and upper bounds for any given dataset cannot be predicted and
can be negative;

I can't use an XSLT pipeline to pre-order the dataset (they won't change
their corporation-wide CMS just for me).

Anybody got any ideas?

TIA,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.