Subject: [netmod] mandatory-stmt (again)

From: Andy Bierman <[email-masked]>
Date: Fri, 25 Jul 2008 11:14:11 -0700

From 4.2.7:

        choice snack {
            mandatory true;
            case sports-arena {
                leaf pretzel {
                    type empty;
                }
                leaf beer {
                    type empty;
                }
            }
            case late-night {
                leaf chocolate {
                    type enumeration {
                        enum dark;
                        enum milk;
                        enum first-available;
                    }
                }
            }
        }

This 'mandatory' seems to mean that 1 of the 2
cases must be present, but both cases are inline,
and contain only optional leafs.  If a uses-stmt
was present instead, then every mandatory node
within it would need to be undone with refinement
statements.  There is no control at the 'case' level
or the 'choice' level.

Since all the leafs are optional, then it seems like
a completely missing value would be considered valid.
But it's not.

Sec 7.9 says:

    If a choice is marked with "mandatory true", at least one node from
    one of the cases must be present in a valid configuration.

So the choice mandatory-stmt overrides the mandatory-stmt
in the leafs.  Why is this OK for 'choice' but not 'container'?

 From 7.6.4:

    If "mandatory" is "true", the node
    must exist in a valid configuration if its parent node exists.  Since
    containers without a "presence" statement are implicitly created and
    deleted when needed, they are ignored when performing mandatory tests
    for leafs.  A mandatory leaf within such a container is mandatory
    even if the container's data node does not exist.

This text seems to support my notion of how mandatory-stmt is
supposed to work within the data tree.  Note the key phrase,
"if its parent node exists".  So a mandatory leaf does
not ripple upwards in the object tree.  It is enforced
down the tree, whenever a given value node (e.g., name) is
actually created.

Andy

_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod