YANG container statement: grouping related leaf nodes

300-435 By islever Editorial Last updated

Short answer

A Use the container statement when the goal is to group related leaf nodes under one named branch, not to create a keyed list, define a scalar leaf, or name a list key.

Question

What is a YANG module container statement used for?
  1. Groups related leaf nodes Correct Answer
  2. Defines a list of entries
  3. Defines a leaf value
  4. Defines a key

Key Takeaways

A YANG container creates a named hierarchy node that gathers related leaf and container children without giving the branch a value or key. For 300-435, option A is correct because grouping related leaf nodes is precisely the container's role, while list creates keyed repeated entries, leaf defines a scalar value, and key identifies list instances.

Expert Analysis

A YANG container is the right construct when the requirement is to gather related leaf nodes under one named branch, which is why option A holds and the list, leaf, and key alternatives do not.

Enumerating what list, leaf, and key would break in a module built for grouping

Choosing B would substitute repeated entries for the hierarchical branch being described: list creates a collection whose instances are addressed by keys, so it introduces multiplicity and key semantics that a plain grouping container does not carry. C would collapse the branch into a single scalar: leaf defines one value with a type, and while a leaf can sit inside a container, it cannot itself hold child leaf nodes. D would attach identity to an entry that does not exist yet: key is a substatement of list, naming the leaf or leaves that distinguish list entries, so using it as the answer confuses a list's identifier with the construct that organizes sibling nodes. None of those three statements provides the parent-child hierarchy that lets a module say these fields belong together; they either repeat, terminate, or identify. The container’s defining contribution is structural organization—a named node that can hold multiple child leaves and even nested containers—so the options that replace grouping with replication, scalar value, or entry identity all miss the requested role.

The named branch that holds sibling leaves is the decisive signal for container

The decisive condition is the stated purpose of grouping related leaf nodes under one named branch, because that is the schema role RFC 7950 assigns to container: it creates an interior node with no value of its own and lets child leaf, container, list, leaf-list, choice, and other data nodes share a common parent. The wording “groups related leaf nodes” therefore points away from any statement that creates an instance, a scalar, or an identifier. A container is not repeated unless it is placed inside a list, it is not addressed by a key, and it does not carry a type; those absences are precisely what let it act as a grouping point. The correct option is the one that describes organization rather than value or identity, and A does exactly that. The hierarchical parent-child relationship is the mechanism: the container supplies the parent, the related leaves become its children, and the resulting path is what NETCONF, RESTCONF, and YANG tree output expose. An interface container holding a description leaf and an enabled leaf produces a path that scopes both fields under the same parent. The container can be nested, but nesting does not give it a value or a key; it only deepens the hierarchy.

When repeated entries with distinguishing keys would make list the answer

B becomes the right choice under a different requirement: if the module must represent zero or more instances of the same structure and distinguish them by a key leaf, then a list statement is the correct construct. That condition is not met by the stated purpose of grouping related leaf nodes, because grouping says nothing about cardinality, instance selection, or uniqueness. A container can legally contain a list, but the container itself remains singular; it does not create repeated entries and cannot carry a key substatement. Confusing the two usually comes from seeing that both can hold leaves and assuming the broader word “groups” implies multiplicity. The missing evidence would be wording such as “defines multiple entries,” “uses a key to identify each entry,” or “supports repeated instances,” none of which appears. D would become attractive only if the requirement were to name the field that uniquely identifies entries inside a list; key is a list substatement, not a top-level grouping statement, so it cannot answer a requirement whose focus is the parent branch that organizes related leaves. The singular grouping role is what keeps A ahead.

A statement-role test for separating container, list, leaf, and key substatements

Carry a simple role test into any YANG schema decision: decide first whether the requested construct organizes children, repeats instances, carries a value, or identifies an instance. container is an interior schema node with no value and no key; it may be a presence container that exists only when explicitly created, or a non-presence container that exists when a child exists, but in either form it is a named grouping point. list is the repeated node and uses key when it needs unique entry identification; leaf is the scalar value node; leaf-list is a repeated scalar of one type. Also check nesting: key is only meaningful as a substatement under list, so an option that treats key as a standalone organizer is structurally wrong. Worked example: a container named interface can hold a description leaf, an enabled leaf, and an address list; the parent is a container, the repeated address entries are a list, and the distinguishing field inside that list would be its key. Apply that same taxonomy whenever the stem’s verb is “groups,” “repeats,” “holds one value,” or “uniquely identifies.” That distinction is the fastest way to eliminate options that sound plausible but describe a different schema node.

Official Reference

Exam Strategy

For YANG statement questions, isolate the verb in the stem before looking at the options: “groups” points to a container, “repeats” or “multiple instances” points to a list, “single value” points to a leaf, and “uniquely identifies entries” points to a key substatement. Then check whether the option is a data node or a substatement, because key belongs under list and cannot stand alone. This verb-to-statement mapping quickly eliminates distractors.

Practice All 300-435 Questions

Access 150 questions with complete answers and detailed explanations.

View Full 300-435 Practice Test →

← Back to 300-435 Study Guide