schema tree CHANGE xpath functions api change and clarification
diff --git a/src/resolve.c b/src/resolve.c
index 975a4c5..132d0b1 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -7238,7 +7238,7 @@
     }
 
     /* find the first schema node */
-    set = lys_find_xpath(NULL, sleaf, buf, 0);
+    set = lys_find_xpath(sleaf, buf, 0);
     if (!set || !set->number) {
         free(buf);
         ly_set_free(set);
diff --git a/src/tree_schema.c b/src/tree_schema.c
index c8bc166..cf6eed3 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -3844,26 +3844,18 @@
 #endif
 
 API struct ly_set *
-lys_find_xpath(struct ly_ctx *ctx, const struct lys_node *node, const char *expr, int options)
+lys_find_xpath(const struct lys_node *ctx_node, const char *expr, int options)
 {
     struct lyxp_set set;
     struct ly_set *ret_set;
     uint32_t i;
     int opts;
 
-    if ((!ctx && !node) || !expr) {
+    if (!ctx_node || !expr) {
         ly_errno = LY_EINVAL;
         return NULL;
     }
 
-    if (!node) {
-        node = ly_ctx_get_node(ctx, NULL, "/ietf-yang-library:modules-state");
-        if (!node) {
-            ly_errno = LY_EINT;
-            return NULL;
-        }
-    }
-
     memset(&set, 0, sizeof set);
 
     opts = LYXP_SNODE;
@@ -3871,16 +3863,16 @@
         opts |= LYXP_SNODE_OUTPUT;
     }
 
-    if (lyxp_atomize(expr, node, LYXP_NODE_ELEM, &set, opts, NULL)) {
+    if (lyxp_atomize(expr, ctx_node, LYXP_NODE_ELEM, &set, opts, NULL)) {
         /* just find a relevant node to put in path, if it fails, use the original one */
         for (i = 0; i < set.used; ++i) {
             if (set.val.snodes[i].in_ctx == 1) {
-                node = set.val.snodes[i].snode;
+                ctx_node = set.val.snodes[i].snode;
                 break;
             }
         }
         free(set.val.snodes);
-        LOGVAL(LYE_SPEC, LY_VLOG_LYS, node, "Resolving XPath expression \"%s\" failed.", expr);
+        LOGVAL(LYE_SPEC, LY_VLOG_LYS, ctx_node, "Resolving XPath expression \"%s\" failed.", expr);
         return NULL;
     }
 
@@ -3911,21 +3903,21 @@
 }
 
 API struct ly_set *
-lys_xpath_atomize(const struct lys_node *cur_snode, enum lyxp_node_type cur_snode_type, const char *expr, int options)
+lys_xpath_atomize(const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type, const char *expr, int options)
 {
     struct lyxp_set set;
     struct ly_set *ret_set;
     uint32_t i;
 
-    if (!cur_snode || !expr) {
+    if (!ctx_node || !expr) {
         return NULL;
     }
 
     /* adjust the root */
-    if ((cur_snode_type == LYXP_NODE_ROOT) || (cur_snode_type == LYXP_NODE_ROOT_CONFIG)) {
+    if ((ctx_node_type == LYXP_NODE_ROOT) || (ctx_node_type == LYXP_NODE_ROOT_CONFIG)) {
         do {
-            cur_snode = lys_getnext(NULL, NULL, lys_node_module(cur_snode), 0);
-        } while ((cur_snode_type == LYXP_NODE_ROOT_CONFIG) && (cur_snode->flags & LYS_CONFIG_R));
+            ctx_node = lys_getnext(NULL, NULL, lys_node_module(ctx_node), 0);
+        } while ((ctx_node_type == LYXP_NODE_ROOT_CONFIG) && (ctx_node->flags & LYS_CONFIG_R));
     }
 
     memset(&set, 0, sizeof set);
@@ -3940,9 +3932,9 @@
         options |= LYXP_SNODE;
     }
 
-    if (lyxp_atomize(expr, cur_snode, cur_snode_type, &set, options, NULL)) {
+    if (lyxp_atomize(expr, ctx_node, ctx_node_type, &set, options, NULL)) {
         free(set.val.snodes);
-        LOGVAL(LYE_SPEC, LY_VLOG_LYS, cur_snode, "Resolving XPath expression \"%s\" failed.", expr);
+        LOGVAL(LYE_SPEC, LY_VLOG_LYS, ctx_node, "Resolving XPath expression \"%s\" failed.", expr);
         return NULL;
     }
 
diff --git a/src/tree_schema.h b/src/tree_schema.h
index a62efff..fc0fc5f 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -2104,18 +2104,17 @@
 /**
  * @brief Search for schema nodes matching the provided XPath expression.
  *
- * XPath always requires a context node to be able to evaluate an expression. However, if \p expr is absolute,
- * the context node can almost always be arbitrary, so you can only set \p ctx and leave \p node empty. But, if
- * \p expr is relative and \p node will not be set, you will likely get unexpected results.
+ * XPath always requires a context node to be able to evaluate an expression because
+ * non-prefixed node names will use its module prefix. However, if \p expr is absolute
+ * and all the node names are prefixed, the context node can be an arbitrary node.
  *
- * @param[in] ctx Context to use. Must be set if \p node is NULL.
- * @param[in] node Context schema node if \p expr is relative, otherwise any node. Must be set if \p ctx is NULL.
+ * @param[in] ctx_node Context schema node.
  * @param[in] expr XPath expression filtering the matching nodes.
  * @param[in] options Bitmask of LYS_FIND_* options.
  * @return Set of found schema nodes. If no nodes are matching \p expr or the result
  * would be a number, a string, or a boolean, the returned set is empty. In case of an error, NULL is returned.
  */
-struct ly_set *lys_find_xpath(struct ly_ctx *ctx, const struct lys_node *node, const char *expr, int options);
+struct ly_set *lys_find_xpath(const struct lys_node *ctx_node, const char *expr, int options);
 
 #define LYS_FIND_OUTPUT 0x01 /**< lys_find_xpath() option to search RPC output nodes instead input ones */
 
@@ -2136,16 +2135,16 @@
 /**
  * @brief Get all the partial XPath nodes (atoms) that are required for \p expr to be evaluated.
  *
- * @param[in] cur_snode Current (context) schema node. Fake roots are distinguished using \p cur_snode_type
+ * @param[in] ctx_node Context (current) schema node. Fake roots are distinguished using \p cur_snode_type
  * and then this node can be any node from the module (so, for example, do not put node added by an augment from another module).
- * @param[in] cur_snode_type Current (context) schema node type. Most commonly is #LYXP_NODE_ELEM, but if
+ * @param[in] ctx_node_type Context (current) schema node type. Most commonly is #LYXP_NODE_ELEM, but if
  * your context node is supposed to be the root, you can specify what kind of root it is.
  * @param[in] expr XPath expression to be evaluated. Must be in JSON data format (prefixes are model names).
  * @param[in] options Whether to apply some evaluation restrictions #LYXP_MUST or #LYXP_WHEN.
  *
  * @return Set of atoms (schema nodes), NULL on error.
  */
-struct ly_set *lys_xpath_atomize(const struct lys_node *cur_snode, enum lyxp_node_type cur_snode_type,
+struct ly_set *lys_xpath_atomize(const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type,
                                  const char *expr, int options);
 
 #define LYXP_MUST 0x01 /**< lys_xpath_atomize() option to apply must statement data tree access restrictions */