diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index 12923fd3..1f5fc7e7 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -1003,10 +1003,8 @@ xmldb_get_cache(clixon_handle h, goto done; } /* Original tree: Remove global defaults and empty non-presence containers */ -#if 0 if (xml_defaults_nopresence(x0t, 2) < 0) goto done; -#endif switch (wdef){ case WITHDEFAULTS_REPORT_ALL: break; diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 92a9cd4d..0c755349 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -582,14 +582,17 @@ text_modify(clixon_handle h, x1bstr = xml_body(x1); switch(op){ case OP_CREATE: - if (x0){ + if (x0 && xml_flag(x0, XML_FLAG_DEFAULT)==0){ if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0) goto done; goto fail; } case OP_REPLACE: /* fall thru */ case OP_MERGE: - if (!(op == OP_MERGE && instr==NULL)){ + /* If default flag, clear it */ + if (x0 && xml_flag(x0, XML_FLAG_DEFAULT)) + xml_flag_reset(x0, XML_FLAG_DEFAULT); + if (!(op == OP_MERGE && (instr==NULL))) { /* Remove existing, also applies to merge in the special case * of ordered-by user and (changed) insert attribute. */ @@ -710,7 +713,7 @@ text_modify(clixon_handle h, } break; case OP_DELETE: - if (x0==NULL){ + if (x0==NULL || xml_flag(x0, XML_FLAG_DEFAULT) != 0){ if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0) goto done; goto fail; @@ -780,7 +783,7 @@ text_modify(clixon_handle h, } switch(op){ case OP_CREATE: - if (x0){ + if (x0 && xml_flag(x0, XML_FLAG_DEFAULT)==0){ if (xml_defaults_nopresence(x0, 0) == 0){ if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0) goto done; @@ -973,7 +976,7 @@ text_modify(clixon_handle h, } break; case OP_DELETE: - if (x0==NULL){ + if (x0==NULL || xml_flag(x0, XML_FLAG_DEFAULT) != 0){ if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0) goto done; goto fail; @@ -1304,7 +1307,6 @@ xmldb_put(clixon_handle h, } goto fail; } - /* Remove NONE nodes if all subs recursively are also NONE */ if (xml_tree_prune_flagged_sub(x0, XML_FLAG_NONE, 0, NULL) <0) goto done;