Skip to content

Commit

Permalink
See #193 - handle 1.1 scoping rules in XPath evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj4668 committed Nov 1, 2023
1 parent 4ba83e7 commit 0789d29
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pyang/xpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0789d29

Please sign in to comment.