parser xml BUGFIX multi-err validation fixes
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 20663e2..0f86a68 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -803,7 +803,7 @@
if (snode->nodetype == LYS_LIST) {
/* check all keys exist */
r = lyd_parse_check_keys(*node);
- LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
+ LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
}
if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
@@ -827,7 +827,8 @@
LOG_LOCBACK(0, 1, 0, 0);
}
lydctx->parse_opts = prev_parse_opts;
- if (rc && (!(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || (rc != LY_EVALID))) {
+ if (rc && ((*node && !(*node)->hash) || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || (rc != LY_EVALID))) {
+ /* list without keys is unusable or an error */
lyd_free_tree(*node);
*node = NULL;
}
@@ -962,10 +963,17 @@
LY_CHECK_GOTO(rc, cleanup);
/* get the schema node */
- rc = lydxml_subtree_get_snode(lydctx, parent, prefix, prefix_len, name, name_len, &snode, &ext);
- LY_CHECK_GOTO(rc, cleanup);
-
- if (!snode && !(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
+ r = lydxml_subtree_get_snode(lydctx, parent, prefix, prefix_len, name, name_len, &snode, &ext);
+ if (r) {
+ rc = r;
+ if ((r == LY_EVALID) && (lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR)) {
+ /* skip the invalid data */
+ if ((r = lydxml_data_skip(xmlctx))) {
+ rc = r;
+ }
+ }
+ goto cleanup;
+ } else if (!snode && !(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
LOGVRB("Skipping parsing of unknown node \"%.*s\".", name_len, name);
/* skip element with children */
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index bdc223f..17a7433 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1202,7 +1202,7 @@
CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
- CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 6.", NULL);
+ CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 7.", NULL);
CHECK_LOG_CTX_APPTAG("Invalid type uint32 value \"ahoy\".", "Data location \"/ii:cont/ll\", line number 6.", NULL);
/* json */