parser xml BUGFIX error for missing namespace
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 944d3d5..a0cf1f5 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -40,6 +40,13 @@
#include "validation.h"
#include "xml.h"
+#define LYDXML_LOG_NAMESPACE_ERR(XMLCTX, PREFIX, PREFIX_LEN) \
+ if (PREFIX_LEN) { \
+ LOGVAL(XMLCTX->ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)PREFIX_LEN, PREFIX); \
+ } else { \
+ LOGVAL(XMLCTX->ctx, LYVE_REFERENCE, "Missing XML namespace."); \
+ }
+
static LY_ERR lydxml_subtree_r(struct lyd_xml_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p,
struct ly_set *parsed);
@@ -123,8 +130,7 @@
/* get namespace of the attribute to find its annotation definition */
ns = lyxml_ns_get(&xmlctx->ns, xmlctx->prefix, xmlctx->prefix_len);
if (!ns) {
- /* unknown namespace, XML error */
- LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)xmlctx->prefix_len, xmlctx->prefix);
+ LYDXML_LOG_NAMESPACE_ERR(xmlctx, xmlctx->prefix, xmlctx->prefix_len);
ret = LY_ENOTFOUND;
goto cleanup;
}
@@ -215,7 +221,7 @@
if (prefix_len) {
ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
if (!ns) {
- LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)prefix_len, prefix);
+ LYDXML_LOG_NAMESPACE_ERR(xmlctx, prefix, prefix_len);
ret = LY_EVALID;
goto cleanup;
}
@@ -537,12 +543,7 @@
if (lydctx->int_opts & LYD_INTOPT_ANY) {
goto unknown_module;
}
-
- if (prefix_len) {
- LOGVAL(ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)prefix_len, prefix);
- } else {
- LOGVAL(ctx, LYVE_REFERENCE, "Missing XML namespace.");
- }
+ LYDXML_LOG_NAMESPACE_ERR(xmlctx, prefix, prefix_len);
return LY_EVALID;
}
@@ -1177,7 +1178,7 @@
prefix_len = xmlctx->prefix_len;
ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
if (!ns) {
- LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)prefix_len, prefix);
+ LYDXML_LOG_NAMESPACE_ERR(xmlctx, prefix, prefix_len);
return LY_EVALID;
} else if (strcmp(ns->uri, uri)) {
/* different namespace */
@@ -1401,7 +1402,7 @@
prefix_len = xmlctx->prefix_len;
ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
if (!ns) {
- LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)prefix_len, prefix);
+ LYDXML_LOG_NAMESPACE_ERR(xmlctx, prefix, prefix_len);
return LY_EVALID;
}