File: Data.xml
0001
name 1
0002
name 2
0003
name 3
0004
name 4
File: Query.xquery
let $sortedProds := for $prod in doc("Data.xml")//car
where $prod/@model = "B" or $prod/@model = "C"
order by $prod/name
return $prod
for $sortedProd at $count in $sortedProds
return {$count}. {data($sortedProd/name)}
Output:
1. name 2
2. name 3
3. name 4