schema tree CHANGE in lys_find_xpath try to print last ctx node in path
Fixes #247
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 712d12c..24c8aa9 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -3253,8 +3253,14 @@
opts |= LYXP_SNODE_OUTPUT;
}
- /* node and nodetype won't matter at all since it is absolute */
if (lyxp_atomize(expr, node, LYXP_NODE_ELEM, &set, opts)) {
+ /* 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;
+ break;
+ }
+ }
free(set.val.snodes);
LOGVAL(LYE_SPEC, LY_VLOG_LYS, node, "Resolving XPath expression \"%s\" failed.", expr);
return NULL;