UPDATE reflect changes in libyang API

- changed handling of data inside anyxml/anydata nodes. We have to
strictly disting between YANG based XML data and other data, since
other data content is supposed to be escaped (< or &) when printed
in XML document.
diff --git a/src/session_client.c b/src/session_client.c
index a3b7d85..f761ab8 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -198,7 +198,7 @@
     struct nc_rpc *rpc;
     struct nc_reply *reply;
     struct nc_reply_data *data_rpl;
-    struct lyd_node_anyxml *get_schema_data;
+    struct lyd_node_anydata *get_schema_data;
     NC_MSG_TYPE msg;
     char *model_data = NULL;
     uint64_t msgid;
@@ -244,11 +244,18 @@
         nc_reply_free(reply);
         return NULL;
     }
-    get_schema_data = (struct lyd_node_anyxml *)data_rpl->data->child;
-    if (get_schema_data->xml_struct) {
-        lyxml_print_mem(&model_data, get_schema_data->value.xml, LYXML_PRINT_SIBLINGS);
-    } else {
+    get_schema_data = (struct lyd_node_anydata *)data_rpl->data->child;
+    switch (get_schema_data->value_type) {
+    case LYD_ANYDATA_CONSTSTRING:
+    case LYD_ANYDATA_STRING:
         model_data = strdup(get_schema_data->value.str);
+        break;
+    case LYD_ANYDATA_DATATREE:
+        lyd_print_mem(&model_data, get_schema_data->value.tree, LYD_XML, LYP_WITHSIBLINGS);
+        break;
+    case LYD_ANYDATA_XML:
+        lyxml_print_mem(&model_data, get_schema_data->value.xml, LYXML_PRINT_SIBLINGS);
+        break;
     }
     nc_reply_free(reply);
     *free_model_data = free;
@@ -1314,7 +1321,7 @@
     struct nc_rpc_subscribe *rpc_sub;
     struct lyd_node *data, *node;
     const struct lys_module *ietfnc = NULL, *ietfncmon, *notifs, *ietfncwd = NULL;
-    char str[11], *filter;
+    char str[11];
     uint64_t cur_msgid;
 
     if (!session) {
@@ -1362,18 +1369,10 @@
         }
         if (rpc_gc->filter) {
             if (!rpc_gc->filter[0] || (rpc_gc->filter[0] == '<')) {
-                /* we need a copy of the filter */
-                filter = strdup(rpc_gc->filter);
-                if (!filter) {
-                    ERRMEM;
-                    lyd_free(data);
-                    return NC_MSG_ERROR;
-                }
-
-                node = lyd_new_anyxml_str(data, ietfnc, "filter", filter);
+                node = lyd_new_anydata(data, ietfnc, "filter", rpc_gc->filter, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "subtree");
             } else {
-                node = lyd_new_anyxml_str(data, ietfnc, "filter", NULL);
+                node = lyd_new_anydata(data, ietfnc, "filter", NULL, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "xpath");
                 lyd_insert_attr(node, NULL, "select", rpc_gc->filter);
             }
@@ -1451,15 +1450,7 @@
         }
 
         if (rpc_e->edit_cont[0] == '<') {
-            /* we need a copy of the content */
-            filter = strdup(rpc_e->edit_cont);
-            if (!filter) {
-                ERRMEM;
-                lyd_free(data);
-                return NC_MSG_ERROR;
-            }
-
-            node = lyd_new_anyxml_str(data, ietfnc, "config", filter);
+            node = lyd_new_anydata(data, ietfnc, "config", rpc_e->edit_cont, LYD_ANYDATA_CONSTSTRING);
         } else {
             node = lyd_new_leaf(data, ietfnc, "url", rpc_e->edit_cont);
         }
@@ -1487,15 +1478,7 @@
         node = lyd_new(data, ietfnc, "source");
         if (rpc_cp->url_config_src) {
             if (rpc_cp->url_config_src[0] == '<') {
-                /* we need a copy of the content */
-                filter = strdup(rpc_cp->url_config_src);
-                if (!filter) {
-                    ERRMEM;
-                    lyd_free(data);
-                    return NC_MSG_ERROR;
-                }
-
-                node = lyd_new_anyxml_str(node, ietfnc, "config", filter);
+                node = lyd_new_anydata(node, ietfnc, "config", rpc_cp->url_config_src, LYD_ANYDATA_CONSTSTRING);
             } else {
                 node = lyd_new_leaf(node, ietfnc, "url", rpc_cp->url_config_src);
             }
@@ -1585,18 +1568,10 @@
         data = lyd_new(NULL, ietfnc, "get");
         if (rpc_g->filter) {
             if (!rpc_g->filter[0] || (rpc_g->filter[0] == '<')) {
-                /* we need a copy of the filter */
-                filter = strdup(rpc_g->filter);
-                if (!filter) {
-                    ERRMEM;
-                    lyd_free(data);
-                    return NC_MSG_ERROR;
-                }
-
-                node = lyd_new_anyxml_str(data, ietfnc, "filter", filter);
+                node = lyd_new_anydata(data, ietfnc, "filter", rpc_g->filter, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "subtree");
             } else {
-                node = lyd_new_anyxml_str(data, ietfnc, "filter", NULL);
+                node = lyd_new_anydata(data, ietfnc, "filter", NULL, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "xpath");
                 lyd_insert_attr(node, NULL, "select", rpc_g->filter);
             }
@@ -1700,15 +1675,7 @@
         node = lyd_new(data, ietfnc, "source");
         if (rpc_val->url_config_src) {
             if (rpc_val->url_config_src[0] == '<') {
-                /* we need a copy of the config */
-                filter = strdup(rpc_val->url_config_src);
-                if (!filter) {
-                    ERRMEM;
-                    lyd_free(data);
-                    return NC_MSG_ERROR;
-                }
-
-                node = lyd_new_anyxml_str(node, ietfnc, "config", filter);
+                node = lyd_new_anydata(node, ietfnc, "config", rpc_val->url_config_src, LYD_ANYDATA_CONSTSTRING);
             } else {
                 node = lyd_new_leaf(node, ietfnc, "url", rpc_val->url_config_src);
             }
@@ -1772,18 +1739,10 @@
 
         if (rpc_sub->filter) {
             if (!rpc_sub->filter[0] || (rpc_sub->filter[0] == '<')) {
-                /* we need a copy of the filter */
-                filter = strdup(rpc_sub->filter);
-                if (!filter) {
-                    ERRMEM;
-                    lyd_free(data);
-                    return NC_MSG_ERROR;
-                }
-
-                node = lyd_new_anyxml_str(data, notifs, "filter", filter);
+                node = lyd_new_anydata(data, notifs, "filter", rpc_sub->filter, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "subtree");
             } else {
-                node = lyd_new_anyxml_str(data, notifs, "filter", NULL);
+                node = lyd_new_anydata(data, notifs, "filter", NULL, LYD_ANYDATA_CONSTSTRING);
                 lyd_insert_attr(node, NULL, "type", "xpath");
                 lyd_insert_attr(node, NULL, "select", rpc_sub->filter);
             }
diff --git a/src/session_server.c b/src/session_server.c
index fefb58f..5a93800 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -338,13 +338,13 @@
         return NULL;
     }
 
-    data = lyd_new_path(NULL, server_opts.ctx, "/ietf-netconf-monitoring:get-schema/data", model_data, LYD_PATH_OPT_OUTPUT);
+    data = lyd_new_path(NULL, server_opts.ctx, "/ietf-netconf-monitoring:get-schema/data", model_data,
+                        LYD_ANYDATA_STRING, LYD_PATH_OPT_OUTPUT);
     if (!data) {
         ERRINT;
         free(model_data);
         return NULL;
     }
-    free(model_data);
 
     return nc_server_reply_data(data, NC_PARAMTYPE_FREE);
 }