xsl-list
[Top] [All Lists]

Select single node having highest attribute value

2005-10-18 10:51:32
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>