I'm beginning to seriously hate the runtime error handling (or lack thereof) in XQuery. It's just too damn hard to debug what's going wrong where compared to Java. You can't see where the bad data is coming from, and there's no try-catch facility to help you out. Now that I think about it, I had very similar problems with Haskell last year. I wonder if this is a common issue with functional languages?