<a>
{
for $o in doc("x.xml")/users/org
where fn:count($o/mem)
order by fn:count($o/mem) descending
return <org>
<b> {$o/@name/string()} </b>
<c> {$o/@ab/string()} </c>
<d> {fn:count($o/mem)} </d>
</org>
}
</a>
結果を降順に並べましたが、上位 4 つの結果だけが必要です。wiki ページの sub-sequence メソッドと [position() 1,4] メソッドを使用して上位 4 を見つけようとしましたが、成功しませんでした。