When I run the following code, I end up with an empty xmlns in the node that was added:
declare namespace myns = "http://hello.com/myns";
xdmp:node-insert-child(
fn:doc($file)/myns:results,
<event ts="{fn:current-dateTime()}">Removed</event>)
Result:
<?xml version="1.0" encoding="UTF-8"?>
<results xmlns="http://hello.com/myns">
<event ts="2018-09-21T15:23:23">Created</event>
<event ts="2018-09-21T15:23:28" xmlns="">Removed</event>
</results>
This causes a log of issues, any idea why this happens?
This is because the Created
event is already in the http://hello.com/myns
namespace. But the Removed
event is not in any namespace, so that's why you're seeing xmlns=""
in the XML, which designates it a no-namespace element.
If you want them all in the same namespace, you can prefix the event you are inserting or add a default namespace declaration:
<myns:event ts="...">
<event xmlns="http://hello.com/myns" ts="...">