One question, two expressions.
Find the accounts in one case and return their handles alphabetically. For XQuery 3.1, $accounts is a supplied sequence of maps with string-valued handle and case entries. For CGQL, accounts is a JSON document collection.
for $a in $accounts
where $a?case eq "CS-0412"
order by $a?handle
return $a?handleFOR a IN accounts
FILTER a.case == "CS-0412"
SORT a.handle
RETURN a.handleThe same three fixture records produce dispatch-04, marla.v and rook_77: a sequence in XQuery, a result array in CGQL.
The parts that feel familiar.
| Intent | XQuery | CGQL |
|---|---|---|
| Iterate & bind | for, let | FOR, LET |
| Keep rows | where | FILTER |
| Order results | order by | SORT |
| Shape output | return | RETURN |
Keep the data model in view.
XQuery works with XML nodes and atomic values; version 3.1 also supports maps and arrays for JSON-oriented work. Its FLWOR expressions explain the familiar clause structure.
CGQL works with JSON documents and graph edges. Its OUTBOUND, INBOUND and ANY traversals follow an edge collection over a bounded depth. XPath axes, XML constructors and XQuery modules have no direct CGQL counterpart.
This is a guide to transferring query habits. CGQL does not execute XQuery, and importing XML requires a separate data transformation.