I am new to XQuery. Please guide me to solve the issue below I want to return the null
value as a string, if the below expression does not give any value.
Currently, the output doesn't show the 'name' field itself. I want to have a name with null
. for eg-
if (IsNull(expression),null,expression)
$output.dataAccessResponse[1]/*:row/*:name/text()
You could use the
fn:exists()
function to test whether or not there is atext()
node.You could also use the
fn:boolean()
function to test the effective boolean value of the node.If you wanted to test whether or not there was a significant value i.e. something other than whitespace, you can
fn:normalize-space()
in a predicate, to ensure that onlytext()
nodes that have meaningful text are selected, and then testfn:exists()
.XQuery doesn't have
null
, so if you are asking what to return to indicatenull
, then you would want to return an empty sequence()
instead ofnull
.So, you could execute something like this:
But at that point, it's really the same as just attempting to select the
text()
with that XPath and it will either return thetext()
node or an empty sequence: