Skip to content

Commit d864d4c

Browse files
committed
common CHANGE use data callback when transforming paths
1 parent e5cafbf commit d864d4c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/common.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ _transform_json2xml(const struct lys_module *module, const char *expr, int schem
259259
if (end) {
260260
name_len = end - cur_expr;
261261
name = strndup(cur_expr, name_len);
262-
mod = ly_ctx_get_module(module->ctx, name, NULL, 1);
262+
mod = ly_ctx_get_module(module->ctx, name, NULL, 0);
263+
if (module->ctx->data_clb) {
264+
if (!mod) {
265+
mod = module->ctx->data_clb(module->ctx, name, NULL, 0, module->ctx->data_clb_data);
266+
} else if (!mod->implemented) {
267+
mod = module->ctx->data_clb(module->ctx, name, mod->ns, LY_MODCLB_NOT_IMPLEMENTED, module->ctx->data_clb_data);
268+
}
269+
}
263270
free(name);
264271
if (!mod) {
265272
LOGVAL(LYE_INMOD_LEN, LY_VLOG_NONE, NULL, name_len, cur_expr);
@@ -339,7 +346,14 @@ _transform_json2xml(const struct lys_module *module, const char *expr, int schem
339346
if (!schema) {
340347
prefix = NULL;
341348
name = strndup(ptr, name_len);
342-
mod = ly_ctx_get_module(module->ctx, name, NULL, 1);
349+
mod = ly_ctx_get_module(module->ctx, name, NULL, 0);
350+
if (module->ctx->data_clb) {
351+
if (!mod) {
352+
mod = module->ctx->data_clb(module->ctx, name, NULL, 0, module->ctx->data_clb_data);
353+
} else if (!mod->implemented) {
354+
mod = module->ctx->data_clb(module->ctx, name, mod->ns, LY_MODCLB_NOT_IMPLEMENTED, module->ctx->data_clb_data);
355+
}
356+
}
343357
free(name);
344358
if (mod) {
345359
prefix = mod->prefix;
@@ -478,7 +492,7 @@ transform_xml2json(struct ly_ctx *ctx, const char *expr, struct lyxml_elem *xml,
478492
}
479493
goto error;
480494
}
481-
mod = ly_ctx_get_module_by_ns(ctx, ns->value, NULL, 1);
495+
mod = ly_ctx_get_module_by_ns(ctx, ns->value, NULL, 0);
482496
if (use_ctx_data_clb && ctx->data_clb) {
483497
if (!mod) {
484498
mod = ctx->data_clb(ctx, NULL, ns->value, 0, ctx->data_clb_data);

0 commit comments

Comments
 (0)