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
Something that I would need would be:
print something to the command line to check weather the progroms has the correct nodes at that time.
Use the standard XPath 2.0 function trace().
a debugging tool that shows me the stored variables
There are varios IDEs for XQuery that come up with a Debugger. For example, have a look at oXygen.