From 0789d29ea489b285eac9a706343c7df3767482cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bj=C3=B6rklund?= Date: Wed, 1 Nov 2023 13:34:57 +0100 Subject: [PATCH] See #193 - handle 1.1 scoping rules in XPath evaluations --- pyang/xpath.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyang/xpath.py b/pyang/xpath.py index af5ce339..41d3b8e3 100644 --- a/pyang/xpath.py +++ b/pyang/xpath.py @@ -82,7 +82,13 @@ def v_xpath(ctx, stmt, node): else: q = xpath_parser.parse(stmt.arg) stmt.i_xpath = q - chk_xpath_expr(ctx, stmt.i_orig_module, stmt.pos, node, node, q, None) + if stmt.i_module.i_version == '1': + # in YANG 1 references in submodules are scoped to the submodule + mod = stmt.i_orig_module + else: + # in YANG 1.1 references in submodules are scoped to the module + mod = stmt.i_module + chk_xpath_expr(ctx, mod, stmt.pos, node, node, q, None) except xpath_lexer.XPathError as e: err_add(ctx.errors, stmt.pos, 'XPATH_SYNTAX_ERROR', e.msg) stmt.i_xpath = None