Hello Cracks ;-)
I need to find the most occurring incidence, lets say the color that occurs
most out of
<colors>
<color>red</color>
<color>green</color>
<color>blue</color>
<color>red</color>
<color>green</color>
<color>green</color>
<color>red</color>
<color>blue</color>
<!-- .... -->
</colors>
Here my first solution
(for $color in distinct-values(//color)
order by count(//color[. eq $color]) descending
return $color)[1]
Problem: red and green have both 3 occurrences.
This works but looks horrible
for $max in max(for $color in distinct-values(//color) return count(//color[.
eq $color])),
$color in distinct-values(//color)
return
if (count(//color[. eq $color]) eq $max) then $color else ()
Any better suggestions?
Thanks in advance
Leo_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk