Open lllyfeng opened 5 years ago
Strongly opposed to this change. Too much complexity. The defaults are OK to reference in other XPath. Multiple XPaths can be true. Competing conditional XPaths could cause interactions between leafs.
Dynamic defaults exist in implementations. That is a datastore metadata issue.
Close: complexity: high, bc: low, importance: low
if a leaf node can not be defined a static default value, but it has a uncertain default value when it is created. For example: list foo { key name; leaf name {...} leaf type { type enumeration { enum foo1 {...} enum foo2 {...} enum foo3 {...} } } leaf value {...} leaf other {...} }
default value of leaf named 'value' is 10, if leaf named 'type''s value is foo2, the default value of leaf named 'value' is 20. Now YANG has no mechansim to resolve this issue. So we have to do not define default value for this leaf node, although this leaf node really has defalut value in running. It will cause some validatation is wrong, e.g. must condition:"other > value". I suggest the solution listed below:
default statement's argument can be a XPATH expression.
For example: leaf value { default 10 { when "../type = foo1"; } default 20 { when "../type = foo2"; } default "./other*2"{ when "../type = foo3"; } type int32; }