libyang wildcard support #1723
-
I am using libyang for validating gNMI xpaths for OpenConfig and proprietary YANG models. We have requirements to support wildcard patterns as described in To summarize
Examples:
The validation function uses lys_find_path(). I am able to validate paths with keys having wildcard values, i.e. What I am unable to do is to validate xpaths in which path elements are asterisks, ellipses or simply omitted as in
I tried different replacement patterns by following examples on the web in https://gerrit.cesnet.cz/plugins/gitiles/github/CESNET/libyang/+/46180b50f25a408db86aba33701493994c932dc7/tests/api/test_xpath.c but nothing seems to work for me :( Any advice would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
What you want to do, in short, is transform those paths into XPath. That should work in the following way: Predicates such as Skipping path elements Not sure what exactly However, |
Beta Was this translation helpful? Give feedback.
-
Hi Michal, I have wildcards working well, but have problems validating XPaths which have multiple keys. I am using the code that someone else wrote, so I am on the learning curve. Here is in a nutshell what the code does: Assume input to a validation function is XPath
These XPaths work (single key): These do not (multiple keys): Realizing that the 2nd list, the channel list, is not the part of the context tree node used by the example code above, my questions are:
Thanks in advance for your help. |
Beta Was this translation helpful? Give feedback.
-
Hello Michal, How do I transform a container-level XPath plus a JSON value into a root-level JSON, so it can be then parsed into LY data schema tree?
I want to transform it into
What would be the most efficient way to do this either in v1 or v2 libyang? Thanks |
Beta Was this translation helpful? Give feedback.
What you want to do, in short, is transform those paths into XPath. That should work in the following way:
Predicates such as
[name=*]
can simply be[name]
I think but using an arbitrary string works fine, too.Skipping path elements
/.../
should have its XPath equivalent as//
.Not sure what exactly
/*/
is supposed to mean but it is valid in XPath and means a single arbitrary element.However,
lys_find_path()
is probably not the function to use because it accepts onlypath
(simplified XPath) and the last 2 cases are not supported for that. You should probably switch tolys_find_xpath()
that accepts full XPath (to the extent supported by libyang).