Subject: [netmod] mandatory versus when

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 19 Oct 2015 16:56:37 +0200

Hi,

I can't find any text in 6020bis that deals with the following issue:

leaf foo {
    when "false()";
    mandatory true;
    type empty;
}

Now, sec. 7.6.5 (The leaf's mandatory Statement) says:

   o  Otherwise, the leaf MUST exist if the ancestor node exists in the
      data tree.

So, if we assume the ancestor node exists in the data tree, the leaf MUST exist.

But sec. 8.1 (Constraints on Data) says:

   The following properties are true in all data trees:

   …

   o  There MUST be no nodes tagged with "when" present if the "when"
      condition evaluates to "false" in the data tree.

The "mandatory" and "when" statements contradict each other. How is this resolved?

Lada

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

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 19 Oct 2015 20:01:07 +0200 (CEST)

> The "mandatory" and "when" statements contradict each other. How is

The idea is that a false when works like if-feature - if the when
evaluates to false then the mandatory constraint doesn't apply.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 20 Oct 2015 10:31:17 +0200

> evaluates to false then the mandatory constraint doesn't apply.

I would personally prefer if "mandatory" was harder than "when" because
it is a schema constraint that can be determined upfront (so is
"if-feature"), whereas "when" needs in principle a complete data tree to
perform the evaluation.

But either way, there should be a text that states that false "when"
wins over mandatory, or the other way around. I can't find any in -08,
section 8 doesn't mention "mandatory" at all.

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 20 Oct 2015 10:45:56 +0200 (CEST)

Ladislav Lhotka <[email-masked]> wrote:
> I would personally prefer if "mandatory" was harder than "when"

But then it would never be possible augment mandatory nodes (see that
other thread).

> because

Ok.  It needs to be added for "min-elements" as well:

OLD:

   o  The "min-elements" and "max-elements" constraints are enforced for
      lists and leaf-lists.

NEW:

   o  The "mandatory" constraint is enforced for leafs, unless the node
      or any of its ancestors has a "when" condition or "if-feature"
      expression that evaluates to "false".

   o  The "min-elements" and "max-elements" constraints are enforced for
      lists and leaf-lists, unless the node or any of its ancestors has
      a "when" condition or "if-feature" expression that evaluates to
      "false".

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 20 Oct 2015 11:04:55 +0200

> On 20 Oct 2015, at 10:45, Martin Bjorklund <[email-masked]> wrote:
> 

Yes, that's why I think "when" is indispensable only as a substatement of "augment", and it is also where the context node problem (Y18) doesn't exist at all.

>      a "when" condition or "if-feature" expression that evaluates to

OK. Lada