In the beginning, I wrote a little XQuery script that was designed to do a small task and only that. Now it came out that this XQuery script is anything but complete, and I have
As Dimitre suggested, trace() is what I fall back on when nothing else works. Messy but it works.
Instead of: $foo := anyXqueryExpression
Do this: $foo := trace(anyXqueryExpression, "text")
Logs the result of executing anyXqueryExpression and adds the prefix "text".