parsers CHANGE rpc, action, notif YANG 1.1 xpath accessible tree handling

Now it will be possible to learn about expressions that
require nodes from outside their subtree and then create
and use these nodes in when/must validation.

TODO: yang parser node XPath dependenies check
      lyd_validate() accepting additional optional data tree
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 646f244..5c2cbc8 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -1388,9 +1388,6 @@
     if (!must->expr) {
         goto error;
     }
-    if (lyxp_syntax_check(must->expr)) {
-        goto error;
-    }
 
     return read_restr_substmt(module->ctx, must, yin);
 
@@ -2031,6 +2028,8 @@
                 goto error;
             }
 
+            dev_target->flags &= ~LYS_XPATH_DEP;
+
             if (d->mod == LY_DEVIATE_RPL) {
                 /* replace must is forbidden */
                 LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "must", "deviate replace");
@@ -2185,6 +2184,11 @@
                     }
                     (*trg_must_size)++;
                 }
+
+                /* check XPath dependencies again */
+                if (*trg_must_size && unres_schema_add_node(dev_target->module, unres, dev_target, UNRES_XPATH, NULL)) {
+                    goto error;
+                }
             } else if (!strcmp(child->name, "unique")) {
                 if (d->mod == LY_DEVIATE_DEL) {
                     memset(&d->unique[d->unique_size], 0, sizeof *d->unique);
@@ -2489,6 +2493,11 @@
         }
     }
 
+    /* check XPath dependencies */
+    if (aug->when && (unres_schema_add_node(module, unres, (struct lys_node *)aug, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return EXIT_SUCCESS;
 
 error:
@@ -3069,9 +3078,6 @@
     if (!retval->cond) {
         goto error;
     }
-    if (lyxp_syntax_check(retval->cond)) {
-        goto error;
-    }
 
     LY_TREE_FOR(yin->child, child) {
         if (!child->ns || strcmp(child->ns->value, LY_NSYIN)) {
@@ -3225,6 +3231,11 @@
         lyxml_free(module->ctx, sub);
     }
 
+    /* check XPath dependencies */
+    if (cs->when && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -3391,6 +3402,11 @@
         lyxml_free(ctx, dflt);
     }
 
+    /* check XPath dependencies */
+    if (choice->when && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -3518,6 +3534,11 @@
         }
     }
 
+    /* check XPath dependencies */
+    if ((anyxml->when || anyxml->must_size) && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -3689,6 +3710,11 @@
         }
     }
 
+    /* check XPath dependencies */
+    if ((leaf->when || leaf->must_size) && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -3943,6 +3969,11 @@
         }
     }
 
+    /* check XPath dependencies */
+    if ((llist->when || llist->must_size) && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -4260,6 +4291,11 @@
         }
     }
 
+    /* check XPath dependencies */
+    if ((list->when || list->must_size) && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -4443,6 +4479,11 @@
         lyxml_free(module->ctx, sub);
     }
 
+    /* check XPath dependencies */
+    if ((cont->when || cont->must_size) && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -4719,6 +4760,11 @@
         lyxml_free(module->ctx, sub);
     }
 
+    /* check XPath dependencies */
+    if (inout->must_size && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -4871,6 +4917,11 @@
         lyxml_free(module->ctx, sub);
     }
 
+    /* check XPath dependencies */
+    if (notif->must_size && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error:
@@ -5152,6 +5203,11 @@
         goto error;
     }
 
+    /* check XPath dependencies */
+    if (uses->when && (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1)) {
+        goto error;
+    }
+
     return retval;
 
 error: