validation NEW default values creation
Also a lot of other refactoring and
improvements. No tests yet.
diff --git a/src/log.c b/src/log.c
index e04f6c3..22d6855 100644
--- a/src/log.c
+++ b/src/log.c
@@ -423,6 +423,10 @@
*path = lysc_path(elem, LYSC_PATH_LOG, NULL, 0);
LY_CHECK_ERR_RET(!(*path), LOGMEM(ctx), LY_EMEM);
break;
+ case LY_VLOG_LYD:
+ *path = lyd_path(elem, LYD_PATH_LOG, NULL, 0);
+ LY_CHECK_ERR_RET(!(*path), LOGMEM(ctx), LY_EMEM);
+ break;
default:
/* shouldn't be here */
LOGINT_RET(ctx);
diff --git a/src/parser_xml.c b/src/parser_xml.c
index f61d6e6..bc38598 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -17,6 +17,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "context.h"
#include "dict.h"
@@ -206,7 +207,7 @@
* @param[in] parent Parent node where the children are inserted. NULL in case of parsing top-level elements.
* @param[in,out] data Pointer to the XML string representation of the YANG data to parse.
* @param[out] node Resulting list of the parsed nodes.
- * @reutn LY_ERR value.
+ * @return LY_ERR value.
*/
static LY_ERR
lydxml_nodes(struct lyd_xml_ctx *ctx, struct lyd_node_inner *parent, const char **data, struct lyd_node **node)
@@ -294,10 +295,27 @@
/* buffer spent */
buffer = NULL;
if (ret == LY_EINCOMPLETE) {
- ly_set_add(&ctx->incomplete_type_validation, cur, LY_SET_OPT_USEASLIST);
+ if (!(ctx->options & LYD_OPT_PARSE_ONLY)) {
+ ly_set_add(&ctx->incomplete_type_validation, cur, LY_SET_OPT_USEASLIST);
+ }
} else if (ret) {
goto cleanup;
}
+
+ if (parent && (cur->schema->flags & LYS_KEY)) {
+ /* check the key order, the anchor must always be the last child */
+ key_anchor = lyd_get_prev_key_anchor(parent->child, cur->schema);
+ if ((!key_anchor && parent->child) || (key_anchor && key_anchor->next)) {
+ if (ctx->options & LYD_OPT_STRICT) {
+ LOGVAL(ctx->ctx, LY_VLOG_LINE, &ctx->line, LYVE_DATA, "Invalid position of the key \"%s\" in a list.",
+ cur->schema->name);
+ ret = LY_EVALID;
+ goto cleanup;
+ } else {
+ LOGWRN(ctx->ctx, "Invalid position of the key \"%s\" in a list.", cur->schema->name);
+ }
+ }
+ }
} else if (snode->nodetype & LYD_NODE_INNER) {
if (ctx->status == LYXML_ELEM_CONTENT) {
LY_ERR r = lyxml_get_string((struct lyxml_context *)ctx, data, &buffer, &buffer_size, &value, &value_len, &dynamic);
@@ -317,6 +335,18 @@
ret = lydxml_nodes(ctx, (struct lyd_node_inner *)cur, data, lyd_node_children_p(cur));
LY_CHECK_GOTO(ret, cleanup);
}
+
+ if (!(ctx->options & LYD_OPT_PARSE_ONLY)) {
+ /* add any missing default children */
+ ret = lyd_validate_defaults_r((struct lyd_node_inner *)cur, lyd_node_children_p(cur), cur->schema, NULL,
+ &ctx->incomplete_type_validation, &ctx->when_check);
+ LY_CHECK_GOTO(ret, cleanup);
+ }
+
+ /* hash now that all keys should be parsed, rehash for key-less list */
+ if (snode->nodetype == LYS_LIST) {
+ lyd_hash(cur);
+ }
} else if (snode->nodetype & LYD_NODE_ANY) {
unsigned int cur_element_index = ctx->elements.count;
const char *start = *data, *stop;
@@ -369,42 +399,27 @@
/* add attributes */
LY_CHECK_GOTO(ret = lydxml_attributes(ctx, &attrs_data, cur), cleanup);
- /* remember we need to evaluate this node's when */
+ /* correct flags */
if (!(snode->nodetype & (LYS_ACTION | LYS_NOTIF)) && snode->when) {
- ly_set_add(&ctx->when_check, cur, LY_SET_OPT_USEASLIST);
+ if (ctx->options & LYD_OPT_TRUSTED) {
+ /* just set it to true */
+ cur->flags |= LYD_WHEN_TRUE;
+ } else {
+ /* remember we need to evaluate this node's when */
+ ly_set_add(&ctx->when_check, cur, LY_SET_OPT_USEASLIST);
+ }
}
-
- /* hash */
- lyd_hash(cur);
+ if (ctx->options & LYD_OPT_TRUSTED) {
+ /* node is valid */
+ cur->flags &= ~LYD_NEW;
+ }
/* insert */
- if (parent) {
- if (cur->schema->flags & LYS_KEY) {
- /* check the key order, the anchor must always be the last child */
- key_anchor = lyd_get_prev_key_anchor(parent->child, cur->schema);
- if ((!key_anchor && parent->child) || (key_anchor && key_anchor->next)) {
- if (ctx->options & LYD_OPT_STRICT) {
- LOGVAL(ctx->ctx, LY_VLOG_LINE, &ctx->line, LYVE_DATA, "Invalid position of the key \"%s\" in a list.",
- cur->schema->name);
- ret = LY_EVALID;
- goto cleanup;
- } else {
- LOGWRN(ctx->ctx, "Invalid position of the key \"%s\" in a list.", cur->schema->name);
- }
- }
- }
- lyd_insert_node((struct lyd_node *)parent, NULL, cur);
- } else if (*node) {
- lyd_insert_node(NULL, *node, cur);
- } else {
- (*node) = cur;
- }
+ lyd_insert_node((struct lyd_node *)parent, node, cur);
cur = NULL;
}
- /* TODO add missing siblings default elements */
-
/* success */
ret = LY_SUCCESS;
@@ -428,7 +443,6 @@
lyd_parse_xml(struct ly_ctx *ctx, const char *data, int options, struct lyd_node **result)
{
LY_ERR ret = LY_SUCCESS;
- struct lyd_node_inner *parent = NULL;
const struct lyd_node **result_trees = NULL;
struct lyd_xml_ctx xmlctx = {0};
@@ -439,68 +453,38 @@
/* init */
*result = NULL;
-#if 0
- if (options & LYD_OPT_RPCREPLY) {
- /* prepare container for RPC reply, for which we need RPC
- * - prepare *result as top-level node
- * - prepare parent as the RPC/action node */
- const struct lyd_node *action;
- for (action = trees[0]; action && action->schema->nodetype != LYS_ACTION; action = lyd_node_children(action)) {
- /* skip list's keys */
- for ( ;action && action->schema->nodetype == LYS_LEAF; action = action->next);
- if (action && action->schema->nodetype == LYS_ACTION) {
- break;
- }
- }
- if (!action) {
- LOGERR(ctx, LY_EINVAL, "Data parser invalid argument trees - the first item in the array must be the RPC/action request when parsing %s.",
- lyd_parse_options_type2str(options));
- return LY_EINVAL;
- }
- parent = (struct lyd_node_inner*)lyd_dup(action, NULL, LYD_DUP_WITH_PARENTS);
- LY_CHECK_ERR_RET(!parent, LOGERR(ctx, ly_errcode(ctx), "Unable to duplicate RPC/action container for RPC/action reply."), ly_errcode(ctx));
- for (*result = (struct lyd_node*)parent; (*result)->parent; *result = (struct lyd_node*)(*result)->parent);
- }
-#endif
-
- if (!data || !data[0]) {
- /* no data - just check for missing mandatory nodes */
- goto validation;
- }
-
- ret = lydxml_nodes(&xmlctx, parent, &data, *result ? &parent->child : result);
+ ret = lydxml_nodes(&xmlctx, NULL, &data, result);
LY_CHECK_GOTO(ret, cleanup);
- /* prepare sized array for validator */
- if (*result) {
- result_trees = lyd_trees_new(1, *result);
+ if (!(options & LYD_OPT_PARSE_ONLY)) {
+ /* add top-level default nodes */
+ ret = lyd_validate_defaults_top(result, NULL, 0, ctx, &xmlctx.incomplete_type_validation, &xmlctx.when_check, options);
+ LY_CHECK_GOTO(ret, cleanup);
+
+ /* prepare sized array for validator */
+ if (*result) {
+ result_trees = lyd_trees_new(1, *result);
+ }
+
+ /* finish incompletely validated terminal values/attributes and when conditions */
+ ret = lyd_validate_unres(&xmlctx.incomplete_type_validation, &xmlctx.incomplete_type_validation_attrs,
+ &xmlctx.when_check, LYD_XML, lydxml_resolve_prefix, ctx, result_trees);
+ LY_CHECK_GOTO(ret, cleanup);
+
+ /* context node and other validation tasks that depend on other data nodes */
+ ret = lyd_validate_data(result_trees, NULL, 0, ctx, options);
+ LY_CHECK_GOTO(result, cleanup);
}
- /* finish incompletely validated terminal values/attributes and when conditions */
- ret = lyd_validate_unres(&xmlctx.incomplete_type_validation, &xmlctx.incomplete_type_validation_attrs,
- &xmlctx.when_check, LYD_XML, lydxml_resolve_prefix, ctx, result_trees);
- LY_CHECK_GOTO(ret, cleanup);
-
-validation:
-#if 0
- if ((!(*result) || (parent && !parent->child)) && (options & (LYD_OPT_RPC | LYD_OPT_NOTIF))) {
- /* error, missing top level node identify RPC and Notification */
- LOGERR(ctx, LY_EINVAL, "Invalid input data of data parser - expected %s which cannot be empty.",
- lyd_parse_options_type2str(options));
- ret = LY_EINVAL;
- goto cleanup;
- }
-#endif
-
- /* context node and other validation tasks that depend on other data nodes */
- ret = lyd_validate_data(result_trees, NULL, 0, ctx, options);
- LY_CHECK_GOTO(result, cleanup);
-
cleanup:
+ /* there should be no unresolved types stored */
+ assert(!(options & LYD_OPT_PARSE_ONLY) || (!xmlctx.incomplete_type_validation.count
+ && !xmlctx.incomplete_type_validation_attrs.count && !xmlctx.when_check.count));
+
ly_set_erase(&xmlctx.incomplete_type_validation, NULL);
ly_set_erase(&xmlctx.incomplete_type_validation_attrs, NULL);
ly_set_erase(&xmlctx.when_check, NULL);
- lyxml_context_clear((struct lyxml_context*)&xmlctx);
+ lyxml_context_clear((struct lyxml_context *)&xmlctx);
lyd_trees_free(result_trees, 0);
if (ret) {
lyd_free_all(*result);
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 7c8aacd..bf0dd16 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -1454,7 +1454,7 @@
} else {
/* b) in data tree */
if (*node_d) {
- /* internal node */
+ /* inner node */
lyd_find_sibling_next(lyd_node_children(*node_d), mod, id, id_len, NULL, 0, (struct lyd_node **)node_d);
if (!*node_d) {
asprintf(errmsg, "Invalid instance-identifier \"%.*s\" value - path \"%.*s\" does not exists in the data tree(s).",
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 93ee994..bdff1f7 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -122,7 +122,14 @@
/** @} plugintypeopts */
/**
- * @brief Callback to validate, canonize and store (optionally, according to the given @p options) the given @p value according to the given @p type.
+ * @brief Callback to validate, canonize and store (optionally, according to the given @p options) the given @p value
+ * according to the given @p type.
+ *
+ * Even when the callback returns #LY_EINCOMPLETE, the value must be normally stored in the structure
+ * (meaning it can be printed/duplicated/compared). That basically means that the #LY_TYPE_OPTS_SECOND_CALL
+ * should only validate the value but not change the internal value! The only exception is union, when this could
+ * happen. However, even on the first call it is stored as a potentially matching value, which means the value
+ * structure is valid. That is all that is required.
*
* Note that the \p value string is not necessarily zero-terminated. The provided \p value_len is always correct.
*
@@ -159,6 +166,8 @@
/**
* @brief Callback for comparing 2 values of the same type.
+ * Must be able to compare values that are not fully resolved! Meaning, whose storing callback returned
+ * #LY_EINCOMPLETE and the was not called again.
*
* Caller is responsible to provide values of the SAME type.
*
@@ -171,6 +180,8 @@
/**
* @brief Callback to receive printed (canonical) value of the data stored in @p value.
+ * Must be able to print values that are not fully resolved! Meaning, whose storing callback returned
+ * #LY_EINCOMPLETE and the was not called again.
*
* @param[in] value Value to print.
* @param[in] format Format in which the data are supposed to be printed.
@@ -188,11 +199,14 @@
/**
* @brief Callback to duplicate data in data structure. Note that callback is even responsible for duplicating lyd_value::canonized.
+ * Must be able to duplicate values that are not fully resolved! Meaning, whose storing callback returned
+ * #LY_EINCOMPLETE and the was not called again.
*
* @param[in] ctx libyang context of the @p dup. Note that the context of @p original and @p dup might not be the same.
* @param[in] original Original data structure to be duplicated.
* @param[in,out] dup Prepared data structure to be filled with the duplicated data of @p original.
- * @return LY_SUCCESS after successful duplication, other LY_ERR values otherwise.
+ * @return LY_SUCCESS after successful duplication.
+ * @return other LY_ERR values on error.
*/
typedef LY_ERR (*ly_type_dup_clb)(struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup);
diff --git a/src/printer.c b/src/printer.c
index 72872b1..6efb076 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -20,9 +20,11 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <assert.h>
#include "log.h"
#include "printer_internal.h"
+#include "plugins_types.h"
/**
* @brief informational structure shared by printers
@@ -62,6 +64,92 @@
{"unique", "tag", 0}, /**< LYEXT_SUBSTMT_UNIQUE */
};
+/**
+ * @brief Check whether a node value equals to its default one.
+ *
+ * @param[in] node Term node to test.
+ * @return 0 if no,
+ * @return non-zero if yes.
+ */
+static int
+ly_is_default(const struct lyd_node *node)
+{
+ const struct lysc_node_leaf *leaf;
+ const struct lysc_node_leaflist *llist;
+ const struct lyd_node_term *term;
+ size_t i;
+
+ assert(node->schema->nodetype & LYD_NODE_TERM);
+ term = (const struct lyd_node_term *)node;
+
+ if (node->schema->nodetype == LYS_LEAF) {
+ leaf = (const struct lysc_node_leaf *)node->schema;
+ if (!leaf->dflt) {
+ return 0;
+ }
+
+ /* compare with the default value */
+ if (leaf->type->plugin->compare(&term->value, leaf->dflt)) {
+ return 0;
+ }
+ } else {
+ llist = (const struct lysc_node_leaflist *)node->schema;
+ if (!llist->dflts) {
+ return 0;
+ }
+
+ LY_ARRAY_FOR(llist->dflts, i) {
+ /* compare with each possible default value */
+ if (llist->type->plugin->compare(&term->value, llist->dflts[i])) {
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+int
+ly_should_print(const struct lyd_node *node, int options)
+{
+ const struct lyd_node *next, *elem;
+
+ if (options & LYDP_WD_TRIM) {
+ /* do not print default nodes */
+ if (node->flags & LYD_DEFAULT) {
+ /* implicit default node/NP container with only default nodes */
+ return 0;
+ } else if (node->schema->nodetype & LYD_NODE_TERM) {
+ if (ly_is_default(node)) {
+ /* explicit default node */
+ return 0;
+ }
+ }
+ } else if ((node->flags & LYD_DEFAULT) && !(options & LYDP_WD_MASK) && !(node->schema->flags & LYS_CONFIG_R)) {
+ /* LYP_WD_EXPLICIT
+ * - print only if it contains status data in its subtree */
+ LYD_TREE_DFS_BEGIN(node, next, elem) {
+ if (elem->schema->flags & LYS_CONFIG_R) {
+ return 1;
+ }
+ LYD_TREE_DFS_END(node, next, elem)
+ }
+ return 0;
+ } else if ((node->flags & LYD_DEFAULT) && (node->schema->nodetype == LYS_CONTAINER) && !(options & LYDP_KEEPEMPTYCONT)) {
+ /* avoid empty default containers */
+ LYD_TREE_DFS_BEGIN(node, next, elem) {
+ if (elem->schema->nodetype != LYS_CONTAINER) {
+ return 1;
+ }
+ assert(elem->flags & LYD_DEFAULT);
+ LYD_TREE_DFS_END(node, next, elem)
+ }
+ return 0;
+ }
+
+ return 1;
+}
+
LY_ERR
ly_print(struct lyout *out, const char *format, ...)
{
diff --git a/src/printer_internal.h b/src/printer_internal.h
index 973eb20..7d1ecee 100644
--- a/src/printer_internal.h
+++ b/src/printer_internal.h
@@ -120,6 +120,16 @@
LY_ERR xml_print_data(struct lyout *out, const struct lyd_node *root, int options);
/**
+ * @brief Check whether the node should even be printed.
+ *
+ * @param[in] node Node to check.
+ * @param[in] options Printer options.
+ * @return 0 if no.
+ * @return non-zero if yes.
+ */
+int ly_should_print(const struct lyd_node *node, int options);
+
+/**
* @brief Generic printer of the given format string into the specified output.
*
* Alternatively, ly_write() can be used.
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 4ce56b8..0e439d2 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -441,12 +441,10 @@
{
LY_ERR ret = LY_SUCCESS;
-#if 0
- if (!lyd_wd_toprint(node, ctx->options)) {
- /* wd says do not print */
+ if (!ly_should_print(node, ctx->options)) {
+ /* do not print at all */
return EXIT_SUCCESS;
}
-#endif
switch (node->schema->nodetype) {
case LYS_CONTAINER:
diff --git a/src/tree_data.c b/src/tree_data.c
index 0b9b59f..b441363 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -458,17 +458,50 @@
LY_ERR ret;
struct lyd_node_term *term;
+ assert(schema->nodetype & LYD_NODE_TERM);
+
term = calloc(1, sizeof *term);
LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
term->schema = schema;
term->prev = (struct lyd_node *)term;
+ term->flags = LYD_NEW;
ret = lyd_value_parse(term, value, value_len, dynamic, 0, get_prefix, prefix_data, format, NULL);
if (ret && (ret != LY_EINCOMPLETE)) {
free(term);
return ret;
}
+ lyd_hash((struct lyd_node *)term);
+
+ *node = (struct lyd_node *)term;
+ return ret;
+}
+
+LY_ERR
+lyd_create_term2(const struct lysc_node *schema, const struct lyd_value *val, struct lyd_node **node)
+{
+ LY_ERR ret;
+ struct lyd_node_term *term;
+ struct lysc_type *type;
+
+ assert(schema->nodetype & LYD_NODE_TERM);
+
+ term = calloc(1, sizeof *term);
+ LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
+
+ term->schema = schema;
+ term->prev = (struct lyd_node *)term;
+ term->flags = LYD_NEW;
+
+ type = ((struct lysc_node_leaf *)schema)->type;
+ ret = type->plugin->duplicate(schema->module->ctx, val, &term->value);
+ if (ret) {
+ LOGERR(schema->module->ctx, ret, "Value duplication failed.");
+ free(term);
+ return ret;
+ }
+ lyd_hash((struct lyd_node *)term);
*node = (struct lyd_node *)term;
return ret;
@@ -479,15 +512,22 @@
{
struct lyd_node_inner *in;
+ assert(schema->nodetype & LYD_NODE_INNER);
+
in = calloc(1, sizeof *in);
LY_CHECK_ERR_RET(!in, LOGMEM(schema->module->ctx), LY_EMEM);
in->schema = schema;
in->prev = (struct lyd_node *)in;
+ in->flags = LYD_NEW;
- if ((schema->nodetype == LYS_CONTAINER) && !(((struct lysc_node_container *)schema)->flags & LYS_PRESENCE)) {
- /* non-presence cotnainer, default */
- in->flags = LYD_DEFAULT;
+ /* do not hash list with keys, we need them for the hash */
+ if ((schema->nodetype != LYS_LIST) || (schema->flags & LYS_KEYLESS)) {
+ lyd_hash((struct lyd_node *)in);
+ }
+ if ((schema->nodetype == LYS_CONTAINER) && !(schema->flags & LYS_PRESENCE)) {
+ /* NP cotnainer always a default */
+ in->flags |= LYD_DEFAULT;
}
*node = (struct lyd_node *)in;
@@ -652,6 +692,9 @@
lyd_insert_node(list, NULL, key);
}
+ /* hash having all the keys */
+ lyd_hash(list);
+
/* success */
*node = list;
list = NULL;
@@ -667,14 +710,18 @@
{
struct lyd_node_any *any;
+ assert(schema->nodetype & LYD_NODE_ANY);
+
any = calloc(1, sizeof *any);
LY_CHECK_ERR_RET(!any, LOGMEM(schema->module->ctx), LY_EMEM);
any->schema = schema;
any->prev = (struct lyd_node *)any;
+ any->flags = LYD_NEW;
any->value.xml = value;
any->value_type = value_type;
+ lyd_hash((struct lyd_node *)any);
*node = (struct lyd_node *)any;
return LY_SUCCESS;
@@ -778,19 +825,22 @@
}
void
-lyd_insert_node(struct lyd_node *parent, struct lyd_node *first_sibling, struct lyd_node *node)
+lyd_insert_node(struct lyd_node *parent, struct lyd_node **first_sibling, struct lyd_node *node)
{
- struct lyd_node *key_anchor;
+ struct lyd_node *anchor;
- assert((!parent && first_sibling) || (!first_sibling && parent));
- assert(node && node->hash);
+ assert((parent || first_sibling) && node && node->hash);
+
+ if (!parent && first_sibling && (*first_sibling) && (*first_sibling)->parent) {
+ parent = (struct lyd_node *)(*first_sibling)->parent;
+ }
if (parent) {
if (node->schema->flags & LYS_KEY) {
/* it is key and we need to insert it at the correct place */
- key_anchor = lyd_get_prev_key_anchor(lyd_node_children(parent), node->schema);
- if (key_anchor) {
- lyd_insert_after(key_anchor, node);
+ anchor = lyd_get_prev_key_anchor(lyd_node_children(parent), node->schema);
+ if (anchor) {
+ lyd_insert_after(anchor, node);
} else if (lyd_node_children(parent)) {
lyd_insert_before((struct lyd_node *)lyd_node_children(parent), node);
} else {
@@ -800,15 +850,26 @@
/* last child */
lyd_insert_last(parent, node);
}
+ } else if (*first_sibling) {
+ /* top-level siblings, find the last one from this module, or simply the last */
+ anchor = (*first_sibling)->prev;
+ while (anchor->prev->next && (lyd_top_node_module(anchor) != lyd_top_node_module(node))) {
+ anchor = anchor->prev;
+ }
+
+ /* insert */
+ lyd_insert_after(anchor, node);
} else {
- /* last sibling */
- lyd_insert_after(first_sibling->prev, node);
+ /* the only sibling */
+ *first_sibling = node;
}
- /* remove default flags from NP containers */
- while (parent && (parent->flags & LYD_DEFAULT)) {
- parent->flags &= ~LYD_DEFAULT;
- parent = (struct lyd_node *)parent->parent;
+ if (!(node->flags & LYD_DEFAULT)) {
+ /* remove default flags from NP containers */
+ while (parent && (parent->flags & LYD_DEFAULT)) {
+ parent->flags &= ~LYD_DEFAULT;
+ parent = (struct lyd_node *)parent->parent;
+ }
}
/* insert into hash table */
@@ -1553,105 +1614,34 @@
return buffer;
}
-API struct ly_set *
-lyd_find_instance(const struct lyd_node *sibling, const struct lysc_node *schema)
-{
- struct ly_set *ret, *ret_aux, *spath;
- const struct lysc_node *siter, *sparent;
- const struct lyd_node *iter;
- unsigned int i, j;
-
- LY_CHECK_ARG_RET(NULL, sibling, schema, NULL);
- if (schema->nodetype & (LYS_CHOICE | LYS_CASE)) {
- LOGARG(schema->module->ctx, schema);
- return NULL;
- }
-
- ret = ly_set_new();
- spath = ly_set_new();
- LY_CHECK_ERR_GOTO(!ret || !spath, LOGMEM(schema->module->ctx), error);
-
- /* build schema path until sibling parent */
- sparent = sibling->parent ? sibling->parent->schema : NULL;
- for (siter = schema; siter && (siter != sparent); siter = siter->parent) {
- if (siter->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LIST | LYS_LEAFLIST | LYS_ANYDATA | LYS_NOTIF | LYS_RPC | LYS_ACTION)) {
- /* standard data node */
- ly_set_add(spath, (void *)siter, LY_SET_OPT_USEASLIST);
-
- } /* else skip the rest node types */
- }
- /* no valid path */
- LY_CHECK_GOTO(!spath->count, error);
-
- /* start searching */
- LY_LIST_FOR(sibling, iter) {
- if (iter->schema == spath->objs[spath->count - 1]) {
- ly_set_add(ret, (void *)iter, LY_SET_OPT_USEASLIST);
- }
- }
- for (i = spath->count - 1; i; i--) {
- if (!ret->count) {
- /* nothing found */
- break;
- }
-
- ret_aux = ly_set_new();
- LY_CHECK_ERR_GOTO(!ret_aux, LOGMEM(schema->module->ctx), error);
- for (j = 0; j < ret->count; j++) {
- LY_LIST_FOR(lyd_node_children(ret->objs[j]), iter) {
- if (iter->schema == spath->objs[i - 1]) {
- ly_set_add(ret_aux, (void *)iter, LY_SET_OPT_USEASLIST);
- }
- }
- }
- ly_set_free(ret, NULL);
- ret = ret_aux;
- }
-
- ly_set_free(spath, NULL);
- return ret;
-
-error:
- ly_set_free(ret, NULL);
- ly_set_free(spath, NULL);
-
- return NULL;
-}
-
-API LY_ERR
-lyd_find_sibling_next(const struct lyd_node *first, const struct lys_module *module, const char *name, size_t name_len,
- const char *key_or_value, size_t val_len, struct lyd_node **match)
+LY_ERR
+lyd_find_sibling_next2(const struct lyd_node *first, const struct lysc_node *schema, const char *key_or_value,
+ size_t val_len, struct lyd_node **match)
{
LY_ERR rc;
const struct lyd_node *node = NULL;
struct lyd_node_term *term;
- const struct lysc_node *schema;
struct ly_keys keys = {0};
struct lyd_value val = {0};
size_t i;
- LY_CHECK_ARG_RET(NULL, module, name, LY_EINVAL);
+ LY_CHECK_ARG_RET(NULL, schema, LY_EINVAL);
if (!first) {
/* no data */
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
return LY_ENOTFOUND;
}
- /* find schema */
- schema = lys_find_child(first->parent ? first->parent->schema : NULL, module, name, name_len, 0, 0);
- if (!schema) {
- LOGERR(module->ctx, LY_EINVAL, "Schema node not found.");
- return LY_EINVAL;
- }
-
if (key_or_value && !val_len) {
val_len = strlen(key_or_value);
}
if (key_or_value && (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
/* store the value */
- LY_CHECK_GOTO(lyd_value_store(&val, schema, key_or_value, val_len, 0, lydjson_resolve_prefix, NULL, LYD_JSON), cleanup);
+ LY_CHECK_GOTO(rc = lyd_value_store(&val, schema, key_or_value, val_len, 0, lydjson_resolve_prefix, NULL, LYD_JSON), cleanup);
} else if (key_or_value && (schema->nodetype == LYS_LIST)) {
/* parse keys into canonical values */
LY_CHECK_GOTO(rc = ly_keys_parse(schema, key_or_value, val_len, 1, &keys), cleanup);
@@ -1671,7 +1661,7 @@
(struct lyd_node **)&term);
if (rc == LY_ENOTFOUND) {
/* all keys must always exist */
- LOGINT_RET(module->ctx);
+ LOGINT_RET(schema->module->ctx);
}
LY_CHECK_GOTO(rc, cleanup);
@@ -1701,23 +1691,51 @@
if (!node) {
rc = LY_ENOTFOUND;
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
goto cleanup;
}
/* success */
- *match = (struct lyd_node *)node;
+ if (match) {
+ *match = (struct lyd_node *)node;
+ }
rc = LY_SUCCESS;
cleanup:
ly_keys_clean(&keys);
if (val.realtype) {
- val.realtype->plugin->free(module->ctx, &val);
+ val.realtype->plugin->free(schema->module->ctx, &val);
}
return rc;
}
API LY_ERR
+lyd_find_sibling_next(const struct lyd_node *first, const struct lys_module *module, const char *name, size_t name_len,
+ const char *key_or_value, size_t val_len, struct lyd_node **match)
+{
+ const struct lysc_node *schema;
+
+ LY_CHECK_ARG_RET(NULL, module, name, match, LY_EINVAL);
+
+ if (!first) {
+ /* no data */
+ *match = NULL;
+ return LY_ENOTFOUND;
+ }
+
+ /* find schema */
+ schema = lys_find_child(first->parent ? first->parent->schema : NULL, module, name, name_len, 0, 0);
+ if (!schema) {
+ LOGERR(module->ctx, LY_EINVAL, "Schema node not found.");
+ return LY_EINVAL;
+ }
+
+ return lyd_find_sibling_next2(first, schema, key_or_value, val_len, match);
+}
+
+API LY_ERR
lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match)
{
struct lyd_node **match_p;
@@ -1727,7 +1745,9 @@
if (!siblings) {
/* no data */
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
return LY_ENOTFOUND;
}
@@ -1761,11 +1781,15 @@
}
if (!siblings) {
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
return LY_ENOTFOUND;
}
- *match = (struct lyd_node *)siblings;
+ if (match) {
+ *match = (struct lyd_node *)siblings;
+ }
return LY_SUCCESS;
}
@@ -1914,11 +1938,15 @@
}
if (!siblings) {
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
return LY_ENOTFOUND;
}
- *match = (struct lyd_node *)siblings;
+ if (match) {
+ *match = (struct lyd_node *)siblings;
+ }
return LY_SUCCESS;
}
@@ -1944,7 +1972,9 @@
if (!siblings) {
/* no data */
- *match = NULL;
+ if (match) {
+ *match = NULL;
+ }
return LY_ENOTFOUND;
}
@@ -1954,7 +1984,7 @@
case LYS_ANYXML:
case LYS_ANYDATA:
case LYS_NOTIF:
- case LYS_RPC:
+ case LYS_ACTION:
case LYS_LEAF:
/* find it based on schema only */
rc = lyd_find_sibling_schema(siblings, schema, match);
@@ -1962,13 +1992,11 @@
case LYS_LEAFLIST:
/* target used attributes: schema, hash, value */
LY_CHECK_RET(lyd_create_term(schema, key_or_value, val_len, NULL, lydjson_resolve_prefix, NULL, LYD_JSON, &target));
- lyd_hash(target);
/* fallthrough */
case LYS_LIST:
if (schema->nodetype == LYS_LIST) {
/* target used attributes: schema, hash, child (all keys) */
LY_CHECK_RET(lyd_create_list(schema, key_or_value, val_len, &target));
- lyd_hash(target);
}
/* find it */
diff --git a/src/tree_data.h b/src/tree_data.h
index 51d6649..2f8411d 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -19,6 +19,7 @@
#include <stdint.h>
#include "log.h"
+#include "set.h"
#include "tree.h"
#include "tree_schema.h"
@@ -170,7 +171,7 @@
struct lyd_value *value; /**< representation of the value according to the selected union's subtype (stored as lyd_value::realpath
here, in subvalue structure */
} *subvalue; /**< data to represent data with multiple types (union). Original value is stored in the main
- lyd_value:canonized while the lyd_value_subvalue::value contains representation according to the
+ lyd_value:canonical_cache while the lyd_value_subvalue::value contains representation according to the
one of the union's type. The lyd_value_subvalue:prefixes provides (possible) mappings from prefixes
in original value to YANG modules. These prefixes are necessary to parse original value to the union's
subtypes. */
@@ -229,7 +230,7 @@
#define LYD_NODE_ANY (LYS_ANYDATA) /**< Schema nodetype mask for lyd_node_any */
/**
- * @defgroup dnodeflags Data nodes flags
+ * @defgroup dnodeflags Data node flags
* @ingroup datatree
* @{
*
@@ -245,12 +246,15 @@
* 1 LYD_DEFAULT |x| |x|x| | | |
* +-+-+-+-+-+-+-+
* 2 LYD_WHEN_TRUE |x|x|x|x|x| | |
+ * +-+-+-+-+-+-+-+
+ * 3 LYD_NEW |x|x|x|x|x|x|x|
* ---------------------+-+-+-+-+-+-+-+
*
*/
#define LYD_DEFAULT 0x01 /**< default (implicit) node */
#define LYD_WHEN_TRUE 0x02 /**< all when conditions of this node were evaluated to true */
+#define LYD_NEW 0x04 /**< node was created after the last validation, is needed for the next validation */
/** @} */
/**
@@ -367,58 +371,86 @@
*
* Various options to change the data tree parsers behavior.
*
- * Default behavior:
+ * Default parser behavior:
* - in case of XML, parser reads all data from its input (file, memory, XML tree) including the case of not well-formed
* XML document (multiple top-level elements) and if there is an unknown element, it is skipped including its subtree
* (see the next point). This can be changed by the #LYD_OPT_NOSIBLINGS option which make parser to read only a single
- * tree (with a single root element) from its input.
- * - parser silently ignores the data without a matching node in schema trees. If the caller want to stop
+ * tree (with a single root element) from its input,
+ * - parser silently ignores the data without a matching node in schema trees. If the caller wants to stop
* parsing in case of presence of unknown data, the #LYD_OPT_STRICT can be used. The strict mode is useful for
* NETCONF servers, since NETCONF clients should always send data according to the capabilities announced by the server.
* On the other hand, the default non-strict mode is useful for clients receiving data from NETCONF server since
* clients are not required to understand everything the server does. Of course, the optimal strategy for clients is
- * to use filtering to get only the required data. Having an unknown element of the known namespace is always an error.
- * The behavior can be changed by #LYD_OPT_STRICT option.
- * - using obsolete statements (status set to obsolete) just generates a warning, but the processing continues. The
- * behavior can be changed by #LYD_OPT_OBSOLETE option.
- * - parser expects that the provided data provides complete datastore content (both the configuration and state data)
- * and performs data validation according to all YANG rules. This can be a problem in case of representing NETCONF's
- * subtree filter data, edit-config's data or other type of data set - such data do not represent a complete data set
- * and some of the validation rules can fail. Therefore there are other options (within lower 8 bits) to make parser
- * to accept such a data.
- * - when parser evaluates when-stmt condition to false, a validation error is raised. If the
- * #LYD_OPT_WHENAUTODEL is used, the invalid node is silently removed instead of an error. The option (and also this default
- * behavior) takes effect only in case of #LYD_OPT_DATA or #LYD_OPT_CONFIG type of data.
+ * to use filtering to get only the required data. Having an unknown element of the known namespace is always an error,
+ * - using obsolete statements (status set to obsolete) just generates a warning, but the processing continues
+ * (see #LYD_OPT_OBSOLETE).
+ *
+ * Default parser validation behavior:
+ * - the provided data are expected to provide complete datastore content (both the configuration and state data)
+ * and performs data validation according to all YANG rules, specifics follow,
+ * - all types are fully resolved (leafref/instance-identifier targets, unions) and must be valid (lists have
+ * all the keys, leaf(-lists) correct values),
+ * - when statements on existing nodes are evaluated, if not satisfied, a validation error is raised,
+ * - data from several cases cause a validation error,
+ * - default values are added.
* @{
*/
-#define LYD_OPT_DATA 0x00 /**< Default type of data - complete datastore content with configuration as well as
+#define LYD_OPT_DATA 0x0 /**< Default type of data - complete datastore content with configuration as well as
state data. */
-#define LYD_OPT_CONFIG LYD_OPT_NO_STATE /**< A configuration datastore - complete datastore without state data. */
+#define LYD_OPT_CONFIG LYD_VALOPT_NO_STATE /**< A configuration datastore - complete datastore without state data. */
#define LYD_OPT_GET LYD_OPT_PARSE_ONLY /**< Data content from a NETCONF reply message to the NETCONF
\<get\> operation. */
-#define LYD_OPT_GETCONFIG LYD_OPT_PARSE_ONLY | LYD_OPT_NO_STATE /**< Data content from a NETCONF reply message to
+#define LYD_OPT_GETCONFIG LYD_OPT_PARSE_ONLY | LYD_VALOPT_NO_STATE /**< Data content from a NETCONF reply message to
the NETCONF \<get-config\> operation. */
-#define LYD_OPT_EDIT LYD_OPT_PARSE_ONLY | LYD_OPT_NO_STATE | LYD_OPT_EMPTY_INST /**< Content of
+#define LYD_OPT_EDIT LYD_OPT_PARSE_ONLY | LYD_VALOPT_NO_STATE | LYD_OPT_EMPTY_INST /**< Content of
the NETCONF \<edit-config\>'s config element. */
-#define LYD_OPT_STRICT 0x0001 /**< Instead of silent ignoring data without schema definition raise an error. */
-#define LYD_OPT_PARSE_ONLY 0x0002 /**< Data will be only parsed and no (only required) validation will be performed. */
-#define LYD_OPT_NO_STATE 0x0004 /**< Consider state data not allowed and raise an error if they are found. */
-#define LYD_OPT_EMPTY_INST 0x0008 /**< Allow leaf/leaf-list instances without values and lists without keys. */
-#define LYD_OPT_VAL_DATA_ONLY 0x0010 /**< Validate only modules whose data actually exist. */
-//#define LYD_OPT_DESTRUCT 0x0400 /**< Free the provided XML tree during parsing the data. With this option, the
-// provided XML tree is affected and all successfully parsed data are freed.
-// This option is applicable only to lyd_parse_xml() function. */
-//#define LYD_OPT_OBSOLETE 0x0800 /**< Raise an error when an obsolete statement (status set to obsolete) is used. */
+#define LYD_OPT_PARSE_ONLY 0x0001 /**< Data will be only parsed and no validation will be performed. When statements
+ are kept unevaluated, union types may not be fully resolved, and default values
+ are not added (only the ones parsed are present). */
+#define LYD_OPT_TRUSTED 0x0002 /**< Data are considered trusted so they will be parsed as validated. If the parsed
+ data are not valid, using this flag may lead to some unexpected behavior!
+ This flag can be used only with #LYD_OPT_PARSE_ONLY. */
+#define LYD_OPT_STRICT 0x0004 /**< Instead of silently ignoring data without schema definition raise an error. */
+#define LYD_OPT_EMPTY_INST 0x0008 /**< Allow leaf/leaf-list instances without values and lists without keys. */
//#define LYD_OPT_NOSIBLINGS 0x1000 /**< Parse only a single XML tree from the input. This option applies only to
// XML input data. */
+
+/** @} dataparseroptions */
+
+/**
+ * @defgroup datavalidationoptions Data validation options
+ * @ingroup datatree
+ *
+ * Various options to change data validation behaviour, both for the parser and separate validation.
+ *
+ * Default separate validation behavior:
+ * - the provided data are expected to provide complete datastore content (both the configuration and state data)
+ * and performs data validation according to all YANG rules, specifics follow,
+ * - all types are fully resolved (leafref/instance-identifier targets, unions) and must be valid (lists have
+ * all the keys, leaf(-lists) correct values),
+ * - when statements on existing nodes are evaluated. Depending on the previous when state (from previous validation
+ * or parsing), the node is silently auto-deleted if the state changed from true to false, otherwise a validation error
+ * is raised if it evaluates to false,
+ * - data from several cases behave based on their previous state (from previous validation or parsing). If there existed
+ * already a case and another one was added, the previous one is silently auto-deleted. Otherwise (if data from 2 or
+ * more cases were created) a validation error is raised,
+ * - default values are added.
+ *
+ * @{
+ */
+
+#define LYD_VALOPT_NO_STATE 0x00010000 /**< Consider state data not allowed and raise an error if they are found. */
+#define LYD_VALOPT_DATA_ONLY 0x00020000 /**< Validate only modules whose data actually exist. */
+//#define LYD_VALOPT_OBSOLETE 0x0800 /**< Raise an error when an obsolete statement (status set to obsolete) is used. */
+
+/** @} datavalidationoptions */
+
//#define LYD_OPT_VAL_DIFF 0x40000 /**< Flag only for validation, store all the data node changes performed by the validation
// in a diff structure. */
//#define LYD_OPT_DATA_TEMPLATE 0x1000000 /**< Data represents YANG data template. */
-/**@} dataparseroptions */
-
/**
* @brief Get the node's children list if any.
*
@@ -722,19 +754,6 @@
char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
/**
- * @brief Search in the given siblings for instances of the provided schema node, recursively.
- * Does **not** use hashes - should not be used unless necessary for best performance.
- *
- * If \p sibling is the first top-level sibling, the whole data tree is effectively searched.
- *
- * @param[in] sibling Starting data sibling for the search.
- * @param[in] schema Schema node of the data nodes caller wants to find.
- * @return Set of found data nodes. If no data node is found, the returned set is empty.
- * @return NULL in case of error.
- */
-struct ly_set *lyd_find_instance(const struct lyd_node *sibling, const struct lysc_node *schema);
-
-/**
* @brief Find the node, in the list, satisfying the given restrictions.
* Does **not** use hashes - should not be used unless necessary for best performance.
*
@@ -775,7 +794,7 @@
*
* @param[in] siblings Siblings to search in including preceding and succeeding nodes.
* @param[in] target Target node to find.
- * @param[out] match Found data node.
+ * @param[out] match Can be NULL, otherwise the found data node.
* @return LY_SUCCESS on success, @p match set.
* @return LY_ENOTFOUND if not found, @p match set to NULL.
* @return LY_ERR value if another error occurred.
@@ -820,7 +839,7 @@
* Note that any explicit values (leaf-list or list key values) will be canonized first
* before comparison. But values that do not have a canonical value are expected to be in the
* JSON format!
- * @param[out] match Found data node.
+ * @param[out] match Can be NULL, otherwise the found data node.
* @return LY_SUCCESS on success, @p match set.
* @return LY_ENOTFOUND if not found, @p match set to NULL.
* @return LY_EINVAL if @p schema is a key-less list.
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 45f4e3f..6e6ee2e 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -53,3 +53,14 @@
return NULL;
}
}
+
+const struct lys_module *
+lyd_top_node_module(const struct lyd_node *node)
+{
+ const struct lysc_node *schema;
+
+ assert(node && !node->parent);
+
+ for (schema = node->schema; schema->parent; schema = schema->parent);
+ return schema->module;
+}
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 9b24e10..8b53af2 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -21,14 +21,16 @@
/**
* @brief Get address of a node's child pointer if any.
*
- * Decides the node's type and in case it has a children list, returns its address.
* @param[in] node Node to check.
- * @return Address of the node's child member if any, NULL otherwise.
+ * @return Address of the node's child member,
+ * @return NULL if there is no child pointer.
*/
struct lyd_node **lyd_node_children_p(struct lyd_node *node);
/**
- * @brief Create a term (leaf/leaf-list) node. Hash is not calculated.
+ * @brief Create a term (leaf/leaf-list) node from a string value.
+ *
+ * Hash is calculated and new node flag is set.
*
* @param[in] schema Schema node of the new data node.
* @param[in] value String value to be parsed.
@@ -46,7 +48,24 @@
ly_clb_resolve_prefix get_prefix, void *prefix_data, LYD_FORMAT format, struct lyd_node **node);
/**
- * @brief Create an inner (container/list/RPC/action/notification) node. Hash is not calculated.
+ * @brief Create a term (leaf/leaf-list) node from a parsed value by duplicating it.
+ *
+ * Hash is calculated and new node flag is set.
+ *
+ * @param[in] schema Schema node of the new data node.
+ * @param[in] val Parsed value to use.
+ * @param[out] node Created node.
+ * @return LY_SUCCESS on success.
+ * @return LY_ERR value if an error occurred.
+ */
+LY_ERR lyd_create_term2(const struct lysc_node *schema, const struct lyd_value *val, struct lyd_node **node);
+
+/**
+ * @brief Create an inner (container/list/RPC/action/notification) node.
+ *
+ * Hash is calculated and new node flag is set except
+ * for list with keys, when the hash is not calculated!
+ * Also, non-presence container has its default flag set.
*
* @param[in] schema Schema node of the new data node.
* @param[out] node Created node.
@@ -56,7 +75,9 @@
LY_ERR lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node);
/**
- * @brief Create a list with all its keys (cannot be used for key-less list). Hash is not calculated.
+ * @brief Create a list with all its keys (cannot be used for key-less list).
+ *
+ * Hash is calculated and new node flag is set.
*
* @param[in] schema Schema node of the new data node.
* @param[in] keys_str List instance key values in the form of "[key1='val1'][key2='val2']...".
@@ -69,7 +90,9 @@
LY_ERR lyd_create_list(const struct lysc_node *schema, const char *keys_str, size_t keys_len, struct lyd_node **node);
/**
- * @brief Create an anyxml/anydata node. Hash is not calculated.
+ * @brief Create an anyxml/anydata node.
+ *
+ * Hash is calculated and flags are properly set based on @p is_valid.
*
* @param[in] schema Schema node of the new data node.
* @param[in] value Value of the any node, is directly assigned into the data node.
@@ -78,7 +101,8 @@
* @return LY_SUCCESS on success.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_any(const struct lysc_node *schema, const void *value, LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node);
+LY_ERR lyd_create_any(const struct lysc_node *schema, const void *value, LYD_ANYDATA_VALUETYPE value_type,
+ struct lyd_node **node);
/**
* @brief Find the key after which to insert the new key.
@@ -92,13 +116,14 @@
/**
* @brief Insert a node into parent/siblings. In case a key is being inserted into a list, the correct position
- * is found and inserted into. Otherwise it is inserted at the last place.
+ * is found and inserted into. Also, in case we are inserting into top-level siblings, insert it as
+ * the last sibling of all the module data siblings. Otherwise it is inserted at the very last place.
*
- * @param[in] parent Parent to insert into, NULL if @p first_sibling is set.
- * @param[in] first_sibling First top-level sibling, NULL if @p parent is set.
+ * @param[in] parent Parent to insert into, NULL for top-level sibling.
+ * @param[in,out] first_sibling First sibling, NULL if no top-level sibling exist yet. Can be also NULL if @p parent is set.
* @param[in] node Individual node (without siblings) to insert.
*/
-void lyd_insert_node(struct lyd_node *parent, struct lyd_node *first_sibling, struct lyd_node *node);
+void lyd_insert_node(struct lyd_node *parent, struct lyd_node **first_sibling, struct lyd_node *node);
/**
* @brief Create and insert an attribute (last) into a parent.
@@ -215,4 +240,46 @@
*/
void lyd_value_free_path(struct ly_ctx *ctx, struct lyd_value_path *path);
+/**
+ * @brief Find the node, in the list, satisfying the given restrictions.
+ * Does **not** use hashes - should not be used unless necessary for best performance.
+ *
+ * @param[in] first Starting sibling node for search, only succeeding ones are searched.
+ * @param[in] schema Schema node of the data node to find.
+ * @param[in] key_or_value Expected value depends on the type of @p schema:
+ * LYS_CONTAINER:
+ * LYS_ANYXML:
+ * LYS_ANYDATA:
+ * LYS_NOTIF:
+ * LYS_RPC:
+ * LYS_ACTION:
+ * NULL should be always set, will be ignored.
+ * LYS_LEAF:
+ * LYS_LEAFLIST:
+ * Optional restriction on the specific leaf(-list) value.
+ * LYS_LIST:
+ * Optional keys values of the matching list instances in the form of "[key1='val1'][key2='val2']...".
+ * The keys do not have to be ordered and not all keys need to be specified.
+ *
+ * Note that any explicit values (leaf, leaf-list or list key values) will be canonized first
+ * before comparison. But values that do not have a canonical value are expected to be in the
+ * JSON format!
+ * @param[in] val_len Optional length of the @p key_or_value argument in case it is not NULL-terminated string.
+ * @param[out] match Can be NULL, otherwise the found data node.
+ * @return LY_SUCCESS on success, @p match set.
+ * @return LY_ENOTFOUND if not found, @p match set to NULL.
+ * @return LY_ERR value if another error occurred.
+ */
+LY_ERR lyd_find_sibling_next2(const struct lyd_node *first, const struct lysc_node *schema, const char *key_or_value,
+ size_t val_len, struct lyd_node **match);
+
+/**
+ * @brief Get the module, whose data this top-level node belongs to. Useful for augments, when the augmented
+ * module is the data owner. Handles top-level choice augments.
+ *
+ * @param[in] node Data node to examine.
+ * @return Module owner of the node.
+ */
+const struct lys_module *lyd_top_node_module(const struct lyd_node *node);
+
#endif /* LY_TREE_DATA_INTERNAL_H_ */
diff --git a/src/validation.c b/src/validation.c
index e2deb7a..a32a11e 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -160,27 +160,55 @@
return ly_ctx_get_module_iter(ctx, i);
}
+static int
+lyd_val_has_choice_data(const struct lysc_node *snode, struct lyd_node *sibling)
+{
+ const struct lysc_node *iter = NULL;
+
+ assert(snode->nodetype == LYS_CHOICE);
+
+ while ((iter = lys_getnext(iter, snode, NULL, 0))) {
+ switch (iter->nodetype) {
+ case LYS_CONTAINER:
+ case LYS_ANYXML:
+ case LYS_ANYDATA:
+ case LYS_LEAF:
+ if (!lyd_find_sibling_val(sibling, iter, NULL, 0, NULL)) {
+ /* one case child data instance found */
+ return 1;
+ }
+ break;
+ case LYS_LIST:
+ case LYS_LEAFLIST:
+ if (!lyd_find_sibling_next2(sibling, iter, NULL, 0, NULL)) {
+ /* one case child data instance found */
+ return 1;
+ }
+ break;
+ default:
+ assert(0);
+ LOGINT(snode->module->ctx);
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
static LY_ERR
lyd_validate_mandatory(const struct lysc_node *snode, struct lyd_node *sibling)
{
- struct lyd_node *node;
- int is_choice = 0;
-
if (snode->nodetype == LYS_CHOICE) {
- is_choice = 1;
- }
+ /* some data of a choice case exist */
+ if (lyd_val_has_choice_data(snode, sibling)) {
+ return LY_SUCCESS;
+ }
+ } else {
+ assert(snode->nodetype & (LYS_LEAF | LYS_CONTAINER | LYD_NODE_ANY));
- LY_LIST_FOR(sibling, node) {
- if (is_choice) {
- if (node->schema->parent && (node->schema->parent->nodetype & LYS_CASE) && (node->schema->parent->parent == snode)) {
- /* case data instance found */
- return LY_SUCCESS;
- }
- } else {
- if (node->schema == snode) {
- /* data instance found */
- return LY_SUCCESS;
- }
+ if (!lyd_find_sibling_val(sibling, snode, NULL, 0, NULL)) {
+ /* data instance found */
+ return LY_SUCCESS;
}
}
@@ -195,13 +223,29 @@
uint32_t count = 0;
struct lyd_node *iter;
+ assert(min || max);
+
LY_LIST_FOR(sibling, iter) {
if (iter->schema == snode) {
++count;
+
+ if (min && (count == min)) {
+ /* satisfied */
+ min = 0;
+ if (!max) {
+ /* nothing more to check */
+ break;
+ }
+ }
+ if (max && (count > max)) {
+ /* not satisifed */
+ break;
+ }
}
}
- if (min && (count < min)) {
+ if (min) {
+ assert(count < min);
LOGVAL(snode->module->ctx, LY_VLOG_LYSC, snode, LY_VCODE_NOMIN, snode->name);
return LY_EVALID;
} else if (max && (count > max)) {
@@ -215,16 +259,32 @@
static struct lyd_node *
lyd_val_uniq_find_leaf(const struct lysc_node_leaf *uniq_leaf, struct lyd_node *list)
{
- struct ly_set *set;
- struct lyd_node *node = NULL;
+ struct lyd_node *node;
+ const struct lysc_node *iter;
+ size_t depth = 0, i;
- set = lyd_find_instance(lyd_node_children(list), (struct lysc_node *)uniq_leaf);
- if (set && set->count) {
- /* we were looking for a leaf */
- assert(set->count == 1);
- node = set->objs[0];
+ /* get leaf depth */
+ for (iter = (struct lysc_node *)uniq_leaf; iter && (iter != list->schema); iter = iter->parent) {
+ if (!(iter->nodetype & (LYS_CHOICE | LYS_CASE))) {
+ ++depth;
+ }
}
- ly_set_free(set, NULL);
+
+ node = list;
+ while (node && depth) {
+ /* find schema node with this depth */
+ for (i = depth - 1, iter = (struct lysc_node *)uniq_leaf; i; iter = iter->parent) {
+ if (!(iter->nodetype & (LYS_CHOICE | LYS_CASE))) {
+ --i;
+ }
+ }
+
+ /* find iter instance in children */
+ assert(iter->nodetype & (LYS_CONTAINER | LYS_LEAF));
+ lyd_find_sibling_val(lyd_node_children(node), iter, NULL, 0, &node);
+ --depth;
+ }
+
return node;
}
@@ -346,8 +406,13 @@
assert(uniques);
/* get all list instances */
- set = lyd_find_instance(sibling, snode);
- LY_CHECK_RET(!set, LY_EINT);
+ set = ly_set_new();
+ LY_CHECK_ERR_RET(!set, LOGMEM(ctx), LY_EMEM);
+ LY_LIST_FOR(sibling, diter) {
+ if (diter->schema == snode) {
+ ly_set_add(set, diter, LY_SET_OPT_USEASLIST);
+ }
+ }
if (set->count == 2) {
/* simple comparison */
@@ -493,8 +558,8 @@
/* validate all restrictions of nodes themselves */
LY_LIST_FOR(sibling, node) {
+ /* TODO node instance duplicities */
/* TODO node's must */
- /* TODO node instance duplicites */
/* TODO node status */
/* TODO node's if-features */
/* TODO node list keys */
@@ -505,6 +570,9 @@
LY_CHECK_RET(lyd_validate_siblings_schema_r(sibling, sparent, mod, options));
LY_LIST_FOR(sibling, node) {
+ /* this sibling is valid */
+ node->flags &= ~LYD_NEW;
+
/* validate all children recursively */
LY_CHECK_RET(lyd_validate_siblings_r((struct lyd_node *)lyd_node_children(node), node->schema, mod, options));
}
@@ -514,19 +582,19 @@
LY_ERR
lyd_validate_data(const struct lyd_node **trees, const struct lys_module **modules, int mod_count, struct ly_ctx *ctx,
- int options)
+ int val_opts)
{
uint32_t i = 0, j;
const struct lys_module *mod;
struct lyd_node *tree;
- if (options & LYD_OPT_VAL_DATA_ONLY) {
+ if (val_opts & LYD_VALOPT_DATA_ONLY) {
if (trees) {
for (j = 0; j < LY_ARRAY_SIZE(trees); ++j) {
tree = (struct lyd_node *)trees[j];
/* validate all top-level nodes and then inner nodes recursively */
- LY_CHECK_RET(lyd_validate_siblings_r(tree, NULL, tree->schema->module->compiled, options));
+ LY_CHECK_RET(lyd_validate_siblings_r(tree, NULL, tree->schema->module->compiled, val_opts));
}
}
} else {
@@ -547,7 +615,112 @@
}
/* validate all top-level nodes and then inner nodes recursively */
- LY_CHECK_RET(lyd_validate_siblings_r(tree, NULL, mod->compiled, options));
+ LY_CHECK_RET(lyd_validate_siblings_r(tree, NULL, mod->compiled, val_opts));
+ }
+ }
+
+ return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_validate_defaults_r(struct lyd_node_inner *parent, struct lyd_node **first, const struct lysc_node *schema,
+ const struct lysc_module *mod, struct ly_set *node_types, struct ly_set *node_when)
+{
+ const struct lysc_node *iter = NULL;
+ struct lyd_node *node;
+ struct lyd_value **dflts;
+ size_t i;
+
+ assert(first && (schema || mod) && node_types && node_when);
+
+ while ((iter = lys_getnext(iter, schema, mod, LYS_GETNEXT_WITHCHOICE))) {
+ switch (iter->nodetype) {
+ case LYS_CHOICE:
+ if (((struct lysc_node_choice *)iter)->dflt && !lyd_val_has_choice_data(iter, *first)) {
+ /* create default case data */
+ LY_CHECK_RET(lyd_validate_defaults_r(parent, first, (struct lysc_node *)((struct lysc_node_choice *)iter)->dflt,
+ NULL, node_types, node_when));
+ }
+ break;
+ case LYS_CONTAINER:
+ if (!(iter->flags & LYS_PRESENCE) && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+ /* create default NP container (default flag automatically set) */
+ LY_CHECK_RET(lyd_create_inner(iter, &node));
+ lyd_insert_node((struct lyd_node *)parent, first, node);
+
+ if (iter->when) {
+ /* remember to resolve when */
+ ly_set_add(node_when, node, LY_SET_OPT_USEASLIST);
+ }
+ }
+ break;
+ case LYS_LEAF:
+ if (((struct lysc_node_leaf *)iter)->dflt && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+ /* create default leaf */
+ LY_CHECK_RET(lyd_create_term2(iter, ((struct lysc_node_leaf *)iter)->dflt, &node));
+ node->flags |= LYD_DEFAULT;
+ lyd_insert_node((struct lyd_node *)parent, first, node);
+
+ if (iter->when) {
+ /* remember to resolve when */
+ ly_set_add(node_when, node, LY_SET_OPT_USEASLIST);
+ }
+ }
+ break;
+ case LYS_LEAFLIST:
+ if (((struct lysc_node_leaflist *)iter)->dflts && lyd_find_sibling_next2(*first, iter, NULL, 0, NULL)) {
+ /* create all default leaf-lists */
+ dflts = ((struct lysc_node_leaflist *)iter)->dflts;
+ LY_ARRAY_FOR(dflts, i) {
+ LY_CHECK_RET(lyd_create_term2(iter, dflts[i], &node));
+ node->flags |= LYD_DEFAULT;
+ lyd_insert_node((struct lyd_node *)parent, first, node);
+
+ if (iter->when) {
+ /* remember to resolve when */
+ ly_set_add(node_when, node, LY_SET_OPT_USEASLIST);
+ }
+ }
+ }
+ break;
+ default:
+ /* without defaults */
+ break;
+ }
+ }
+
+ return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_validate_defaults_top(struct lyd_node **first, const struct lys_module **modules, int mod_count, struct ly_ctx *ctx,
+ struct ly_set *node_types, struct ly_set *node_when, int val_opts)
+{
+ uint32_t i = 0;
+ const struct lys_module *mod;
+ struct lyd_node *sibling;
+
+ assert(node_types && node_when);
+
+ if (val_opts & LYD_VALOPT_DATA_ONLY) {
+ mod = NULL;
+ LY_LIST_FOR(*first, sibling) {
+ if (lyd_top_node_module(sibling) != mod) {
+ /* remember this module */
+ mod = lyd_top_node_module(sibling);
+
+ /* add all top-level defaults for this module */
+ LY_CHECK_RET(lyd_validate_defaults_r(NULL, first, NULL, mod->compiled, node_types, node_when));
+ }
+ }
+ } else {
+ while ((mod = lyd_val_next_module(modules, mod_count, ctx, &i))) {
+ if (!mod->implemented) {
+ continue;
+ }
+
+ /* add all top-level defaults for this module */
+ LY_CHECK_RET(lyd_validate_defaults_r(NULL, first, NULL, mod->compiled, node_types, node_when));
}
}
diff --git a/src/validation.h b/src/validation.h
index 8c665d7..dfc81d0 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -34,17 +34,45 @@
ly_clb_resolve_prefix get_prefix_clb, void *parser_data, const struct lyd_node **trees);
/**
- * @brief Perform all vaidation tasks that depend on other nodes, the data tree must
- * be complete when calling this function.
+ * @brief Perform all validation tasks, the data tree must be complete when calling this function.
*
* @param[in] trees Array of all data trees.
* @param[in] modules Array of modules that should be validated, NULL for all modules.
* @param[in] mod_count Modules count.
* @param[in] ctx Context if all modules should be validated, NULL for only selected modules.
- * @param[in] options Validation options.
+ * @param[in] val_opts Validation options.
* @return LY_ERR value.
*/
LY_ERR lyd_validate_data(const struct lyd_node **trees, const struct lys_module **modules, int mod_count,
- struct ly_ctx *ctx, int options);
+ struct ly_ctx *ctx, int val_opts);
+
+/**
+ * @brief Check the existence and create any non-existing default siblings, recursively for the created nodes.
+ *
+ * @param[in] parent Parent of the potential default values.
+ * @param[in,out] first First sibling.
+ * @param[in] schema Schema parent of the default values, NULL for top-level siblings.
+ * @param[in] mod Module of the default values, NULL for nested (non top-level) siblings.
+ * @param[in] node_types Set to add nodes with unresolved types into.
+ * @param[in] node_when Set to add nodes with "when" conditions into.
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_validate_defaults_r(struct lyd_node_inner *parent, struct lyd_node **first, const struct lysc_node *schema,
+ const struct lysc_module *mod, struct ly_set *node_types, struct ly_set *node_when);
+
+/**
+ * @brief Check the existence and create any non-existing default top-level nodes.
+ *
+ * @param[in,out] first First top-level sibling. There may be no explicit nodes.
+ * @param[in] modules Array of modules that should be considered, NULL for all modules.
+ * @param[in] mod_count Modules count.
+ * @param[in] ctx Context if all modules should be considered, NULL for only selected modules.
+ * @param[in] node_types Set to add nodes with unresolved types into, can be NULL if not needed.
+ * @param[in] node_when Set to add nodes with "when" conditions into, can be NULL if not needed.
+ * @param[in] val_opts Relevant validation options (#LYD_VALOPT_DATA_ONLY).
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_validate_defaults_top(struct lyd_node **first, const struct lys_module **modules, int mod_count,
+ struct ly_ctx *ctx, struct ly_set *node_types, struct ly_set *node_when, int val_opts);
#endif /* LY_VALIDATION_H_ */
diff --git a/src/xml.h b/src/xml.h
index 2795d62..7965e7e 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -65,7 +65,7 @@
* @brief Status of the parser providing information what is expected next (which function is supposed to be called).
*/
enum LYXML_PARSER_STATUS {
- LYXML_ELEMENT, /* expecting XML element, call lyxml_get_element() */
+ LYXML_ELEMENT = 0, /* expecting XML element, call lyxml_get_element() */
LYXML_ELEM_CONTENT, /* expecting content of an element, call lyxml_get_string */
LYXML_ATTRIBUTE, /* expecting XML attribute, call lyxml_get_attribute() */
LYXML_ATTR_CONTENT, /* expecting value of an attribute, call lyxml_get_string */
diff --git a/src/xpath.c b/src/xpath.c
index 38489ee..c5e3259 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -917,7 +917,11 @@
trg->val.nodes = malloc(trg->used * sizeof *trg->val.nodes);
LY_CHECK_ERR_RET(!trg->val.nodes, LOGMEM(src->ctx); memset(trg, 0, sizeof *trg), );
memcpy(trg->val.nodes, src->val.nodes, src->used * sizeof *src->val.nodes);
- trg->ht = lyht_dup(src->ht);
+ if (src->ht) {
+ trg->ht = lyht_dup(src->ht);
+ } else {
+ trg->ht = NULL;
+ }
}
}
}
@@ -8032,7 +8036,7 @@
exp_idx = 0;
memset(set, 0, sizeof *set);
set->type = LYXP_SET_EMPTY;
- set_insert_node(set, (struct lyd_node *)ctx_node, 0, ctx_node_type, options);
+ set_insert_node(set, (struct lyd_node *)ctx_node, 0, ctx_node_type, 0);
set->ctx = local_mod->ctx;
set->ctx_node = ctx_node;
set->root_type = lyxp_get_root_type(ctx_node, NULL, options);
diff --git a/tests/features/test_types.c b/tests/features/test_types.c
index 751f78a..a08b3ce 100644
--- a/tests/features/test_types.c
+++ b/tests/features/test_types.c
@@ -155,7 +155,7 @@
const char *data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("int8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -172,28 +172,28 @@
/* invalid range */
data = "<int8 xmlns=\"urn:tests:types\">1</int8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"1\" does not satisfy the range constraint. /");
data = "<int16 xmlns=\"urn:tests:types\">100</int16>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"100\" does not satisfy the range constraint. /");
/* invalid value */
data = "<int32 xmlns=\"urn:tests:types\">0x01</int32>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid int32 value \"0x01\". /");
data = "<int64 xmlns=\"urn:tests:types\"></int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty int64 value. /");
data = "<int64 xmlns=\"urn:tests:types\"> </int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty int64 value. /");
data = "<int64 xmlns=\"urn:tests:types\">-10 xxx</int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid int64 value \"-10 xxx\". /");
s->func = NULL;
@@ -212,7 +212,7 @@
const char *data = "<uint8 xmlns=\"urn:tests:types\">\n 150 \t\n </uint8>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("uint8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -229,28 +229,28 @@
/* invalid range */
data = "<uint8 xmlns=\"urn:tests:types\">\n 15 \t\n </uint8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"15\" does not satisfy the range constraint. /");
data = "<uint16 xmlns=\"urn:tests:types\">\n 1500 \t\n </uint16>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"1500\" does not satisfy the range constraint. /");
/* invalid value */
data = "<uint32 xmlns=\"urn:tests:types\">-10</uint32>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"-10\" is out of uint32's min/max bounds. /");
data = "<uint64 xmlns=\"urn:tests:types\"/>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty uint64 value. /");
data = "<uint64 xmlns=\"urn:tests:types\"> </uint64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty uint64 value. /");
data = "<uint64 xmlns=\"urn:tests:types\">10 xxx</uint64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid uint64 value \"10 xxx\". /");
s->func = NULL;
@@ -269,7 +269,7 @@
const char *data = "<dec64 xmlns=\"urn:tests:types\">\n +8 \t\n </dec64>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -285,7 +285,7 @@
lyd_free_all(tree);
data = "<dec64 xmlns=\"urn:tests:types\">8.00</dec64>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -294,7 +294,7 @@
lyd_free_all(tree);
data = "<dec64-norestr xmlns=\"urn:tests:types\">-9.223372036854775808</dec64-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -303,7 +303,7 @@
lyd_free_all(tree);
data = "<dec64-norestr xmlns=\"urn:tests:types\">9.223372036854775807</dec64-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -313,32 +313,32 @@
/* invalid range */
data = "<dec64 xmlns=\"urn:tests:types\">\n 15 \t\n </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"15.0\" does not satisfy the range constraint. /");
data = "<dec64 xmlns=\"urn:tests:types\">\n 0 \t\n </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"0.0\" does not satisfy the range constraint. /");
/* invalid value */
data = "<dec64 xmlns=\"urn:tests:types\">xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid 1. character of decimal64 value \"xxx\". /");
data = "<dec64 xmlns=\"urn:tests:types\"/>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty decimal64 value. /");
data = "<dec64 xmlns=\"urn:tests:types\"> </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty decimal64 value. /");
data = "<dec64 xmlns=\"urn:tests:types\">8.5 xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid 6. character of decimal64 value \"8.5 xxx\". /");
data = "<dec64 xmlns=\"urn:tests:types\">8.55 xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits. /");
s->func = NULL;
@@ -356,7 +356,7 @@
const char *data = "<str xmlns=\"urn:tests:types\">teststring</str>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -365,34 +365,34 @@
/* multibyte characters (€ encodes as 3-byte UTF8 character, length restriction is 2-5) */
data = "<str-utf8 xmlns=\"urn:tests:types\">€€</str-utf8>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str-utf8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("€€", leaf->value.canonical_cache);
lyd_free_all(tree);
data = "<str-utf8 xmlns=\"urn:tests:types\">€</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Length \"1\" does not satisfy the length constraint. /");
data = "<str-utf8 xmlns=\"urn:tests:types\">€€€€€€</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Length \"6\" does not satisfy the length constraint. /");
data = "<str-utf8 xmlns=\"urn:tests:types\">€€x</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("String \"€€x\" does not conform to the 1. pattern restriction of its type. /");
/* invalid length */
data = "<str xmlns=\"urn:tests:types\">short</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Length \"5\" does not satisfy the length constraint. /");
data = "<str xmlns=\"urn:tests:types\">tooooo long</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Length \"11\" does not satisfy the length constraint. /");
/* invalid pattern */
data = "<str xmlns=\"urn:tests:types\">string15</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("String \"string15\" does not conform to the 1. pattern restriction of its type. /");
s->func = NULL;
@@ -411,7 +411,7 @@
const char *data = "<bits xmlns=\"urn:tests:types\">\n two \t\nzero\n </bits>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -431,7 +431,7 @@
lyd_free_all(tree);
data = "<bits xmlns=\"urn:tests:types\">zero two</bits>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -440,12 +440,12 @@
/* disabled feature */
data = "<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Bit \"one\" is disabled by its 1. if-feature condition. /");
/* enable that feature */
assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -463,12 +463,12 @@
/* multiple instances of the bit */
data = "<bits xmlns=\"urn:tests:types\">one zero one</bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Bit \"one\" used multiple times. /");
/* invalid bit value */
data = "<bits xmlns=\"urn:tests:types\">one xero one</bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid bit value \"xero\". /");
s->func = NULL;
@@ -487,7 +487,7 @@
const char *data = "<enums xmlns=\"urn:tests:types\">white</enums>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -503,12 +503,12 @@
/* disabled feature */
data = "<enums xmlns=\"urn:tests:types\">yellow</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Enumeration \"yellow\" is disabled by its 1. if-feature condition. /");
/* enable that feature */
assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -517,15 +517,15 @@
/* leading/trailing whitespaces are not valid */
data = "<enums xmlns=\"urn:tests:types\"> white</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid enumeration value \" white\". /");
data = "<enums xmlns=\"urn:tests:types\">white\n</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid enumeration value \"white\n\". /");
/* invalid enumeration value */
data = "<enums xmlns=\"urn:tests:types\">black</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid enumeration value \"black\". /");
s->func = NULL;
@@ -545,7 +545,7 @@
"<binary-norestr xmlns=\"urn:tests:types\">TQ==</binary-norestr>";
/* valid data (hello) */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -565,21 +565,21 @@
/* no data */
data = "<binary-norestr xmlns=\"urn:tests:types\">\n \t\n </binary-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
data = "<binary-norestr xmlns=\"urn:tests:types\"></binary-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
data = "<binary-norestr xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -588,23 +588,23 @@
/* invalid base64 character */
data = "<binary-norestr xmlns=\"urn:tests:types\">a@bcd=</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid Base64 character (@). /");
/* missing data */
data = "<binary-norestr xmlns=\"urn:tests:types\">aGVsbG8</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Base64 encoded value length must be divisible by 4. /");
data = "<binary-norestr xmlns=\"urn:tests:types\">VsbG8=</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Base64 encoded value length must be divisible by 4. /");
/* invalid binary length */
data = "<binary xmlns=\"urn:tests:types\">aGVsbG93b3JsZA==</binary>"; /* helloworld */
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("This base64 value must be of length 5. /");
data = "<binary xmlns=\"urn:tests:types\">TQ==</binary>"; /* M */
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("This base64 value must be of length 5. /");
s->func = NULL;
@@ -622,7 +622,7 @@
const char *data = "<bool xmlns=\"urn:tests:types\">true</bool>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -631,7 +631,7 @@
lyd_free_all(tree);
data = "<bool xmlns=\"urn:tests:types\">false</bool>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -641,11 +641,11 @@
/* invalid value */
data = "<bool xmlns=\"urn:tests:types\">unsure</bool>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid boolean value \"unsure\". /");
data = "<bool xmlns=\"urn:tests:types\"> true</bool>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid boolean value \" true\". /");
s->func = NULL;
@@ -663,7 +663,7 @@
const char *data = "<empty xmlns=\"urn:tests:types\"></empty>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -671,7 +671,7 @@
lyd_free_all(tree);
data = "<empty xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -680,11 +680,11 @@
/* invalid value */
data = "<empty xmlns=\"urn:tests:types\">x</empty>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty value \"x\". /");
data = "<empty xmlns=\"urn:tests:types\"> </empty>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid empty value \" \". /");
s->func = NULL;
@@ -723,7 +723,7 @@
const char *data = "<ident xmlns=\"urn:tests:types\">gigabit-ethernet</ident>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -739,7 +739,7 @@
lyd_free_all(tree);
data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</ident>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -749,19 +749,19 @@
/* invalid value */
data = "<ident xmlns=\"urn:tests:types\">fast-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid identityref \"fast-ethernet\" value - identity not found. /");
data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:slow-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid identityref \"x:slow-ethernet\" value - identity not found. /");
data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:crypto-alg</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid identityref \"x:crypto-alg\" value - identity not accepted by the type specification. /");
data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:unknown\">x:fast-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid identityref \"x:fast-ethernet\" value - unable to map prefix to YANG schema. /");
s->func = NULL;
@@ -793,7 +793,7 @@
"<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:cont/xdf:leaftarget</xdf:inst>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -818,8 +818,8 @@
data = "<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id></list>"
"<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:id</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -828,8 +828,8 @@
data = "<leaflisttarget xmlns=\"urn:tests:types\">1</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">2</leaflisttarget>"
"<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:leaflisttarget[.='1']</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -838,8 +838,8 @@
data = "<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id><value>x</value></list>"
"<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[2]/xdf:value</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -850,8 +850,8 @@
"<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='b']</id><value>y</value></list_inst>"
"<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[.='b']\"]/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -880,8 +880,8 @@
"<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[2]</id><value>y</value></list_inst>"
"<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[2]\"]/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -891,8 +891,8 @@
data = "<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:ethernet</id><value>x</value></list_ident>"
"<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:fast-ethernet</id><value>y</value></list_ident>"
"<a:inst xmlns:a=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">/a:list_ident[a:id='d:fast-ethernet']/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -902,8 +902,8 @@
data = "<list2 xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list2>"
"<list2 xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list2>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a:xxx'][a:value='y']/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -913,8 +913,8 @@
data = "<list xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list>"
"<list xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list[2]/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -925,8 +925,8 @@
"<list2 xmlns=\"urn:tests:types\"><id>c</id><value>b</value></list2>"
"<list2 xmlns=\"urn:tests:types\"><id>a</id><value>b</value></list2>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='b']/a:id</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
@@ -939,136 +939,136 @@
/* invalid value */
data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:1leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:1leaftarget\" value at character 11 (1leaftarget). /");
data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont:t:1leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont:t:1leaftarget\" value at character 8 (:t:1leaftarget). /");
data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:invalid/t:path</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:invalid/t:path\" value - path \"/t:cont/t:invalid\" does not exists in the YANG schema. /");
data = "<inst xmlns=\"urn:tests:types\" xmlns:t=\"urn:tests:invalid\">/t:cont/t:leaftarget</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaftarget\" value - unable to map prefix \"t\" to YANG schema. /");
data = "<inst xmlns=\"urn:tests:types\">/cont/leaftarget</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/cont/leaftarget\" value - all node names (/cont) MUST be qualified with explicit namespace prefix. /");
data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
logbuf_assert("Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /");
data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
logbuf_assert("Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /");
data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><t:inst xmlns:t=\"urn:tests:types\">/t:leaflisttarget[1</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:leaflisttarget[1\" value's predicate \"[1\" (Predicate (pos) is not terminated by ']' character.). /");
data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont[1]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont[1]\" value - predicate \"[1]\" for container is not accepted. /");
data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">[1]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"[1]\" value - instance-identifier must starts with '/'. /");
data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[id='1']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[id='1']\" value's predicate \"[id=\" (Missing prefix of a node name.). /");
data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[t:id='1']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[t:id='1']\" value - key-predicate \"[t:id='1']\" is accepted only for lists, not leaf-list. /");
data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget><leaflisttarget>2</leaflisttarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[4]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
logbuf_assert("Invalid instance-identifier \"/types:cont/leaflisttarget[4]\" value - required instance not found. /");
data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[6]</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[6]\" value - "
"position-predicate 6 is bigger than allowed max-elements (5). /");
data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - "
"node \"value\" used in key-predicate \"[t:value='x']\" must be a key. /");
logbuf_clean();
data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - "
"node \"value\" used in key-predicate \"[t:value='x']\" must be a key. /");
data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:x='x']</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:x='x']\" value - "
"path \"/t:cont/t:listtarget[t:x\" does not exists in the YANG schema. /");
data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[.='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[.='x']\" value - "
"leaf-list-predicate \"[.='x']\" is accepted only for leaf-lists, not list. /");
data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='2']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
logbuf_assert("Invalid instance-identifier \"/types:cont/leaflisttarget[.='2']\" value - required instance not found. /");
data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[.='x']\" value - "
"leaf-list-predicate \"[.='x']\"'s value is invalid. /");
data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:id='x']\" value - "
"key-predicate \"[t:id='x']\"'s key value is invalid. /");
data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
"<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='2']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
logbuf_assert("Invalid instance-identifier \"/types:cont/listtarget[id='2']\" value - required instance not found. /");
data = "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
"<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[1][2]</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[1][2]\" value - "
"position predicate (\"[2]\") cannot be used repeatedly for a single node. /");
data = "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
"<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[.='a'][.='b']</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[.='a'][.='b']\" value - "
"leaf-list-predicate (\"[.='b']\") cannot be used repeatedly for a single node. /");
data = "<list xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list>"
"<list xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list[a:id='a'][a:id='b']/a:value</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/a:list[a:id='a'][a:id='b']/a:value\" value - "
"key \"id\" is referenced the second time in key-predicate \"[a:id='b']\". /");
data = "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list2>"
"<list2 xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list2>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a']/a:value</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/a:list2[a:id='a']/a:value\" value - "
"missing 1 key(s) for the list instance \"a:list2[a:id='a']\". /");
@@ -1078,23 +1078,23 @@
"<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
"<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='a']/a:id</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
trees = lyd_trees_new(1, tree);
/* key-predicate */
data = "/a:list2[a:id='a'][a:value='b']/a:id";
- assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
+ assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev->prev, data, strlen(data),
test_instanceid_getprefix, tree->schema->module, LYD_XML, trees));
logbuf_assert("Invalid instance-identifier \"/a:list2[a:id='a'][a:value='b']/a:id\" value - "
"key-predicate \"[a:id='a'][a:value='b']\" does not match any \"list2\" instance. /");
/* leaf-list-predicate */
data = "/a:leaflisttarget[.='c']";
- assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
+ assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev->prev, data, strlen(data),
test_instanceid_getprefix, tree->schema->module, LYD_XML, trees));
logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[.='c']\" value - "
"leaf-list-predicate \"[.='c']\" does not match any \"leaflisttarget\" instance. /");
/* position predicate */
data = "/a:list2[4]";
- assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
+ assert_int_equal(LY_EVALID, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev->prev, data, strlen(data),
test_instanceid_getprefix, tree->schema->module, LYD_XML, trees));
logbuf_assert("Invalid instance-identifier \"/a:list2[4]\" value - "
"position-predicate 4 is bigger than number of instances in the data tree (2). /");
@@ -1102,7 +1102,7 @@
data = "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
"<inst xmlns=\"urn:tests:types\">/a:leaflisttarget[1]</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[1]\" value - unable to map prefix \"a\" to YANG schema. /");
s->func = NULL;
@@ -1134,8 +1134,8 @@
assert_non_null(lys_parse_mem(s->ctx, schema, LYS_IN_YANG));
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1146,8 +1146,8 @@
data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
"<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
"<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">y</lref2>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1156,7 +1156,7 @@
data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
"<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>y</lr1></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
tree = tree->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree))->prev);
@@ -1168,10 +1168,10 @@
data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
"<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
"<l><id>x</id><value>x</value><lr2>y</lr2></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
tree = tree->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
- leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree)->prev)->prev);
+ leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree)->prev->prev)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr2", leaf->schema->name);
assert_string_equal("y", leaf->value.canonical_cache);
@@ -1181,8 +1181,8 @@
"<list xmlns=\"urn:tests:types\"><id>y</id><targets>c</targets><targets>d</targets></list>"
"<c xmlns=\"urn:tests:leafrefs\"><x><x>y</x></x>"
"<l><id>x</id><value>x</value><lr3>c</lr3></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree)->prev)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
@@ -1193,34 +1193,34 @@
/* invalid value */
data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget>"
"<lref xmlns=\"urn:tests:types\">y</lref>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref value \"y\" - required instance \"/leaflisttarget\" with this value does not exists in the data tree(s). /");
data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
"<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
"<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref value \"b\" - required instance \"../list[id = current()/../str-norestr]/targets\" with this value does not exists in the data tree(s). /");
data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
"<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
"<lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref - required instance \"../list[id = current()/../str-norestr]\" does not exists in the data tree(s). /");
data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref - required instance \"../list\" does not exists in the data tree(s). /");
data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
"<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>a</lr1></l></c>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref value \"a\" - required instance \"../../../t:str-norestr\" with this value does not exists in the data tree(s). /");
data = "<str-norestr xmlns=\"urn:tests:types\">z</str-norestr>"
"<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
"<l><id>x</id><value>x</value><lr2>z</lr2></l></c>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid leafref - required instance \"../../l[id=current()/../../../t:str-norestr][value=current()/../../../t:str-norestr]\" "
"does not exists in the data tree(s). /");
@@ -1253,8 +1253,8 @@
"<un1 xmlns=\"urn:tests:types\">12</un1>";
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1281,8 +1281,8 @@
data = "<int8 xmlns=\"urn:tests:types\">11</int8><int8 xmlns=\"urn:tests:types\">12</int8>"
"<un1 xmlns=\"urn:tests:types\">2</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1295,7 +1295,7 @@
lyd_free_all(tree);
data = "<un1 xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1321,7 +1321,7 @@
lyd_free_all(tree);
data = "<un1 xmlns=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">d:superfast-ethernet</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1335,8 +1335,8 @@
data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
"<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[2]</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1350,8 +1350,8 @@
data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
"<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[3]</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- tree = tree->prev;
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1364,7 +1364,7 @@
lyd_free_all(tree);
data = "<un1 xmlns=\"urn:tests:types\">123456789012345678901</un1>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
logbuf_assert("Invalid union value \"123456789012345678901\" - no matching subtype found. /");
s->func = NULL;
diff --git a/tests/src/test_parser_xml.c b/tests/src/test_parser_xml.c
index dcdf84a..5b08f23 100644
--- a/tests/src/test_parser_xml.c
+++ b/tests/src/test_parser_xml.c
@@ -110,7 +110,7 @@
struct lyd_node *tree;
struct lyd_node_term *leaf;
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
@@ -132,7 +132,7 @@
struct lyd_node *tree;
struct lyd_node_any *any;
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_ANYDATA, tree->schema->nodetype);
assert_string_equal("any", tree->schema->name);
@@ -155,7 +155,7 @@
struct lyd_node_term *leaf;
/* check hashes */
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -167,7 +167,7 @@
/* keys order */
data = "<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>c</c><b>b</b></l1>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -184,7 +184,7 @@
lyd_free_all(tree);
data = "<l1 xmlns=\"urn:tests:a\"><c>c</c><b>b</b><a>a</a></l1>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -219,7 +219,7 @@
struct lyd_node *tree;
struct lyd_node_inner *cont;
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("c", tree->schema->name);
@@ -228,7 +228,7 @@
lyd_free_all(tree);
data = "<cp xmlns=\"urn:tests:a\"/>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("cp", tree->schema->name);
diff --git a/tests/src/test_printer_xml.c b/tests/src/test_printer_xml.c
index 2c815d1..c5c6714 100644
--- a/tests/src/test_printer_xml.c
+++ b/tests/src/test_printer_xml.c
@@ -159,7 +159,7 @@
data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>";
result = "<int8 xmlns=\"urn:tests:types\">15</int8>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_true((len = lyd_print_mem(&printed, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, result);
@@ -181,7 +181,7 @@
s->func = test_anydata;
data = "<any xmlns=\"urn:tests:types\"><somexml xmlns:x=\"url:x\" xmlns=\"example.com\"><x:x/></somexml></any>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_true((len = lyd_print_mem(&printed, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
@@ -189,7 +189,7 @@
lyd_free_all(tree);
data = "<any xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_true((len = lyd_print_mem(&printed, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
diff --git a/tests/src/test_tree_data.c b/tests/src/test_tree_data.c
index 25a1cfd..ecba711 100644
--- a/tests/src/test_tree_data.c
+++ b/tests/src/test_tree_data.c
@@ -111,8 +111,8 @@
assert_int_equal(LY_SUCCESS, lyd_compare(NULL, NULL, 0));
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
assert_int_equal(LY_ENOT, lyd_compare(((struct lyd_node_inner*)tree1)->child, tree2, 0));
@@ -121,8 +121,8 @@
data1 = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
data2 = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1->next, tree2, 0));
lyd_free_all(tree1);
@@ -130,8 +130,8 @@
data1 = "<ll xmlns=\"urn:tests:a\">a</ll><ll xmlns=\"urn:tests:a\">b</ll>";
data2 = "<ll xmlns=\"urn:tests:a\">b</ll>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(NULL, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, NULL, 0));
@@ -141,8 +141,8 @@
data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>";
data2 = "<c xmlns=\"urn:tests:a\"><x>y</x></c>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -150,8 +150,8 @@
data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>";
data2 = "<c xmlns=\"urn:tests:a\"><x>x</x><x>y</x></c>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -159,12 +159,12 @@
data1 = "<any xmlns=\"urn:tests:a\"><x>x</x></any>";
data2 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
lyd_free_all(tree1);
data1 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -172,7 +172,6 @@
*state = NULL;
}
-
static void
test_dup(void **state)
{
@@ -182,7 +181,7 @@
const char *result;
const char *data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -190,44 +189,43 @@
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
result = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
lyd_free_all(tree1);
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
result = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_WITH_SIBLINGS | LYD_DUP_RECURSIVE));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree2);
-
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
lyd_free_all(tree1);
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree2);
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
lyd_free_all(tree1);
result = "<l2 xmlns=\"urn:tests:a\"/>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_PARSE_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<any xmlns=\"urn:tests:a\"><c><a>a</a></c></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child, NULL, LYD_DUP_WITH_PARENTS));
assert_string_equal("x", tree2->schema->name);
assert_non_null(tree2->parent);
@@ -236,7 +234,7 @@
lyd_free_all(tree2);
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, NULL, LYD_DUP_WITH_PARENTS));
assert_string_equal("c", tree2->schema->name);
assert_non_null(tree2->parent);
@@ -245,7 +243,7 @@
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
assert_non_null(lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child,
(struct lyd_node_inner*)tree2, LYD_DUP_WITH_PARENTS));
@@ -255,7 +253,7 @@
/* invalid */
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_null(lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, (struct lyd_node_inner*)tree1->next, LYD_DUP_WITH_PARENTS));
lyd_free_all(tree1);
diff --git a/tests/src/test_validation.c b/tests/src/test_validation.c
index ca699ae..660f856 100644
--- a/tests/src/test_validation.c
+++ b/tests/src/test_validation.c
@@ -236,19 +236,19 @@
struct lyd_node *tree;
data = "<c xmlns=\"urn:tests:a\">hey</c>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- logbuf_assert("When condition \"/cont/b = 'val_b'\" not satisfied.");
+ logbuf_assert("When condition \"/cont/b = 'val_b'\" not satisfied. /a:c");
data = "<cont xmlns=\"urn:tests:a\"><b>val_b</b></cont><c xmlns=\"urn:tests:a\">hey</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_string_equal("c", tree->next->schema->name);
assert_int_equal(LYD_WHEN_TRUE, tree->next->flags);
lyd_free_all(tree);
data = "<cont xmlns=\"urn:tests:a\"><a>val</a><b>val_b</b></cont><c xmlns=\"urn:tests:a\">val_c</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
assert_string_equal("a", lyd_node_children(tree)->schema->name);
assert_int_equal(LYD_WHEN_TRUE, lyd_node_children(tree)->flags);
@@ -268,22 +268,22 @@
struct lyd_node *tree;
data = "<d xmlns=\"urn:tests:b\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"choic\" instance does not exist. /b:choic");
data = "<l xmlns=\"urn:tests:b\">string</l><d xmlns=\"urn:tests:b\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"c\" instance does not exist. /b:c");
data = "<a xmlns=\"urn:tests:b\">string</a>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"c\" instance does not exist. /b:c");
data = "<a xmlns=\"urn:tests:b\">string</a><c xmlns=\"urn:tests:b\">string2</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -299,14 +299,14 @@
struct lyd_node *tree;
data = "<d xmlns=\"urn:tests:c\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Too few \"l\" instances. /c:choic/b/l");
data =
"<l xmlns=\"urn:tests:c\">val1</l>"
"<l xmlns=\"urn:tests:c\">val2</l>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Too few \"l\" instances. /c:choic/b/l");
@@ -314,7 +314,7 @@
"<l xmlns=\"urn:tests:c\">val1</l>"
"<l xmlns=\"urn:tests:c\">val2</l>"
"<l xmlns=\"urn:tests:c\">val3</l>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -327,7 +327,7 @@
"<lt xmlns=\"urn:tests:c\"><k>val3</k></lt>"
"<lt xmlns=\"urn:tests:c\"><k>val4</k></lt>"
"<lt xmlns=\"urn:tests:c\"><k>val5</k></lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Too many \"lt\" instances. /c:lt");
@@ -350,7 +350,7 @@
"<lt xmlns=\"urn:tests:d\">"
"<k>val2</k>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -363,7 +363,7 @@
"<k>val2</k>"
"<l1>not-same</l1>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -376,9 +376,9 @@
"<k>val2</k>"
"<l1>same</l1>"
"</lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\".");
+ logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\". /d:lt[k='val2']");
/* now try with more instances */
data =
@@ -414,7 +414,7 @@
"<k>val8</k>"
"<l1>8</l1>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -448,7 +448,7 @@
"<lt xmlns=\"urn:tests:d\">"
"<k>val8</k>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -482,9 +482,9 @@
"<k>val8</k>"
"<l1>8</l1>"
"</lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\".");
+ logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\". /d:lt[k='val2']");
*state = NULL;
}
@@ -554,7 +554,7 @@
"<l3>3</l3>"
"</lt3>"
"</lt2>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY | LYD_OPT_STRICT, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY | LYD_OPT_STRICT, &tree));
assert_non_null(tree);
lyd_free_withsiblings(tree);
@@ -615,10 +615,10 @@
"<l3>3</l3>"
"</lt3>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"l3\" not satisfied in \"/d:lt2[k='val2']/lt3[kk='val3']\" and"
- " \"/d:lt2[k='val2']/lt3[kk='val1']\".");
+ " \"/d:lt2[k='val2']/lt3[kk='val1']\". /d:lt2[k='val2']/lt3[kk='val1']");
data =
"<lt2 xmlns=\"urn:tests:d\">"
@@ -656,9 +656,9 @@
"</cont>"
"<l4>5</l4>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- logbuf_assert("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\".");
+ logbuf_assert("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\". /d:lt2[k='val2']");
data =
"<lt2 xmlns=\"urn:tests:d\">"
@@ -704,9 +704,9 @@
"<l5>3</l5>"
"<l6>3</l6>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_OPT_VAL_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- logbuf_assert("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\".");
+ logbuf_assert("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\". /d:lt2[k='val3']");
*state = NULL;
}