Subject: [netmod] Query about invalid XPATH paths in YANG

From: William Ivory <[email-masked]>
Date: Mon, 23 Jan 2017 17:18:31 +0000

Hi,

I'd appreciate clarification on whether a YANG path in an XPATH statement in a must or when statement must point to a valid YANG path or not.  You might wonder why we'd have an invalid path (as opposed to one that's simply not configured right now) but it is occasionally helpful when sharing groupings.  (Possibly we should remodel the YANG but that's another matter!).

As a simple example, is the following allowed?

Container foo {
        Leaf bar {
                Type string;
                Must "not(../nonExistentSiblingNode)";
        }
}

I don't see that this should be any different to a must statement path pointing to an unconfigured node, returning an empty nodeset in both cases.

The reason I ask is that we are seeing a NETCONF client differentiating between unconfigured (ok) and non-existent (error) cases.  It would be useful to know one way or the other, ideally with a pointer to the relevant part of the spec that makes this clear.

Thanks,

William

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 23 Jan 2017 19:17:27 +0100 (CET)

William Ivory <[email-masked]> wrote:
> Hi,
> 
> I'd appreciate clarification on whether a YANG path in an XPATH
> statement in a must or when statement must point to a valid YANG path
> or not.  You might wonder why we'd have an invalid path (as opposed to
> one that's simply not configured right now) but it is occasionally
> helpful when sharing groupings.  (Possibly we should remodel the YANG
> but that's another matter!).
> 

Yes this is allowed.  Many YANG compilers give warnings for this kind
of expression, but it is legal.

> I don't see that this should be any different to a must statement path
> pointing to an unconfigured node, returning an empty nodeset in both
> cases.
> 
> The reason I ask is that we are seeing a NETCONF client
> differentiating between unconfigured (ok) and non-existent (error)
> cases.  It would be useful to know one way or the other, ideally with
> a pointer to the relevant part of the spec that makes this clear.

It follows from how XPath works, and the fact that there is no text in
RFC 7950 (or 6020) that limits XPath to something non-standard.

/martin

---

From: William Ivory <[email-masked]>
Date: Mon, 23 Jan 2017 18:34:01 +0000

Hi Martin,

Thanks for the confirmation.

Regards,

William

-----Original Message-----
From: Martin Bjorklund [mailto:[email-masked]] 
Sent: 23 January 2017 18:17
To: William Ivory <[email-masked]>
Cc: [email-masked]
Subject: Re: [netmod] Query about invalid XPATH paths in YANG

>                 Must "not(../nonExistentSiblingNode)";

Yes this is allowed.  Many YANG compilers give warnings for this kind of expression, but it is legal.

> a pointer to the relevant part of the spec that makes this clear.

It follows from how XPath works, and the fact that there is no text in RFC 7950 (or 6020) that limits XPath to something non-standard.

/martin