A developer models a new campus VLAN with YANG using leaf vlan-id and container vlans from Cisco-IOS-XE-native. The generated NETCONF XML was rejected for wrong hierarchy and missing namespace, though leaf names look right. The script must produce valid device config. Which mapping from YANG model to XML instance with namespaces should the script generate to configure the VLAN correctly?
Select an answer to reveal the explanation.
Short Explanation
Think of YANG as the recipe for the XML hierarchy, and you’re on the right track when the nested elements follow that structure. Namespaces identify which model your tags belong to, so declaring the Cisco module namespace on the top element can qualify the nested elements too.
Full Explanation
The correct mapping follows the YANG schema’s containment: the VLAN leaves must appear inside the containers defined by Cisco-IOS-XE-native, and the data elements must use that module’s namespace. Declaring the namespace on the top element is a conventional way to apply it to nested elements, giving the XML the expected hierarchy and qualified names. Using the correct container tree but assigning every data element the NETCONF base namespace fails because that namespace identifies NETCONF protocol elements such as <config>, not Cisco model data; the device cannot match those elements to the YANG nodes. Keeping the containers and module namespace but encoding vlan-id as an XML attribute also fails: YANG XML encoding represents a leaf as an element with its value as text, not as an attribute. Using the Cisco module namespace and leaf elements but placing the VLAN under interfaces gives the wrong schema path; the VLAN belongs under the model’s VLAN container. Exam caveat: a NETCONF <config> wrapper may legitimately use the NETCONF base namespace while the enclosed configuration subtree uses the Cisco module namespace; do not confuse the wrapper’s namespace with the data model’s. Practical check: validate the generated XML against the device’s advertised YANG schema, checking each element’s expanded name (namespace URI plus local name) and its parent path.