Thx Martin. Pls see below.
Jason
> -----Original Message-----
> From: Martin Bjorklund [mailto:[email protected]]
> Sent: Wednesday, March 28, 2018 2:26 AM
> To: Sterne, Jason (Nokia - CA/Ottawa) <[email protected]>
> Cc: [email protected]
> Subject: Re: [netmod] YANG 'must' Xpaths, predicates and wildcards
>
> Hi,
>
> "Sterne, Jason (Nokia - CA/Ottawa)" <[email protected]> wrote:
> > Hi all,
> >
> > I'm pretty sure that this xpath (e.g. in a must statement) isn't
> > correct:
> >
> > (A) ../container-a/list-b[name=*]/some-leaf
> >
> > and should just be this instead:
> >
> > (B) ../container-a/list-b/some-leaf
>
> Assuming all list entries has a 'name', yes, it is the same.
>
> > Or is the * an allowable wildcard for a key value in a predicate ?
>
> "*" is syntactically legal,
[>>JTS: ] That surprises me. I've seen the use of * described in XPath docs but
it always seems to be in cases outside any predicates. I couldn't find
somewhere that shows * as a wildcard in a predicate (or examples of them).
[>>JTS: ] Does this [xyz=*] work for all types of keys (strings, integers, etc)
? (i.e. will match on all entries in the list)
but is not a wildcard on all values of the
> node; it is a wildcard for all nodes.
>
> So if all list entries has a name, A will evaluate to the same nodeset
> as B, since "name = *" is a node-set comparison, and the node "name"
> will be present in the node set from "*" (node set comparisons are not
> always intuitive; read the spec for all details ;-)
[>>JTS: ] I'll try to dig through the specs but this subtlety (wildcard for all
nodes, vs wildcard for all values) is beyond me at the moment.
[>>JTS: ] You mention "if all list entries has a name". I assume you mean that
all list-b entries have a name. I wasn't clear enough above but in my example,
'name' is the key for list-b. So all entries have a name (ignoring config
false lists that can have no keys for the moment).
>
> > I also had a question about whether the following "must" correctly
> > checks that at least one entry exists in a-list.
> >
> > container c1 {
> > leaf foo {
> > must "a-list";
> > type uint16;
> > }
> > list a-list {
> > key "entry";
> > leaf entry {
> > type uint16;
> > }
> > leaf another-entry {
> > type uint32;
> > }
> > }
> > }
> >
> > I think I could also replace that must with the following:
> > must "count(a-list) > 1";
> > but does must "a-list"; achieve the same thing ?
>
> Yes, but if the list is big, the simple "a-list" may be more
> efficient, since "count()" will actually count all instances
> (modulo existance of optimizations in the evaluator).
>
>
> /martin
_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod