libyang
3.7.5
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
|
Internally, XPath evaluation is performed on when and must conditions in the schema. For that almost a full XPath 1.0 evaluator was implemented. In YANG models you can also find paths identifying augment targets, leafref targets, and trivial paths in choice default and unique statements argument. The exact format of all those paths can be found in the relevant RFCs. Further will only be discussed paths that are used directly in libyang API functions.
Generally, any xpath argument expects an expression similar to when or must as the same evaluator is used. As for the format of any prefixes, the standardized JSON (RFC 7951) was used. Summarized, xpath follows these conventions:
The term path is used when a simplified (subset of) XPath is expected. Path is always a valid XPath but not the other way around. In short, paths only identify a specific (set of) nodes based on their ancestors in the schema. Predicates are allowed the same as for an instance-identifier. Specifically, key values of a list, leaf-list value, or position of lists without keys can be used.
/module-name:container/list[key1='1'][key2='2']
/module-name:container/leaf-list[.='val']
/module-name:container/list-without-keys[3]
/module-name:container/container2/augment-module:aug-cont/aug-list[aug-list-key='value']