log UPDATE parser data path print

Fixes #1930
diff --git a/src/log.c b/src/log.c
index 6c14c33..c654771 100644
--- a/src/log.c
+++ b/src/log.c
@@ -31,6 +31,7 @@
 #include "plugins_exts.h"
 #include "set.h"
 #include "tree_data.h"
+#include "tree_data_internal.h"
 #include "tree_schema.h"
 
 ATOMIC_T ly_ll = (uint_fast32_t)LY_LLWRN;
@@ -530,11 +531,61 @@
     va_end(ap);
 }
 
+/**
+ * @brief Append a schema node name to a generated data path, only if it fits.
+ *
+ * @param[in,out] str Generated path to update.
+ * @param[in] snode Schema node to append.
+ * @param[in] parent Last printed data node.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+ly_vlog_build_path_append(char **str, const struct lysc_node *snode, const struct lyd_node *parent)
+{
+    const struct lys_module *mod, *prev_mod;
+    uint32_t len, new_len;
+    void *mem;
+
+    if (snode->nodetype & (LYS_CHOICE | LYS_CASE)) {
+        /* schema-only node */
+        return LY_SUCCESS;
+    } else if (lysc_data_parent(snode) != parent->schema) {
+        /* not a direct descendant node */
+        return LY_SUCCESS;
+    }
+
+    /* get module to print, if any */
+    mod = snode->module;
+    prev_mod = (parent->schema) ? parent->schema->module : lyd_owner_module(parent);
+    if (prev_mod == mod) {
+        mod = NULL;
+    }
+
+    /* realloc string */
+    len = strlen(*str);
+    new_len = len + 1 + (mod ? strlen(mod->name) + 1 : 0) + strlen(snode->name);
+    mem = realloc(*str, new_len + 1);
+    LY_CHECK_ERR_RET(!mem, LOGMEM(LYD_CTX(parent)), LY_EMEM);
+    *str = mem;
+
+    /* print the last schema node */
+    sprintf(*str + len, "/%s%s%s", mod ? mod->name : "", mod ? ":" : "", snode->name);
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Build log path from the stored log location information.
+ *
+ * @param[in] ctx Context to use.
+ * @param[out] path Generated log path.
+ * @return LY_ERR value.
+ */
 static LY_ERR
 ly_vlog_build_path(const struct ly_ctx *ctx, char **path)
 {
-    int rc;
+    int r;
     char *str = NULL, *prev = NULL;
+    const struct lyd_node *dnode;
 
     *path = NULL;
 
@@ -543,45 +594,54 @@
         *path = strdup((const char *)log_location.paths.objs[log_location.paths.count - 1]);
         LY_CHECK_ERR_RET(!(*path), LOGMEM(ctx), LY_EMEM);
     } else {
-        /* generate location string */
-        if (log_location.scnodes.count) {
+        /* data/schema node */
+        if (log_location.dnodes.count) {
+            dnode = log_location.dnodes.objs[log_location.dnodes.count - 1];
+            if (!dnode->parent && lysc_data_parent(dnode->schema) && (log_location.dnodes.count > 1)) {
+                /* data parsers put all the parent nodes in the set, but they are not connected */
+                str = lyd_path_set(&log_location.dnodes, LYD_PATH_STD);
+
+                /* sometimes the last node is not created yet and we only have the schema node */
+                if (log_location.scnodes.count) {
+                    ly_vlog_build_path_append(&str, log_location.scnodes.objs[log_location.scnodes.count - 1], dnode);
+                }
+            } else {
+                str = lyd_path(log_location.dnodes.objs[log_location.dnodes.count - 1], LYD_PATH_STD, NULL, 0);
+            }
+            LY_CHECK_ERR_RET(!str, LOGMEM(ctx), LY_EMEM);
+
+            r = asprintf(path, "Data location \"%s\"", str);
+            free(str);
+            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
+        } else if (log_location.scnodes.count) {
             str = lysc_path(log_location.scnodes.objs[log_location.scnodes.count - 1], LYSC_PATH_LOG, NULL, 0);
             LY_CHECK_ERR_RET(!str, LOGMEM(ctx), LY_EMEM);
 
-            rc = asprintf(path, "Schema location \"%s\"", str);
+            r = asprintf(path, "Schema location \"%s\"", str);
             free(str);
-            LY_CHECK_ERR_RET(rc == -1, LOGMEM(ctx), LY_EMEM);
+            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
         }
-        if (log_location.dnodes.count) {
-            prev = *path;
-            str = lyd_path(log_location.dnodes.objs[log_location.dnodes.count - 1], LYD_PATH_STD, NULL, 0);
-            LY_CHECK_ERR_RET(!str, LOGMEM(ctx), LY_EMEM);
 
-            rc = asprintf(path, "%s%sata location \"%s\"", prev ? prev : "", prev ? ", d" : "D", str);
-            free(str);
-            free(prev);
-            LY_CHECK_ERR_RET(rc == -1, LOGMEM(ctx), LY_EMEM);
-        }
+        /* line */
+        prev = *path;
         if (log_location.line) {
-            prev = *path;
-            rc = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L", log_location.line);
+            r = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L", log_location.line);
             free(prev);
-            LY_CHECK_ERR_RET(rc == -1, LOGMEM(ctx), LY_EMEM);
+            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
 
             log_location.line = 0;
         } else if (log_location.inputs.count) {
-            prev = *path;
-            rc = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L",
+            r = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L",
                     ((struct ly_in *)log_location.inputs.objs[log_location.inputs.count - 1])->line);
             free(prev);
-            LY_CHECK_ERR_RET(rc == -1, LOGMEM(ctx), LY_EMEM);
+            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
         }
 
         if (*path) {
             prev = *path;
-            rc = asprintf(path, "%s.", prev);
+            r = asprintf(path, "%s.", prev);
             free(prev);
-            LY_CHECK_ERR_RET(rc == -1, LOGMEM(ctx), LY_EMEM);
+            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
         }
     }
 
