I have this code
for $sea in distinct-values (doc("mondial.xml")//island/tokenize(@sea,"\s"))
let $count := count(doc("mondial.xml")//island[@sea = $sea]/tokenize(@sea,"\s"))
let $seacount := concat($sea," ",$count)
return $seacount
Which returns to me
"sea-ArcticOcean 3 sea-Greenlandsea 0 sea-NorwegianSea 1 sea-BarentsSea 0
sea-Atlantic 53 sea-LabradorSea 0 ..." and so on.
The number Is as you can see $count and the sea-XXX part Is the variable $sea. What I'm stuck on now Is somehow choosing the $sea which has the max value of $count of all of the counts and displaying that sea-name. I've tried things like adding a $max variable to:
for $sea in distinct-values (doc("mondial.xml")//island/tokenize(@sea,"\s"))
let $count := count(doc("mondial.xml")//island[@sea = $sea]/tokenize(@sea,"\s"))
let $seacount := concat($sea," ",$count)
$max := concat($sea," ",max($count))
return $max
Also tried adding an order by $count statement and then returning the first node:
for $sea in distinct-values (doc("mondial.xml")//island/tokenize(@sea,"\s"))
let $count := count(doc("mondial.xml")//island[@sea = $sea]/tokenize(@sea,"\s"))
let $seacount := concat($sea," ",$count)
order by $count
return $seacount[1]
Am I approaching this the wrong way or ?
Aucun commentaire:
Enregistrer un commentaire