Cedric1
(Cedric)
June 21, 2005, 9:40pm
1
Hello,
Does Someone know how I find the maximal value of attribut in an element. I show you this xquery exemple:
declare namespace xs=‘XML Schema ’
for $c in max(input()/Case[@year=xs:gYear(‘2000’) and @crit=‘BL’]/@number )
return $c
If I write this exemple, I have no answer, it take too long tim.
However, I have an index on year et crit attribut.
If I write this xquery without max() function, I hava an answer, but it is a list number and I want to have the maximum value of the number attribut.
Thank you very much for your help.
C
I’d try
declare namespace xs='http://www.w3.org/2001/XMLSchema'
max(
for $c in input()/Case
where $c/@year=xs:gYear('2000') and $c/@crit='BL'
return $c/@number
)
Cedric1
(Cedric)
June 22, 2005, 12:53pm
3
Thank you Curtis for your help, now It works very well ! :lol:
C
J_Unger
(J. Unger)
July 7, 2005, 8:21pm
4
Try this:
declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators ”
declare namespace xs = “XML Schema ”
let $max:= (
input()/Case[@year=xs:gYear(‘2000’) and @crit=‘BL’]
sort by (@number descending)
)[1]
return $max
Regards,
Joachim