Subject: [netmod] YANG 1.1 issue: ill-defined XPath context for 'when'

From: Ladislav Lhotka <[email-masked]>
Date: Sun, 23 Mar 2014 17:58:39 +0100

* ill-defined XPath context for 'when'

** Description

The context for XPath expressions appearing in the 'when' statement is not properly defined in [[http://tools.ietf.org/html/rfc6020#section-7.19.5][Sec. 7.19.5]] because the context node needn’t exist in the data tree.

Here is an example:

container foo {
    when "...";
    leaf bar {
        mandatory true;
        ...
    }
}

According to the third bullet in Sec. 7.19.5, the context node for the 'when' expression is the container "foo".

Then, a data tree which doesn't contain <foo> must be always considered invalid because a mandatory leaf is missing. It is not possible to argue that <foo> is missing due to the fact that the 'when' expression evaluates to false because the XPath expression cannot be evaluated at all (the context node <foo> is not present in the instance document).

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Andy Bierman <[email-masked]>
Date: Sun, 23 Mar 2014 10:30:38 -0700

On Sun, Mar 23, 2014 at 9:58 AM, Ladislav Lhotka <[email-masked]> wrote:

> The context for XPath expressions appearing in the 'when' statement is not
> properly defined in [[
> http://tools.ietf.org/html/rfc6020#section-7.19.5][Sec. 7.19.5]] because
> the context node needn't exist in the data tree.
>
> Here is an example:
>
> container foo {
>     when "...";
>     leaf bar {
>         mandatory true;
>         ...
>     }
> }
>
> According to the third bullet in Sec. 7.19.5, the context node for the
> 'when' expression is the container "foo".
>
> Then, a data tree which doesn't contain <foo> must be always considered
> invalid because a mandatory leaf is missing. It is not possible to argue
> that <foo> is missing due to the fact that the 'when' expression evaluates
> to false because the XPath expression cannot be evaluated at all (the
> context node <foo> is not present in the instance document).
>
>

The when-stmt can be inherited in many ways, such as via uses or augment.
It is too useful to prohibit the combination with mandatory, min-elements,
or default.

The solution is already in rfc6087bis. The when-stmt MUST NOT contain
and descendant-or-self node references in any way.  Then it is simply an
implementation detail to process the expression as if the context node did
exist.

Andy

---

From: Ladislav Lhotka <[email-masked]>
Date: Sun, 23 Mar 2014 18:42:11 +0100

On 23 Mar 2014, at 18:30, Andy Bierman <[email-masked]> wrote:

> It is too useful to prohibit the combination with mandatory, min-elements, or default.

I haven’t proposed anything like that, I am just pointing to an issue with the spec that is IMO evident and should be corrected.

> implementation detail to process the expression as if the context node did exist.

No. The ‘when’ expression in my example needn’t reference anything within “foo” and the issue is still relevant.

Lada

---

From: Andy Bierman <[email-masked]>
Date: Sun, 23 Mar 2014 11:15:36 -0700

On Sun, Mar 23, 2014 at 10:42 AM, Ladislav Lhotka <[email-masked]> wrote:

> > The context for XPath expressions appearing in the 'when' statement is
> not properly defined in [[
> I haven't proposed anything like that, I am just pointing to an issue with
> the spec that is IMO evident and should be corrected.
>
> >
> No. The 'when' expression in my example needn't reference anything within
> "foo" and the issue is still relevant.
>
>
Not sure why... in our code this situation is handled just fine.
When processing the parent of container foo, the tool can process the
when-stmt
since it does not refer to anything inside the foo container.  Processing
the expression
as if the context node is the TBD foo node is just an implementation detail.
This is interoperable, since the content of the foo container is not
allowed to
be in the when expression.

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 24 Mar 2014 08:52:55 +0100 (CET)

Hi,

This is, as far as I can tell, a duplication of issue Y18.  Right?

/martin

Ladislav Lhotka <[email-masked]> wrote:
> not properly defined in
> [[http://tools.ietf.org/html/rfc6020#section-7.19.5][Sec. 7.19.5]]
> because the context node needn’t exist in the data tree.
> 
> Here is an example:
> 
> container foo {
>     when "...";
>     leaf bar {
>         mandatory true;
>         ...
>     }
> }
> 
> Then, a data tree which doesn't contain <foo> must be always
> considered invalid because a mandatory leaf is missing. It is not
> possible to argue that <foo> is missing due to the fact that the
> 'when' expression evaluates to false because the XPath expression
> cannot be evaluated at all (the context node <foo> is not present in
> the instance document).
> 
> --
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
>

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 24 Mar 2014 08:54:27 +0100

> This is, as far as I can tell, a duplication of issue Y18.  Right?

Oh yes, I missed that, sorry.

Lada