diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c
index 179ebf56..98adafca 100644
--- a/apps/backend/backend_get.c
+++ b/apps/backend/backend_get.c
@@ -847,15 +847,20 @@ get_common(clicon_handle h,
if ((xfind = xml_find(xe, "with-defaults")) != NULL) {
if ((with_defaults = xml_find_value(xfind, "body")) != NULL) {
if (strcmp(with_defaults, "explicit") == 0) {
+ /* Clear marked nodes */
+ if (xml_apply(xret, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0)
+ goto done;
/* Traverse XML and mark state nodes */
if (xml_non_config_data(xret, NULL) < 0)
goto done;
/* Remove default configuration nodes from XML */
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_MARK|XML_FLAG_DEFAULT) < 0)
goto done;
- /* Restore marked nodes */
- if (xml_apply(xret, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0)
- goto done;
+ }
+ else if (strcmp(with_defaults, "trim") == 0) {
+ /* Remove default nodes from XML */
+ if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_DEFAULT) < 0)
+ goto done;
}
else if (strcmp(with_defaults, "report-all") == 0) {
/* Accept mode, do nothing */
diff --git a/test/test_yang_with_defaults.sh b/test/test_yang_with_defaults.sh
index fdb05831..36700964 100755
--- a/test/test_yang_with_defaults.sh
+++ b/test/test_yang_with_defaults.sh
@@ -191,9 +191,12 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
"\
trim" \
"" \
-"applicationoperation-not-supported\
-error\
-with-defaults retrieval mode \"trim\" is not supported"
+"\
+eth08192\
+eth1\
+eth29000not feeling so good\
+eth31500waking up\
+"
new "rfc6243 3.3. 'explicit' Retrieval Mode"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \