XML/XQuery/is
Testing for the last car using the is operator
File: Data.xml
<order>
<car model="A">
<name language="en">name 1</name>
</car>
<car model="B">
<name language="en">name 2</name>
</car>
<car model="B">
<name language="en">name 3</name>
</car>
</order>
File: Query.xquery
<p>{ let $prods := doc("Data.xml")//car
for $prod in $prods
return if ($prod is $prods[last()])
then concat($prod/name,".")
else concat($prod/name,", ")
}</p>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<p>name 1, name 2, name 3.</p>