diff --git a/src/tree_data.c b/src/tree_data.c
index 55839e1..7dc78e8 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2289,8 +2289,7 @@
             }
 
             /* print next node */
-            bufused += sprintf(buffer + bufused, "/%s%s%s", mod ? mod->name : "", mod ? ":" : "",
-                    iter->schema ? iter->schema->name : ((struct lyd_node_opaq *)iter)->name.name);
+            bufused += sprintf(buffer + bufused, "/%s%s%s", mod ? mod->name : "", mod ? ":" : "", LYD_NAME(iter));
 
             /* do not always print the last (first) predicate */
             if (iter->schema && ((depth > 1) || (pathtype == LYD_PATH_STD))) {
@@ -2330,6 +2329,80 @@
     return buffer;
 }
 
+char *
+lyd_path_set(const struct ly_set *dnodes, LYD_PATH_TYPE pathtype)
+{
+    uint32_t depth;
+    size_t bufused = 0, buflen = 0, len;
+    char *buffer = NULL;
+    const struct lyd_node *iter, *parent;
+    const struct lys_module *mod, *prev_mod;
+    LY_ERR rc = LY_SUCCESS;
+
+    switch (pathtype) {
+    case LYD_PATH_STD:
+    case LYD_PATH_STD_NO_LAST_PRED:
+        for (depth = 1; depth <= dnodes->count; ++depth) {
+            /* current node */
+            iter = dnodes->dnodes[depth - 1];
+            mod = iter->schema ? iter->schema->module : lyd_owner_module(iter);
+
+            /* parent */
+            parent = (depth > 1) ? dnodes->dnodes[depth - 2] : NULL;
+            assert(!parent || !iter->schema || !parent->schema || (lysc_data_parent(iter->schema) == parent->schema));
+
+            /* get module to print, if any */
+            prev_mod = (parent && parent->schema) ? parent->schema->module : lyd_owner_module(parent);
+            if (prev_mod == mod) {
+                mod = NULL;
+            }
+
+            /* realloc string */
+            len = 1 + (mod ? strlen(mod->name) + 1 : 0) + (iter->schema ? strlen(iter->schema->name) :
+                    strlen(((struct lyd_node_opaq *)iter)->name.name));
+            if ((rc = lyd_path_str_enlarge(&buffer, &buflen, bufused + len, 0))) {
+                break;
+            }
+
+            /* print next node */
+            bufused += sprintf(buffer + bufused, "/%s%s%s", mod ? mod->name : "", mod ? ":" : "", LYD_NAME(iter));
+
+            /* do not always print the last (first) predicate */
+            if (iter->schema && ((depth > 1) || (pathtype == LYD_PATH_STD))) {
+                switch (iter->schema->nodetype) {
+                case LYS_LIST:
+                    if (iter->schema->flags & LYS_KEYLESS) {
+                        /* print its position */
+                        rc = lyd_path_position_predicate(iter, &buffer, &buflen, &bufused, 0);
+                    } else {
+                        /* print all list keys in predicates */
+                        rc = lyd_path_list_predicate(iter, &buffer, &buflen, &bufused, 0);
+                    }
+                    break;
+                case LYS_LEAFLIST:
+                    if (iter->schema->flags & LYS_CONFIG_W) {
+                        /* print leaf-list value */
+                        rc = lyd_path_leaflist_predicate(iter, &buffer, &buflen, &bufused, 0);
+                    } else {
+                        /* print its position */
+                        rc = lyd_path_position_predicate(iter, &buffer, &buflen, &bufused, 0);
+                    }
+                    break;
+                default:
+                    /* nothing to print more */
+                    break;
+                }
+            }
+            if (rc) {
+                break;
+            }
+        }
+        break;
+    }
+
+    return buffer;
+}
+
 LIBYANG_API_DEF struct lyd_meta *
 lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module, const char *name)
 {
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 97b0f53..373db41 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -1,9 +1,10 @@
 /**
  * @file tree_data_internal.h
  * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
  * @brief internal functions for YANG schema trees.
  *
- * Copyright (c) 2015 - 2020 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -556,17 +557,26 @@
  * @param[in,out] buflen Current buffer length.
  * @param[in,out] bufused Current number of characters used in @p buffer.
  * @param[in] is_static Whether buffer is static or can be reallocated.
- * @return LY_ERR
+ * @return LY_ERR value.
  */
 LY_ERR lyd_path_list_predicate(const struct lyd_node *node, char **buffer, size_t *buflen, size_t *bufused, ly_bool is_static);
 
 /**
+ * @brief Generate a path similar to ::lyd_path() except read the parents from a set.
+ *
+ * @param[in] dnodes Set with the data nodes, from parent to the last descendant.
+ * @param[in] pathtype Type of data path to generate.
+ * @return Generated data path.
+ */
+char *lyd_path_set(const struct ly_set *dnodes, LYD_PATH_TYPE pathtype);
+
+/**
  * @brief Remove an object on the specific set index keeping the order of the other objects.
  *
  * @param[in] set Set from which a node will be removed.
  * @param[in] index Index of the object to remove in the \p set.
  * @param[in] destructor Optional function to free the objects being removed.
- * @return LY_ERR return value.
+ * @return LY_ERR value.
  */
 LY_ERR ly_set_rm_index_ordered(struct ly_set *set, uint32_t index, void (*destructor)(void *obj));
 
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 4fdc1bf..a44e6b6 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -28,7 +28,10 @@
 {
     const char *schema = "module a {namespace urn:tests:a;prefix a;yang-version 1.1; import ietf-yang-metadata {prefix md;}"
             "md:annotation hint { type int8;}"
-            "list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;} leaf d {type string;}}"
+            "list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;}"
+            "  leaf d {type string;}"
+            "  container cont {leaf e {type boolean;}}"
+            "}"
             "leaf foo { type string;}"
             "container c {"
             "    leaf x {type string;}"
@@ -148,6 +151,12 @@
             "Metadata in JSON must be namespace-qualified, missing prefix for \"hint\".",
             "Schema location \"/a:foo\", line number 1.");
 
+    /* invalid JSON type */
+    data = "{\"a:l1\" : [{ \"a\" : \"val-a\", \"b\" : \"val-b\", \"c\" : 1, \"cont\" : { \"e\" : \"0\" } }]}";
+    PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
+            "Invalid non-boolean-encoded boolean value \"0\".",
+            "Data location \"/a:l1[a='val-a'][b='val-b'][c='1']/cont/e\", line number 1.");
+
     /* reverse solidus in JSON object member name */
     data = "{\"@a:foo\":{\"a:hi\\nt\":1},\"a:foo\":\"xxx\"}";
     assert_int_equal(LY_EINVAL, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
@@ -391,18 +400,18 @@
     /* missing keys */
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "List instance is missing its key \"a\".",
-            "Schema location \"/a:l1\", data location \"/a:l1[b='b'][c='1']\", line number 1.");
+            "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
 
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"b\".", "Schema location \"/a:l1\", data location \"/a:l1[a='a']\", line number 1.");
+            "List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
 
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"b\" : \"b\", \"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".", "Schema location \"/a:l1\", data location \"/a:l1[a='a'][b='b']\", line number 1.");
+            "List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
 
     /* key duplicate */
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\", \"a\" : \"a\", \"c\" : 1}]}", 0, LYD_VALIDATE_PRESENT,
             tree, LY_EVALID, "Duplicate instance of \"c\".",
