1.6. YANG 1.1 Translation
It should be possible to use modules that contain YANG++ statements with tools that only understand YANG 1.1 modules, by converting the module to YANG 1.1 first.
The intermediate or final expansion of YANG++ language constructs can be converted to an equivalent set of YANG 1.1 modules. Constructs that do not exist in YANG 1.1 can be omitted or converted to YANG extensions.
Direct Translation Approach
The direct translation focuses entirely on the final schema tree.
Each uses-class-stmt must be replaced with the equivalent YANG 1.1 statements
statements not supported by YANG 1.1 must be omitted or converted to extensions somehow
All class-stmt definitions can be removed from the translation.
Grouping Translation Approach
For the 'object' base class, a class can be easily converted to a grouping, and a 'uses-class' statement can be converted to a 'uses' statement.
Each class-stmt definition is converted to a grouping
Each uses-class-stmt is replaced with a 'uses' statement for the grouping that was converted from a class.
It may not be possible to converted derived classes into a hierarchy of groupings. Instead, all inherited concrete statements are also included in the grouping.
XPath Conversion
Proper XPath conversion from Class Path strings to plain XPath may only be possible using the direct translation approach. The complete XPath cannot be constructed until the final 'uses' expansion point is known.
1.6.1. Converting Base Class Types
Each base type can be converted to some sort of YANG 1.1 construct
class type |
YANG 1.1 construct |
---|---|
'anydata' or 'container' with description-stmt declaring purpose |
|
'data-def' statement |
|
'sx:structure' statement with description-stmt declaring purpose |
|
'sx:structure' statement |
1.6.2. Converting Object Class Types
A class root is converted to a container or list. Unlike a grouping, a class has a root node that becomes a real schema node, exactly as done for YANG Schema Mount RFC 8528.
Example: Convert Class to a P-container:
Example class:
class address {
presence "P-container";
uses address-fields;
}
Example grouping:
grouping address {
container address {
presence "P-container";
uses address-fields;
}
}
Example: Convert Class to a List:
Example class:
class address {
key "last-name first-name";
uses address-fields;
}
Example grouping:
grouping address {
list address {
key "last-name first-name";
uses address-fields;
}
}
Example: Convert a Derived Class to a Grouping:
Example class:
class std-parms {
leaf std-leaf ( type string; }
}
class my-parms {
parent-class std-parms;
leaf my-extra-leaf { type string; }
}
Example grouping:
grouping my-parms {
container my-parms {
leaf std-leaf ( type string; }
leaf my-extra-leaf { type string; }
}
}
TBD: complete definitions and more examples