I need to return the 5 largest elements that the loop returns. I'm trying with the position() function, but I can't...
<IsolatedData>
<LleidaData>
{
for $dl in doc ("dadesLleida.xml")//row
where $dl/residence = 'No'
order by xs:integer($dl/confirmed_cases) descending
return
<ConfirmedCases>{$dl/confirmed_cases/text(), ' - ', $dl/start_date/text()}</ConfirmedCases>
}
</LleidaData>
</IsolatedData>```
countclause you can introduce to set up a variable with the "position" and restrict it with a furtherwherefor instance. But doing(for .. where .. order .. return ..)[position() le 5]should also do. - Martin Honnen