Hi,

Your example is not circular, and it is legal.  However, the 'when'
expression refers to the node in which the when expression is defined.
Note that this expression will always evaluates to 'false' (see the
third bullet in 7.21.5 in RFC 7950).

Take a step back and consider what the 'when' statement means - it is
used to indicate if the node can be present or not.  As such, it
doesn't make any sense to refer to the node itself in the xpath
expression.

In your case, you probably want to use a 'must' expression.  This is
evaluated once the node is present, in order to enforce some
constraint.


/martin


Vladimir Vassilev <vladi...@transpacket.com> wrote:
> Hi,
> 
> Is there any practical value of 'when' statements with circular
> dependency to the value of the parent (in case it is a leaf) or any
> children of the parent?
> 
>   container circular-dependency-when {
>       leaf a {
>           when "(. + ../b) = 100";
>           type uint16 {
>               range "0 .. 100";
>           }
>       }
>       leaf b {
>           type uint16 {
>               range "0 .. 100";
>           }
>       }
>   }
> 
> I notice none of the tools known to me complain about this example
> model however some will not allow the user to interactively configure
> 'a' (even if he intends to use value which would make the 'when'
> statement evaluate as "true").
> 
> Did not find any 'when' statements depending on the value of their
> parent or the value of children of that parent in the standard and
> draft models known to me but this is valid YANG according to the YANG
> RFC text.
> 
> I believe if there is consensus this indeed qualifies as circular
> dependency and it has no value to allow such cases it can at least
> give a signal to model designers they should avoid using such 'when'
> statements until this is explicitly noted in a follow up YANG version.
> 
> Vladimir
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod
> 

_______________________________________________
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to