tree schema NEW unique validation
Several other fixes in lyd_path()
and XML parser are included.
Tests also included.
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index df66c42..54c39af 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -3952,6 +3952,7 @@
{
LY_ERR ret = LY_SUCCESS;
struct lysc_node_leaf **key, ***unique;
+ struct lysc_node *parent;
const char *keystr, *delim;
size_t len;
unsigned int v;
@@ -3995,7 +3996,7 @@
/* all referenced leafs must be of the same config type */
if (config != -1 && ((((*key)->flags & LYS_CONFIG_W) && config == 0) || (((*key)->flags & LYS_CONFIG_R) && config == 1))) {
LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
- "Unique statement \"%s\" refers to leafs with different config type.", uniques[v]);
+ "Unique statement \"%s\" refers to leaves with different config type.", uniques[v]);
return LY_EVALID;
} else if ((*key)->flags & LYS_CONFIG_W) {
config = 1;
@@ -4003,6 +4004,15 @@
config = 0;
}
+ /* we forbid referencing nested lists because it is unspecified what instance of such a list to use */
+ for (parent = (*key)->parent; parent != (struct lysc_node *)list; parent = parent->parent) {
+ if (parent->nodetype == LYS_LIST) {
+ LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
+ "Unique statement \"%s\" refers to a leaf in nested list \"%s\".", uniques[v], parent->name);
+ return LY_EVALID;
+ }
+ }
+
/* check status */
LY_CHECK_RET(lysc_check_status(ctx, list->flags, list->module, list->name,
(*key)->flags, (*key)->module, (*key)->name));