Can someone help me to achieve the folowing:
In case the element has a null value then xsi:nil= "true" is kept.
Thnx.
You can use XQuery Update to achieve this, e.g. like this:
declare variable $e := <entry nil="true" />;
if ($e/@nil != "null") then (
copy $c := $e
modify (
delete node $c/@nil
)
return $c
)
else $e
Please note, that there is no actual null value in xquery as you might be familar with from languages like Java. Therefore I used a simple string here to indicate a null-value, you might want to change this.
In addition, please be aware that this function does not return the same node without the attribute, but instead it copies the node and returns this new modified node without the nil attribute.