17

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 to fix it. The problem is, my XQuery evolved into a program, and XQuery is a Pain to debug. Something that I would need would be:

Print something to the command line to check whether the program has the correct nodes at that time.

A debugging tool that shows me the stored variables

Kindle Q
  • 944
  • 2
  • 19
  • 28
Arne
  • 7,921
  • 9
  • 48
  • 66

3 Answers3

5

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.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
3

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".

Brad Cox
  • 384
  • 2
  • 6
1

There are few Xml Database centric diagnostics apis. w.r.t to MarkLogic Xml Database.

  1. Diagnostics/ TaskServer UI in the admin console.
  2. Tabular Profile use their CQ application
  3. xdmp:query-trace(), xdmp:trace() are api gives some idea about the Query plan.
  4. opensource Xquery Debugger = xqdebug

are few techniques to have effective coding.

kadalamittai
  • 2,076
  • 1
  • 16
  • 19