Since 6.1 RESTCONF PUTs have added clixon-lib namespace for attributes.

These empty namespaces are removed.
This commit is contained in:
Olof hagsand 2023-03-27 12:57:24 +02:00
parent da2edceb7e
commit 2c104daee2
4 changed files with 21 additions and 4 deletions

View file

@ -653,6 +653,7 @@ text_modify(clicon_handle h,
if (strcmp(restype, "enumeration") == 0 ||
strcmp(restype, "bits") == 0)
x1bstr = clixon_trim2(x1bstr, " \t\n");
#if 0 /* Passes regression test without, keep for some time until other test requires it */
/* If origin body has namespace definitions, copy them. The reason is that
* some bodies rely on namespace prefixes, such as NACM path, but there is
* no way we can know this here.
@ -663,6 +664,7 @@ text_modify(clicon_handle h,
*/
if (assign_namespace_body(x1, x0) < 0)
goto done;
#endif
}
/* XXX here x1bstr is checked for null, while adding an empty string above */
if ((x0b = xml_body_get(x0)) == NULL && x1bstr && strlen(x1bstr)){

View file

@ -1006,6 +1006,7 @@ assign_namespace_element(cxobj *x0, /* source */
*
* @param[in] x0 Source XML
* @param[in] x1 Destination XML
* @note "standard" namespaces, including clixon internal namespaces are removed
*/
int
assign_namespace_body(cxobj *x0, /* source */
@ -1031,9 +1032,13 @@ assign_namespace_body(cxobj *x0, /* source */
else
prefix1 = name;
/* prefix1 contains actual prefix or NULL, prefix0 can be xmlns */
if (strcmp(namespace, NETCONF_BASE_NAMESPACE) ==0 ||
strcmp(namespace, YANG_XML_NAMESPACE) ==0)
if (strcmp(namespace, NETCONF_BASE_NAMESPACE) == 0 ||
strcmp(namespace, YANG_XML_NAMESPACE) == 0 ||
strcmp(namespace, CLIXON_CONF_NS) == 0 ||
strcmp(namespace, CLIXON_LIB_NS) == 0
)
continue;
continue; // XXX
/* Detect if prefix:namespace is declared already? */
if (xml2ns(x1, prefix1, &namespace1) == 1)
continue;