-            "Schema location \"/a:l1/c\", data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
+            "Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
 
     /* keys order, in contrast to XML, JSON accepts keys in any order even in strict mode */
     CHECK_PARSE_LYD("{ \"a:l1\": [ {\"d\" : \"d\", \"a\" : \"a\", \"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree);
@@ -416,7 +425,7 @@
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
-    CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 0, LYS_LEAF, 1, 0, NULL, 0);
+    CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 1, LYS_LEAF, 1, 0, NULL, 0);
     CHECK_LOG_CTX(NULL, NULL);
 
     CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
@@ -511,7 +520,7 @@
     data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"d\":\"val_d\"}]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "List instance is missing its key \"c\".",
-            "Schema location \"/a:l1\", data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
+            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -523,7 +532,7 @@
     data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "Invalid non-number-encoded int16 value \"val_c\".",
-            "Schema location \"/a:l1/c\", data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
+            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 4e5cc2e..271cc4b 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -30,12 +30,10 @@
             "    namespace urn:tests:a;\n"
             "    prefix a;\n"
             "    yang-version 1.1;\n"
-            "    list l1 {\n"
-            "        key \"a b c\";\n"
-            "        leaf a {type string;}\n"
-            "        leaf b {type string;}\n"
-            "        leaf c {type int16;}\n"
-            "        leaf d {type string;}}\n"
+            "    list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;}"
+            "        leaf d {type string;}"
+            "        container cont {leaf e {type boolean;}}"
+            "    }"
             "    leaf foo { type string;}\n"
             "    container c {\n"
             "        leaf x {type string;}\n"
