File: Data.xml
name 1
name 2
name 3
File: Query.xquery
{ let $prods := doc("Data.xml")//car
for $prod in $prods
return if ($prod is $prods[last()])
then concat($prod/name,".")
else concat($prod/name,", ")
}
Output:
name 1, name 2, name 3.