<syntaxhighlight lang="xquery">
(: equivalent queries, with identical syntax trees :)doc('addressbook.xml')//city (: equivalent query :),
doc('addressbook.xml')/descendant-or-node()/child::city
(: will be rewritten to :)
doc('addressbook.xml')/descendant::city
</syntaxhighlight>
a[b]/b[c/d]/c
(: will be rewritten to :)
a/b/c[d]
</syntaxhighlight>