tree CHANGE invalid xpath is accepted with a warning
diff --git a/src/resolve.c b/src/resolve.c
index a90725d..6427ff7 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -4173,12 +4173,12 @@
 }
 
 int
-lys_check_xpath(struct lys_node *node, int check_place)
+lys_check_xpath(struct lys_node *node, int check_place, int warn_on_fwd_ref)
 {
     struct lys_node *parent, *elem;
     struct lyxp_set set;
     uint32_t i;
-    int rc;
+    int ret;
 
     if (check_place) {
         parent = node;
@@ -4206,9 +4206,9 @@
         }
     }
 
-    rc = lyxp_node_atomize(node, &set);
-    if (rc) {
-        return rc;
+    ret = lyxp_node_atomize(node, &set, warn_on_fwd_ref);
+    if (ret == -1) {
+        return -1;
     }
 
     for (parent = node; parent && !(parent->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); parent = lys_parent(parent));
@@ -4234,7 +4234,7 @@
     }
 
     free(set.val.snodes);
-    return EXIT_SUCCESS;
+    return ret;
 }
 
 static int
@@ -6026,12 +6026,13 @@
  * @param[in] type Type of the unresolved item.
  * @param[in] str_snode String, a schema node, or NULL.
  * @param[in] unres Unres schema structure to use.
+ * @param[in] final_fail Whether we are just printing errors of the failed unres items.
  *
  * @return EXIT_SUCCESS on success, EXIT_FAILURE on forward reference, -1 on error.
  */
 static int
 resolve_unres_schema_item(struct lys_module *mod, void *item, enum UNRES_ITEM type, void *str_snode,
-                          struct unres_schema *unres)
+                          struct unres_schema *unres, int final_fail)
 {
     /* has_str - whether the str_snode is a string in a dictionary that needs to be freed */
     int rc = -1, has_str = 0, tpdf_flag = 0, i, k;
@@ -6250,7 +6251,7 @@
         break;
     case UNRES_XPATH:
         node = (struct lys_node *)item;
-        rc = lys_check_xpath(node, 1);
+        rc = lys_check_xpath(node, 1, final_fail);
         break;
     default:
         LOGINT;
@@ -6378,7 +6379,7 @@
              * UNRES_AUGMENT, UNRES_CHOICE_DFLT and UNRES_IDENT */
 
             ++unres_count;
-            rc = resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
+            rc = resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 0);
             if (!rc) {
                 unres->type[i] = UNRES_RESOLVED;
                 ++resolved;
@@ -6386,7 +6387,7 @@
             } else if (rc == -1) {
                 ly_vlog_hide(0);
                 /* print the error */
-                resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
+                resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 1);
                 return -1;
             } else {
                 /* forward reference, erase ly_errno */
@@ -6403,7 +6404,7 @@
             if (unres->type[i] > UNRES_IDENT) {
                 continue;
             }
-            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
+            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 1);
         }
         return -1;
     }
@@ -6414,7 +6415,7 @@
             continue;
         }
 
-        rc = resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
+        rc = resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 0);
         if (rc == 0) {
             if (unres->type[i] == UNRES_LIST_UNIQ) {
                 /* free the allocated structure */
@@ -6425,7 +6426,7 @@
         } else if (rc == -1) {
             ly_vlog_hide(0);
             /* print the error */
-            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
+            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 1);
             return -1;
         }
     }
@@ -6440,17 +6441,11 @@
             if (unres->type[i] == UNRES_RESOLVED) {
                 continue;
             }
+            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres, 1);
             if (unres->type[i] == UNRES_XPATH) {
-                /* unresolvable XPaths are actually supposed to be warnings - they may be
-                 * unresolved due to the not implemented target module so it shouldn't avoid
-                 * parsing the module, but we still want to announce some issue here */
-                ly_vlog_hide(0xff);
-            }
-            resolve_unres_schema_item(mod, unres->item[i], unres->type[i], unres->str_snode[i], unres);
-            if (unres->type[i] == UNRES_XPATH && *ly_vlog_hide_location() == 0xff) {
+                /* XPath referencing an unknown node is actually supposed to be just a warning */
                 unres->type[i] = UNRES_RESOLVED;
                 resolved++;
-                ly_vlog_hide(0);
             }
         }
         if (resolved < unres->count) {
@@ -6528,7 +6523,7 @@
         log_hidden = 0;
         ly_vlog_hide(1);
     }
-    rc = resolve_unres_schema_item(mod, item, type, snode, unres);
+    rc = resolve_unres_schema_item(mod, item, type, snode, unres, 0);
     if (!log_hidden) {
         ly_vlog_hide(0);
     }
@@ -6543,7 +6538,7 @@
         } else if (rc == -1 && type == UNRES_IFFEAT) {
             /* free the allocated resources */
             free(*((char **)item));
-         }
+        }
         return rc;
     } else {
         /* erase info about validation errors */