@@ -85,7 +83,6 @@
     leaf = (struct lyd_node_term *)tree->next->next;
     CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
     assert_true(leaf->flags & LYD_DEFAULT);
-
     lyd_free_all(tree);
 
     /* make foo2 explicit */
@@ -98,7 +95,6 @@
     leaf = (struct lyd_node_term *)tree;
     CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
     assert_false(leaf->flags & LYD_DEFAULT);
-
     lyd_free_all(tree);
 
     /* parse foo2 but make it implicit, skip metadata xxx from missing schema */
@@ -112,8 +108,13 @@
     leaf = (struct lyd_node_term *)tree;
     CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
     assert_true(leaf->flags & LYD_DEFAULT);
-
     lyd_free_all(tree);
+
+    /* invalid value */
+    data = "<l1 xmlns=\"urn:tests:a\"><a>val-a</a><b>val-b</b><c>1</c><cont><e>0</e></cont></l1>";
+    PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
+            "Invalid boolean value \"0\".",
+            "Data location \"/a:l1[a='val-a'][b='val-b'][c='1']/cont/e\", line number 1.");
 }
 
 static void
@@ -133,6 +134,7 @@
     tree = tree->next;
     CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_R | LYS_STATUS_CURR | LYS_SET_CONFIG, 1, "any",
             1, LYS_ANYDATA, 0, 0, NULL, 0);
+
     const char *data_expected =
             "<any xmlns=\"urn:tests:a\">\n"
             "  <element1>\n"
@@ -142,7 +144,6 @@
             "</any>\n";
 
     CHECK_LYD_STRING(tree, LYD_PRINT_WITHSIBLINGS, data_expected);
-
     lyd_free_all(tree);
 }
 
@@ -167,18 +168,18 @@
 
     /* missing keys */
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"a\".", "Schema location \"/a:l1\", data location \"/a:l1[b='b'][c='1']\", line number 1.");
+            "List instance is missing its key \"a\".", "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
 
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"b\".", "Schema location \"/a:l1\", data location \"/a:l1[a='a']\", line number 1.");
+            "List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
 
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><b>b</b><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".", "Schema location \"/a:l1\", data location \"/a:l1[a='a'][b='b']\", line number 1.");
+            "List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
 
     /* key duplicate */
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a><c>1</c></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "Duplicate instance of \"c\".",
-            "Schema location \"/a:l1/c\", data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
+            "Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
 
     /* keys order */
     CHECK_PARSE_LYD("<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree);
@@ -192,7 +193,7 @@
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
-    CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 0, LYS_LEAF, 1, 0, NULL, 0);
+    CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 1, LYS_LEAF, 1, 0, NULL, 0);
     CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
     lyd_free_all(tree);
 
@@ -210,7 +211,7 @@
     lyd_free_all(tree);
 
     PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid position of the key \"b\" in a list.", "Schema location \"/a:l1/b\", data location \"/a:b\", line number 1.");
+            "Invalid position of the key \"b\" in a list.", "Data location \"/a:l1[c='1']/b\", line number 1.");
 }
 
 static void
@@ -267,7 +268,7 @@
             "</l1>\n";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "List instance is missing its key \"c\".",
-            "Schema location \"/a:l1\", data location \"/a:l1[a='val_a'][b='val_b']\", line number 5.");
+            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 5.");
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -283,7 +284,7 @@
             "</l1>\n";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "Invalid type int16 value \"val_c\".",
-            "Schema location \"/a:l1/c\", data location \"/a:l1[a='val_a'][b='val_b']\", line number 4.");
+            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 4.");
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 7181782..b8e4b03 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -57,7 +57,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     CHECK_PARSE_LYD_PARAM("<c xmlns=\"urn:tests:a\">hey</c>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"/cont/b = 'val_b'\" not satisfied.", "Schema location \"/a:c\", data location \"/a:c\".");
+    CHECK_LOG_CTX("When condition \"/cont/b = 'val_b'\" not satisfied.", "Data location \"/a:c\".");
 
     LYD_TREE_CREATE("<cont xmlns=\"urn:tests:a\"><b>val_b</b></cont><c xmlns=\"urn:tests:a\">hey</c>", tree);
     CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 0, LYS_LEAF, 0, 0, NULL, 1);
