File: Data.xml
0001
name 1
0002
name 2
0003
name 3
File: Query.xquery
let $prods := doc("Data.xml")//car
let $idProds := count($prods)
for $prod at $count in $prods
return if ($count = $idProds)
then concat($prod/name,".")
else concat($prod/name,",")
Output:
name 1, name 2, name 3.