BibleGateway.com Verse Of The Day

Wednesday, August 18, 2010

Good XSL And XPath Advice

A few months ago I came across a post that I've gotten a lot of mileage out of while working on the Oracle Service Bus (OSB). I can't remember where I saw it or who said it, otherwise I would cite it, but to paraphrase:
If your XPath query is not returning any results (and you think it should), it is almost always a namespace issue.

OK, so maybe it is common knowledge, common sense, or whatever for everyone else, but for me, remembering that one statement makes XSL, XPath, and XQuery much less frustrating to deal with.

Take that statement along with the issues with the default namespace, and it can be a lifesaver.

If you have an XML with a default namespace and try searching for, say "//somenode", it won't be found, because "//somenode" will only match somenode's without any namespace. The somenode's in an XML doc with a default namespace does have a namespace.

No comments: