300-435 Question 48
Single answerYou are tasked with creating an XML instance document for a network configuration based on a YANG model. The YANG model defines the following structure:
module example-config {
namespace "http://example.com/config";
prefix ex;
container device {
leaf hostname {
type string;
}
leaf ip-address {
type inet:ipv4-address;
}
}
}
Which of the following XML documents correctly represents this YANG model?
- A
Router1 192.168.1.1 - B
Router1 - C
Router1 192.168.1.1 - D
Router1 192.168.1.1
Show answer and explanation
Correct answer: C
Explanation
The correct XML instance must adhere to the structure defined in the YANG model. The root element should be 'device', the namespace should be declared as 'http://example.com/config', and all mandatory leaves ('hostname' and 'ip-address') must be present. Option 3 satisfies all these requirements.
- A. Incorrect.
This XML document is missing the namespace declaration for the 'example-config' module, which is required based on the YANG model.
- B. Incorrect.
This XML document includes the correct namespace but is missing the 'ip-address' leaf, which is mandatory based on the YANG model.
- C. Correct.
This XML document is correct as it includes the namespace 'http://example.com/config' and both mandatory leaves 'hostname' and 'ip-address', matching the YANG model structure.
- D. Incorrect.
This XML document incorrectly uses a root element 'example-config', which is not defined in the YANG model. The correct root element should be 'device'.