diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index 2e8c6e47..689d0699 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -365,7 +365,7 @@ api_data_write(clicon_handle h, */ if ((xdata0 = xml_new("data0", NULL, NULL)) == NULL) goto done; - { /* XXX mv to copy? */ + if (api_path){ /* XXX mv to copy? */ cxobj *xfrom; cxobj *xac; diff --git a/include/clixon_custom.h b/include/clixon_custom.h index 2405b8a1..f9a9235d 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -78,10 +78,13 @@ */ #define XML_EXPLICIT_INDEX -/*! Treat specially in a xmldb datastore. - * config is treated as a "neutral" tag that does not have a yang spec. +/*! Treat and specially in a xmldb datastore. + * config/data is treated as a "neutral" tag that does not have a yang spec. * In particular when binding xml to yang, if is encountered as top-of-tree, do not * try to bind a yang-spec to this symbol. + * The root of this is GET and PUT commands where the and tag belongs to the + * RPC rather than the data. + * This is a hack, there must be a way to make this more generic */ #define XMLDB_CONFIG_HACK diff --git a/lib/src/clixon_xml_io.c b/lib/src/clixon_xml_io.c index f1c5e024..10b746b5 100644 --- a/lib/src/clixon_xml_io.c +++ b/lib/src/clixon_xml_io.c @@ -436,12 +436,14 @@ _xml_parse(const char *str, if (ret == 0) failed++; break; + case YB_TOP: /* xt: nospec * x: <-- populate from modules */ #ifdef XMLDB_CONFIG_HACK - if (strcmp(xml_name(x),"config") == 0){ + if (strcmp(xml_name(x),"config") == 0 || + strcmp(xml_name(x),"data") == 0){ /* xt: nospec * x: * <-- populate from modules diff --git a/util/clixon_util_xml.c b/util/clixon_util_xml.c index e6241eb8..8a183bea 100644 --- a/util/clixon_util_xml.c +++ b/util/clixon_util_xml.c @@ -161,6 +161,7 @@ main(int argc, char *top_path = NULL; cxobj *xbot; /* Place in xtop where base cxobj is parsed */ cvec *nsc = NULL; + enum yang_bind yb; /* In the startup, logs to stderr & debug flag set later */ clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR); @@ -291,7 +292,13 @@ main(int argc, } } else{ /* XML */ - if ((ret = xml_parse_file2(fd, (xt==NULL)?YB_TOP:YB_PARENT, yspec, NULL, &xt, &xerr)) < 0){ + if (!yang_file_dir) + yb = YB_NONE; + else if (xt == NULL) + yb = YB_TOP; + else + yb = YB_PARENT; + if ((ret = xml_parse_file2(fd, yb, yspec, NULL, &xt, &xerr)) < 0){ fprintf(stderr, "xml parse error: %s\n", clicon_err_reason); goto done; }