Is there a NULL literal in XPath 1.0 or 2.0?
My use case is that I have a conditional (if then else
) XPath expression and I want to return NULL to signify a certain condition. I am afraid that returning an empty string might be ambiguous in my case as it could be a valid result of the other part of the if then else
expression.
The empty sequence
()
can be used as such. It is also returned if there is no result for a path expression.You can check for an empty sequence using
If you pass the result of the first XPath expression to your native code, you should be able to distinguish "NULL" from the empty string by having no results (empty sequence / "NULL") or having a result string (which could be empty).