Beyond FLWOR, XQuery has what a language needs to produce data: node constructors, string templates, conditionals, switch and typeswitch, and maps and arrays, so one query can read XML and write JSON. Declarations (namespaces, functions, options) go in the prolog before the query body.
MENU
XQuery Other Expressions
XQuery 3.1 Other Expressions and Data Types