for $city in $country//city[population > 1000000]
group by $name := $country/name[1]
group by where
count $id
return <country id='{ $id }' name='{ $name }'>{ $city/name }</country>
start at $s when fn:true()
only end at $e when $e - $s eq 2
return <<window>>{ $w }<</window>>
</syntaxhighlight>
declare option output:omit-xml-declaration "no";
declare option output:method "xhtml";
<<html/>>
</syntaxhighlight>
'''Result:''' <code><?xml version="1.0" encoding="UTF-8"?><html></html></code>