@@ -105,10 +105,10 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:a\">hey</d>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"../c = 'val_c'\" not satisfied.", "Schema location \"/a:d\", data location \"/a:d\".");
+    CHECK_LOG_CTX("When condition \"../c = 'val_c'\" not satisfied.", "Data location \"/a:d\".");
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:a\"><b>hey</b></cont>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"../a = 'val_a'\" not satisfied.", "Schema location \"/a:cont/b\", data location \"/a:cont/b\".");
+    CHECK_LOG_CTX("When condition \"../a = 'val_a'\" not satisfied.", "Data location \"/a:cont/b\".");
 
     LYD_TREE_CREATE("<c xmlns=\"urn:tests:a\">val_c</c><d xmlns=\"urn:tests:a\">hey</d>", tree);
     CHECK_LYSC_NODE(tree->next->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_MAND_TRUE, 1, "d", 0, LYS_LEAF, 0, 0, NULL, 1);
@@ -267,7 +267,7 @@
             "<lt xmlns=\"urn:tests:c\"><k>val4</k></lt>"
             "<lt xmlns=\"urn:tests:c\"><k>val5</k></lt>"
             "<lt xmlns=\"urn:tests:c\"><k>val6</k></lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too many \"lt\" instances.", "Schema location \"/c:lt\", data location \"/c:lt[k='val5']\".",
+    CHECK_LOG_CTX_APPTAG("Too many \"lt\" instances.", "Data location \"/c:lt[k='val5']\".",
             "too-many-elements");
 }
 
@@ -356,7 +356,7 @@
             "    <l1>same</l1>\n"
             "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\".",
-            "Schema location \"/d:lt\", data location \"/d:lt[k='val2']\".", "data-not-unique");
+            "Data location \"/d:lt[k='val2']\".", "data-not-unique");
 
     /* now try with more instances */
     LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
@@ -454,7 +454,7 @@
             "    <l1>8</l1>\n"
             "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\".",
-            "Schema location \"/d:lt\", data location \"/d:lt[k='val2']\".", "data-not-unique");
+            "Data location \"/d:lt[k='val2']\".", "data-not-unique");
 }
 
 static void
@@ -580,7 +580,7 @@
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l3\" not satisfied in \"/d:lt2[k='val2']/lt3[kk='val3']\" and "
             "\"/d:lt2[k='val2']/lt3[kk='val1']\".",
-            "Schema location \"/d:lt2/lt3\", data location \"/d:lt2[k='val2']/lt3[kk='val1']\".", "data-not-unique");
+            "Data location \"/d:lt2[k='val2']/lt3[kk='val1']\".", "data-not-unique");
 
     CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
             "    <k>val1</k>\n"
@@ -618,7 +618,7 @@
             "    <l4>5</l4>\n"
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\".",
-            "Schema location \"/d:lt2\", data location \"/d:lt2[k='val2']\".", "data-not-unique");
+            "Data location \"/d:lt2[k='val2']\".", "data-not-unique");
 
     CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
             "    <k>val1</k>\n"
@@ -664,7 +664,7 @@
             "    <l6>3</l6>\n"
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\".",
-            "Schema location \"/d:lt2\", data location \"/d:lt2[k='val3']\".", "data-not-unique");
+            "Data location \"/d:lt2[k='val3']\".", "data-not-unique");
 }
 
 static void
@@ -725,28 +725,28 @@
 
     CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:e\">25</d><d xmlns=\"urn:tests:e\">50</d>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Schema location \"/e:d\", data location \"/e:d\".");
+    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Data location \"/e:d\".");
 
     CHECK_PARSE_LYD_PARAM("<lt xmlns=\"urn:tests:e\"><k>A</k></lt>"
             "<lt xmlns=\"urn:tests:e\"><k>B</k></lt>"
             "<lt xmlns=\"urn:tests:e\"><k>A</k></lt>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Schema location \"/e:lt\", data location \"/e:lt[k='A']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Data location \"/e:lt[k='A']\".");
 
     CHECK_PARSE_LYD_PARAM("<ll xmlns=\"urn:tests:e\">A</ll>"
             "<ll xmlns=\"urn:tests:e\">B</ll>"
             "<ll xmlns=\"urn:tests:e\">B</ll>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Schema location \"/e:ll\", data location \"/e:ll[.='B']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/e:ll[.='B']\".");
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"></cont><cont xmlns=\"urn:tests:e\"/>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "Schema location \"/e:cont\", data location \"/e:cont\".");
+    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "Data location \"/e:cont\".");
 
     /* same tests again but using hashes */
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><d>25</d><d>50</d><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Schema location \"/e:cont/d\", data location \"/e:cont/d\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Data location \"/e:cont/d\", line number 1.");
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
             "<lt><k>a</k></lt>"
