如何在 MSXML6 上获得等效的 max()? [英] How to get equivalent of max() on MSXML6?
问题描述
显然 MSXML6 不支持 XSLT 2.0,至少不支持 max()
函数.我需要找出其兄弟节点中包含最高值的节点.它们的顺序是任意的.
Evidently MSXML6 doesn't support XSLT 2.0, at least not the max()
function. I need to find out the node that contains the highest value among its siblings. They are in arbitrary order.
我希望订单保持相同,因此添加 order-by
和检查 [0]
是不可能的.
I want the order to remain identical so adding order-by
and checking [0]
is out of question.
我想用一个 XPath 语句来做到这一点.我不想调用模板或涉及任何比这更复杂的逻辑.我确信某处嵌入了一个可怕的 MS Scripting Extensions.呃.
I want to do this with a single XPath statement. I don't want to call templates or involve any more complex logic than that. I'm sure there is a horrifying MS Scripting Extensions embedded somewhere. Eww.
我想到了:
elem1[count(../elem1[@value < current()/@value]) = 0]
但它没有像我预期的那样工作(总是返回第一个节点).你还能想到其他任何漂亮的 XPath 魔法吗?
But it didn't work as I expected (returns the first node always). Any other nifty XPath magic can you think of there?
推荐答案
尝试
elem1[not(../elem1/@value > @value)]
也就是说,您需要 elem1
,对于 not 另一个 elem1
具有更大的 @value代码>.
That is, you want the elem1
for which it is not the case that another elem1
has a greater @value
.
灵感来自这个方便的页面
这篇关于如何在 MSXML6 上获得等效的 max()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!