tree data BUGFIX do not require string value in dictionary

... when using them in any node values. It was not
documented and redundant.
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 2cd4158..1399e12 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1120,7 +1120,6 @@
     struct lyd_meta *meta = NULL;
     LYD_ANYDATA_VALUETYPE value_type;
     char *value = NULL;
-    const char *val_dict;
     uint32_t flags;
     const struct ly_ctx *ctx = lybctx->lybctx->ctx;
 
@@ -1155,25 +1154,12 @@
     switch (value_type) {
     case LYD_ANYDATA_LYB:
     case LYD_ANYDATA_DATATREE:
-        /* use the value directly */
-        ret = lyd_create_any(snode, value, value_type, 1, &node);
-        LY_CHECK_GOTO(ret, error);
-
-        break;
     case LYD_ANYDATA_STRING:
     case LYD_ANYDATA_XML:
     case LYD_ANYDATA_JSON:
-        /* value is expected to be in the dictionary */
-        ret = lydict_insert_zc(ctx, value, &val_dict);
-        value = NULL;
+        /* use the value directly */
+        ret = lyd_create_any(snode, value, value_type, 1, &node);
         LY_CHECK_GOTO(ret, error);
-
-        /* use the value in the dictionary */
-        ret = lyd_create_any(snode, val_dict, value_type, 1, &node);
-        if (ret) {
-            lydict_remove(ctx, val_dict);
-            goto error;
-        }
         break;
     default:
         LOGINT(ctx);
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 224b3c3..77cd720 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -12,12 +12,15 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#define _GNU_SOURCE
+
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "common.h"
+#include "compat.h"
 #include "context.h"
 #include "dict.h"
 #include "in_internal.h"
@@ -491,7 +494,7 @@
 lydxml_subtree_r(struct lyd_xml_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p, struct ly_set *parsed)
 {
     LY_ERR ret = LY_SUCCESS, r;
-    const char *prefix, *name, *val;
+    const char *prefix, *name;
     size_t prefix_len, name_len;
     struct lyxml_ctx *xmlctx;
     const struct ly_ctx *ctx;
@@ -506,6 +509,7 @@
     LY_VALUE_FORMAT format;
     uint32_t getnext_opts;
     ly_bool parse_subtree;
+    char *val;
 
     assert(parent || first_p);
 
@@ -748,14 +752,15 @@
 
         if (!xmlctx->ws_only) {
             /* use an arbitrary text value for anyxml */
-            lydict_insert(xmlctx->ctx, xmlctx->value, xmlctx->value_len, &val);
+            val = strndup(xmlctx->value, xmlctx->value_len);
+            LY_CHECK_ERR_GOTO(!val, LOGMEM(xmlctx->ctx); ret = LY_EMEM, error);
 
             /* parser next */
             LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
 
             /* create node */
             ret = lyd_create_any(snode, val, LYD_ANYDATA_STRING, 1, &node);
-            LY_CHECK_GOTO(ret, error);
+            LY_CHECK_ERR_GOTO(ret, free(val), error);
         } else {
             /* parser next */
             LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
diff --git a/src/tree_data.c b/src/tree_data.c
index b1106ff..2ab998e 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -810,7 +810,19 @@
     /* TODO: convert XML/JSON strings into a opaq data tree */
 
     if (use_value) {
-        any->value.str = value;
+        switch (value_type) {
+        case LYD_ANYDATA_DATATREE:
+            any->value.tree = (void *)value;
+            break;
+        case LYD_ANYDATA_STRING:
+        case LYD_ANYDATA_XML:
+        case LYD_ANYDATA_JSON:
+            lydict_insert_zc(schema->module->ctx, (void *)value, &any->value.str);
+            break;
+        case LYD_ANYDATA_LYB:
+            any->value.mem = (void *)value;
+            break;
+        }
         any->value_type = value_type;
     } else {
         any_val.str = value;
diff --git a/src/tree_data.h b/src/tree_data.h
index 8b3640c..a5397b8 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -1375,7 +1375,7 @@
  * @param[in] module Module of the node being created. If NULL, @p parent module will be used.
  * @param[in] name Schema node name of the new data node. The node can be #LYS_ANYDATA or #LYS_ANYXML.
  * @param[in] value Value for the node. Expected type is determined by @p value_type.
- * @param[in] use_value Whether to directly take @p value and assign it to the node or make a copy.
+ * @param[in] use_value Whether to use dynamic @p value or make a copy.
  * @param[in] value_type Type of the provided value in @p value.
  * @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
  * taken into consideration. Otherwise, the output's data node is going to be created.
@@ -1394,7 +1394,7 @@
  * @param[in] ext Extension instance where the any node being created is defined.
  * @param[in] name Schema node name of the new data node. The node can be #LYS_ANYDATA or #LYS_ANYXML.
  * @param[in] value Value for the node. Expected type is determined by @p value_type.
- * @param[in] use_value Whether to directly take @p value and assign it to the node or make a copy.
+ * @param[in] use_value Whether to use dynamic @p value or make a copy.
  * @param[in] value_type Type of the provided value in @p value.
  * @param[out] node The created node.
  * @return LY_ERR value.
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 90de1f8..3cf45c6 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -270,7 +270,7 @@
  * @param[in] schema Schema node of the new data node.
  * @param[in] value Value of the any node.
  * @param[in] value_type Value type of the value.
- * @param[in] use_value Whether to directly assign (eat) the value or duplicate it.
+ * @param[in] use_value Whether to use dynamic @p value or duplicate it.
  * @param[out] node Created node.
  * @return LY_SUCCESS on success.
  * @return LY_ERR value if an error occurred.