@@ -755,12 +755,12 @@
             "<lt><k>d</k></lt>"
             "<lt><k>c</k></lt></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Schema location \"/e:cont/lt\", data location \"/e:cont/lt[k='c']\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Data location \"/e:cont/lt[k='c']\", line number 1.");
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
             "<ll>a</ll><ll>b</ll><ll>c</ll><ll>d</ll><ll>d</ll></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Schema location \"/e:cont/ll\", data location \"/e:cont/ll[.='d']\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/e:cont/ll[.='d']\", line number 1.");
 
     /* cases */
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l>"
@@ -768,7 +768,7 @@
             "<l xmlns=\"urn:tests:e\">c</l>"
             "<l xmlns=\"urn:tests:e\">b</l>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"l\".", "Schema location \"/e:choic/b/l\", data location \"/e:l[.='b']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"l\".", "Data location \"/e:l[.='b']\".");
 
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l><l xmlns=\"urn:tests:e\">b</l>"
             "<l xmlns=\"urn:tests:e\">c</l>"
@@ -1095,12 +1095,12 @@
             "</cont>\n";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE, 0, LY_EVALID, tree);
     CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
-            "Schema location \"/h:cont/cont2\", data location \"/h:cont\", line number 3.");
+            "Data location \"/h:cont\", line number 3.");
 
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
     assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, NULL));
     CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
-            "Schema location \"/h:cont/cont2\", data location \"/h:cont/cont2\".");
+            "Data location \"/h:cont/cont2\".");
     lyd_free_all(tree);
 }
 
@@ -1139,7 +1139,7 @@
             "  <l2>val</l2>\n"
             "</cont>\n", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.",
-            "Schema location \"/i:cont/l2\", data location \"/i:cont/l2\".", "must-violation");
+            "Data location \"/i:cont/l2\".", "must-violation");
 
     LYD_TREE_CREATE("<cont xmlns=\"urn:tests:i\">\n"
             "  <l>right</l>\n"
@@ -1151,7 +1151,7 @@
             "  <l>wrong</l>\n"
             "  <l3>val</l3>\n"
             "</cont>\n", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Schema location \"/i:cont/l3\", data location \"/i:cont/l3\".", "not-left");
+    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/i:cont/l3\".", "not-left");
 }
 
 const char *schema_j =
@@ -1228,7 +1228,7 @@
     /* missing leafref */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_RPC_YANG, NULL));
     CHECK_LOG_CTX("Invalid leafref value \"target\" - no target instance \"/lf3\" with the same value.",
-            "Schema location \"/j:cont/l1/act/input/lf2\", data location \"/j:cont/l1[k='val1']/act/lf2\".");
+            "Data location \"/j:cont/l1[k='val1']/act/lf2\".");
     ly_in_free(in, 0);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
@@ -1292,8 +1292,8 @@
             "</modify-user-password>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
     assert_int_equal(LY_EVALID, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree, NULL));
-    CHECK_LOG_CTX("Unsatisfied length - string \"123\" length is not allowed.", "Schema location "
-            "\"/val-str:modify-user-password/input/new-password\", data location \"/val-str:modify-user-password\", line number 3.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"123\" length is not allowed.",
+            "Data location \"/val-str:modify-user-password\", line number 3.");
     ly_in_free(in, 0);
 }
 
@@ -1321,7 +1321,7 @@
     /* missing leafref */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_REPLY_YANG, NULL));
     CHECK_LOG_CTX("Invalid leafref value \"target\" - no target instance \"/lf4\" with the same value.",
-            "Schema location \"/j:cont/l1/act/output/lf2\", data location \"/j:cont/l1[k='val1']/act/lf2\".");
+            "Data location \"/j:cont/l1[k='val1']/act/lf2\".");
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
             "  <lf1>not true</lf1>\n"
@@ -1422,7 +1422,7 @@
             "  }\n"
             "}\n", LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.",
-            "Schema location \"/k:ch/a0\", data location \"/k:ch\", line number 5.");
+            "Data location \"/k:ch\", line number 5.");
 
     CHECK_PARSE_LYD_PARAM(
             "{\n"
@@ -1432,7 +1432,7 @@
             "  }\n"
             "}\n", LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.",
-            "Schema location \"/k:ch/a0\", data location \"/k:ch\", line number 5.");
+            "Data location \"/k:ch\", line number 5.");
 }
 
 int
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index bcc3f95..6f33d01 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -226,7 +226,7 @@
 
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("No module with namespace \"unknown\" in the context.",
-            "Schema location \"/sm:root\", data location \"/sm:root\", line number 1.");
+            "Data location \"/sm:root\", line number 1.");
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
     assert_string_equal(LYD_NAME(data), "root");
@@ -237,7 +237,7 @@
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("No module named \"unknown\" in the context.",
-            "Schema location \"/sm:root\", data location \"/sm:root\", line number 1.");
+            "Data location \"/sm:root\", line number 1.");
 
     /* missing required callback data */
     xml =
@@ -250,7 +250,7 @@
             "</root>";
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Schema location \"/sm:root\", data location \"/sm:root\", line number 1.");
+            "Data location \"/sm:root\", line number 1.");
 
     json =
             "{"
@@ -266,7 +266,7 @@
             "}";
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Schema location \"/sm:root\", data location \"/sm:root\", line number 1.");
+            "Data location \"/sm:root\", line number 1.");
 
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
             "<yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\" "
@@ -1123,8 +1123,7 @@
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
             "Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
-            "Schema location \"/ietf-interfaces:interfaces/interface/sm:sm-name\", "
-            "data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
+            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
 
     json =
             "{\n"
@@ -1149,8 +1148,7 @@
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
             "Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
-            "Schema location \"/ietf-interfaces:interfaces/interface/sm:sm-name\", "
-            "data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\", line number 18.");
+            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\", line number 18.");
 
     /* success */
     xml =
diff --git a/tests/utests/node/list.c b/tests/utests/node/list.c
index 712e2e1..f89c56a 100644
--- a/tests/utests/node/list.c
+++ b/tests/utests/node/list.c
@@ -852,7 +852,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Schema location \"/T0:user\", data location \"/T0:user[uid='0']\".");
+            "Data location \"/T0:user[uid='0']\".");
 
     data =
             "<user xmlns=\"urn:tests:T0\">"
@@ -869,7 +869,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Unique data leaf(s) \"name group\" not satisfied in \"/T0:user[uid='0']\" and \"/T0:user[uid='1']\".",
-            "Schema location \"/T0:user\", data location \"/T0:user[uid='1']\".");
+            "Data location \"/T0:user[uid='1']\".");
 
     /* double key */
     schema = MODULE_CREATE_YANG("T1", "list user {"
@@ -932,7 +932,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Schema location \"/T1:user\", data location \"/T1:user[uid='0'][group='User']\".");
+            "Data location \"/T1:user[uid='0'][group='User']\".");
 
     /* min elements max elements */
     schema = MODULE_CREATE_YANG("T2",
@@ -1089,7 +1089,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Too many \"user\" instances.",
-            "Schema location \"/T2:user\", data location \"/T2:user[uid='5']\".");
+            "Data location \"/T2:user[uid='5']\".");
 
     /* empty list */
     schema = MODULE_CREATE_YANG("T_EMPTY_LIST",
@@ -1205,7 +1205,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Schema location \"/T0:user\", data location \"/T0:user[uid='0']\", line number 1.");
+            "Data location \"/T0:user[uid='0']\", line number 1.");
 
     data =
             "{\"T0:user\": ["
@@ -1215,7 +1215,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Unique data leaf(s) \"name group\" not satisfied in \"/T0:user[uid='0']\" and \"/T0:user[uid='1']\".",
-            "Schema location \"/T0:user\", data location \"/T0:user[uid='1']\", line number 1.");
+            "Data location \"/T0:user[uid='1']\", line number 1.");
 
     /* double key */
     schema = MODULE_CREATE_YANG("T1", "list user {"
@@ -1265,7 +1265,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Schema location \"/T1:user\", data location \"/T1:user[uid='0'][group='User']\", line number 1.");
+            "Data location \"/T1:user[uid='0'][group='User']\", line number 1.");
 
     /* min elements max elements */
     schema = MODULE_CREATE_YANG("T2",
@@ -1367,7 +1367,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Too many \"user\" instances.",
-            "Schema location \"/T2:user\", data location \"/T2:user[uid='5']\", line number 1.");
+            "Data location \"/T2:user[uid='5']\", line number 1.");
 
     schema = MODULE_CREATE_YANG("T_EMPTY_LIST",
             "container user_list {"
diff --git a/tests/utests/types/instanceid.c b/tests/utests/types/instanceid.c
index 8b46aaa..06c8622 100644
--- a/tests/utests/types/instanceid.c
+++ b/tests/utests/types/instanceid.c
@@ -159,12 +159,12 @@
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/mod:cont/l2\" value - required instance not found.",
-            "Schema location \"/defs:l1\", data location \"/defs:l1\".", "instance-required");
+            "Data location \"/defs:l1\".", "instance-required");
 
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:llist[.='2']", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:llist[.='2']\" value - required instance not found.",
-            "Schema location \"/defs:l1\", data location \"/defs:l1\".", "instance-required");
+            "Data location \"/defs:l1\".", "instance-required");
 
     TEST_ERROR_XML2("<list2 xmlns=\"urn:tests:defs\"><id>a</id><id2>a</id2></list2>"
             "<list2 xmlns=\"urn:tests:defs\"><id>c</id><id2>b</id2></list2>"
@@ -172,7 +172,7 @@
             "<llist xmlns=\"urn:tests:defs\">b</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:list2[a:id='a'][a:id2='a']/a:id", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:list2[id='a'][id2='a']/id\" value - required instance not found.",
-            "Schema location \"/defs:l1\", data location \"/defs:l1\".", "instance-required");
+            "Data location \"/defs:l1\".", "instance-required");
 
     TEST_ERROR_XML2("<list2 xmlns=\"urn:tests:defs\"><id>a</id><id2>a</id2></list2>"
             "<list2 xmlns=\"urn:tests:defs\"><id>c</id><id2>b</id2></list2>"
@@ -180,12 +180,12 @@
             "<llist xmlns=\"urn:tests:defs\">2</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:llist[.='3']", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:llist[.='3']\" value - required instance not found.",
-            "Schema location \"/defs:l1\", data location \"/defs:l1\".", "instance-required");
+            "Data location \"/defs:l1\".", "instance-required");
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:list-keyless[3]", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:list-keyless[3]\" value - required instance not found.",
-            "Schema location \"/defs:l1\", data location \"/defs:l1\".", "instance-required");
+            "Data location \"/defs:l1\".", "instance-required");
 
     /* more errors */
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">x</llist>",
diff --git a/tests/utests/types/leafref.c b/tests/utests/types/leafref.c
index e208aec..c8d0cb6 100644
--- a/tests/utests/types/leafref.c
+++ b/tests/utests/types/leafref.c
@@ -131,7 +131,7 @@
     TEST_ERROR_XML2("<leaflisttarget xmlns=\"urn:tests:defs\">x</leaflisttarget>",
             "defs", "", "lref", "y", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"y\" - no target instance \"/leaflisttarget\" with the same value.",
-            "Schema location \"/defs:lref\", data location \"/defs:lref\".", "instance-required");
+            "Data location \"/defs:lref\".", "instance-required");
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>x</id><targets>a</targets><targets>b</targets></list>"
             "<list xmlns=\"urn:tests:defs\"><id>y</id><targets>x</targets><targets>y</targets></list>"
