Skip to content

schema: add lysc_node_lref_xpath_targets() helper #2358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

bradh352
Copy link
Contributor

@bradh352 bradh352 commented Feb 27, 2025

The lysc_node_lref_targets() helper returns a node in the schema, but if the xpath itself had added restrictions such as only matching certain list keys, then there was no way to retrieve that information.

This adds the appropriate helper, sharing as much code as possible with lysc_node_lref_targets() and also adds a test case to check for this.

Fixes #2357

The lysc_node_lref_targets() helper returns a node in the schema,
but if the xpath itself had added restrictions such as only
matching certain list keys, then there was no way to retrieve
that information.

This adds the appropriate helper, sharing as much code as possible
with lysc_node_lref_targets() and also adds a test case to check
for this.

Signed-off-by: Brad House <[email protected]>
@bradh352 bradh352 force-pushed the bradh352/lysc_node_lref_xpath_targets branch from d97ee52 to a53e85e Compare February 27, 2025 16:25
@michalvasko
Copy link
Member

As I mentioned in the linked issue, I would strongly prefer this helper function to be implemented in your project, has little use and hence redundant to be included in libyang.

@bradh352
Copy link
Contributor Author

bradh352 commented Mar 3, 2025

I'm closing this one. I ended up not using it directly in SONiC. Given the fact that the paths returned aren't valid xpaths, it is of minimal use. For Golang I just implemented this directly as cgo code, then rewrote the xpaths to be valid. For python a different approach is used there where it uses the original lysc_node_lref_targets() to look up the data paths that could be impacted, then scans all results doing a value check to limit to the actual matching nodes. A bit more overhead ... but the old libyang1 code was actually doing something similar so its no worse.

@bradh352 bradh352 closed this Mar 3, 2025
@bradh352 bradh352 deleted the bradh352/lysc_node_lref_xpath_targets branch March 3, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants