cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
716
Views
0
Helpful
2
Replies

NSO Devtools xpath eval expression doesn't work in YANG?

u.avsec
Spotlight
Spotlight

Hi

Devtools have an xpath eval option where xpath expressions can be tested. Really useful, but where those expressions actually work? In XML templates? They seem to not work in YANG as leafrefs or tailf:default-ref.

 

This is my situation:

admin@ncs(config-devices_service-test)# xpath eval deref(current()/device-model)/../bla_prefix:ned-versions[last()]
/services/bla_prefix:bla/device-platform[model='ASR-1001-HX']/ned-versions :: 7.99.1.1

Disregard the hierarchy as it is specific to our yang models and slightly sanitized for public use. Point is, it works in CLI.

 

If I paste it in YANG (changing one level of reference to accommodate actual yang hierarchy CLI can't reach), model fails to compile:

 error: bad argument value "deref(current()/../device-model)/../bla_prefix:ned-versions[last()]", should be of type extended-schema-nodeid

What am I missing? A setting or a tailf: option that I am not setting unknowingly? Or YANG 1.0 simply isn't as capable?

 

P.S. ned-version node I'm performing last() on is a leaf-list, and I am trying to use this expression in tailf:default-ref if that is important in any way.

1 Accepted Solution

Accepted Solutions

vleijon
Cisco Employee
Cisco Employee
You can use them in templates, when and must expressions. Leafrefs are a limited type of xpath, if you look in RFC7950 path-arg, the RFC puts it like this:


The syntax for a path argument is a subset of the XPath abbreviated

syntax. Predicates are used only for constraining the values for the

key nodes for list entries. Each predicate consists of exactly one

equality test per key, and multiple adjacent predicates MAY be

present if a list has multiple keys. The syntax is formally defined

by the rule "path-arg" in Section 14<>.

View solution in original post

2 Replies 2

vleijon
Cisco Employee
Cisco Employee
You can use them in templates, when and must expressions. Leafrefs are a limited type of xpath, if you look in RFC7950 path-arg, the RFC puts it like this:


The syntax for a path argument is a subset of the XPath abbreviated

syntax. Predicates are used only for constraining the values for the

key nodes for list entries. Each predicate consists of exactly one

equality test per key, and multiple adjacent predicates MAY be

present if a list has multiple keys. The syntax is formally defined

by the rule "path-arg" in Section 14<>.

I see. Bummer. Thanks for clarifying!