@@ -139,36 +139,36 @@
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Schema location \"/defs:lref2\", data location \"/defs:lref2\".", "instance-required");
+            "Data location \"/defs:lref2\".", "instance-required");
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>x</id><targets>a</targets><targets>b</targets></list>"
             "<list xmlns=\"urn:tests:defs\"><id>y</id><targets>x</targets><targets>y</targets></list>",
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Schema location \"/defs:lref2\", data location \"/defs:lref2\".", "instance-required");
+            "Data location \"/defs:lref2\".", "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">y</str-norestr>",
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Schema location \"/defs:lref2\", data location \"/defs:lref2\".", "instance-required");
+            "Data location \"/defs:lref2\".", "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">y</str-norestr>",
             "leafrefs", "", "c", "<l><id>x</id><value>x</value><lr1>a</lr1></l>", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"a\" - no target instance \"../../../t:str-norestr\" with the same value.",
-            "Schema location \"/leafrefs:c/l/lr1\", data location \"/leafrefs:c/l[id='x'][value='x']/lr1\".", "instance-required");
+            "Data location \"/leafrefs:c/l[id='x'][value='x']/lr1\".", "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">z</str-norestr>",
             "leafrefs", "", "c", "<l><id>y</id><value>y</value></l><l><id>x</id><value>x</value><lr2>z</lr2></l>", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"z\" - no target instance \"../../l[id=current()/../../../t:str-norestr]"
             "[value=current()/../../../t:str-norestr]/value\" with the same value.",
-            "Schema location \"/leafrefs:c/l/lr2\", data location \"/leafrefs:c/l[id='x'][value='x']/lr2\".", "instance-required");
+            "Data location \"/leafrefs:c/l[id='x'][value='x']/lr2\".", "instance-required");
 
     TEST_ERROR_XML2("",
             "defs", "", "lref", "%n", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"%n\" - no target instance \"/leaflisttarget\" with the same value.",
-            "Schema location \"/defs:lref\", data location \"/defs:lref\".", "instance-required");
+            "Data location \"/defs:lref\".", "instance-required");
 }
 
 static void
diff --git a/tests/utests/types/string.c b/tests/utests/types/string.c
index 47ad0ad..f6a8d0e 100644
--- a/tests/utests/types/string.c
+++ b/tests/utests/types/string.c
@@ -744,7 +744,7 @@
     /* error */
     TEST_ERROR_XML("T0", "< df");
     CHECK_LOG_CTX("Child element \"df\" inside a terminal node \"port\" found.",
-            "Schema location \"/T0:port\", data location \"/T0:port\", line number 1.");
+            "Data location \"/T0:port\", line number 1.");
     TEST_ERROR_XML("T0", "&text;");
     CHECK_LOG_CTX("Entity reference \"&text;</po\" not supported, only predefined references allowed.", "Line number 1.");
     TEST_ERROR_XML("T0", "\"&#x8;\"");