tree data UPDATE store default NS for XML prefix data

May be needed for unprefixed identity resolution.
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 5c17aa8..22c6af6 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -148,6 +148,11 @@
         set = prefix_data;
         for (i = 0; i < set->count; ++i) {
             ns = set->objs[i];
+            if (!ns->prefix) {
+                /* default namespace is not for the element */
+                continue;
+            }
+
             xml_print_ns(pctx, ns->uri, (prefix_opts & LYXML_PREFIX_DEFAULT) ? NULL : ns->prefix, prefix_opts);
         }
         break;
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index d1635c2..c5a0e2a 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -941,6 +941,18 @@
             ns_list = *prefix_data_p;
         }
 
+        /* store default namespace */
+        ns = lyxml_ns_get(prefix_data, NULL, 0);
+        if (ns) {
+            new_ns = calloc(1, sizeof *new_ns);
+            LY_CHECK_ERR_GOTO(!new_ns, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+            LY_CHECK_GOTO(ret = ly_set_add(ns_list, new_ns, 1, NULL), cleanup);
+
+            new_ns->prefix = NULL;
+            new_ns->uri = strdup(ns->uri);
+            LY_CHECK_ERR_GOTO(!new_ns->uri, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+        }
+
         /* add all used prefixes */
         value_end = (char *)value + value_len;
         for (value_iter = value; value_iter; value_iter = value_next) {