Grouping of XML input with XPath 3.1 and Saxon-JS

Example input

Example XPath 3.1 code

cities/city!(@country || ', ' || @name)

Example XPath results