Here’s the thing… I have a query:
for $item in doc("order.xml")//item
$name:= doc("catalog.xml")//product[number = $item/@num]/name
return <item num="{$item/@num" (: a1 :)
name="{$name}" (: a2 :)
quan="{$item/@quantity}"/> (: a3 :)
…. No commas, right? Later, it says “If the comma after firstresult were not there, it would be a syntax error because there would be two separate expressions in the query body,” about a different query:
declare boundary-space preserve;
declare namespace prod = "http://datypic.com/prod";
declare variable $catalog := doc("catalog.xml")//catalog;
<firstResult>{count($catalog/product)}</firstResult> (: b1 :)
<prod:secondResult>{$catalog/product/number}</prod:secondResult> (: b2 :)
Where is the line drawn between “separate queries” (b1 and b2) and “separate parts of the same query” (a1, a2, and a3)?
hmm its just that…
(a1, a2, a3) is a single element node, but spanned on multiple lines (thats allowed!)
on the other hand (b1, b2) are two separate element nodes, and to make a sequence ya need to put a comma