To be able to work with YANG data instances, libyang has to represent YANG data models. All the processed modules are stored in libyang context and loaded using parser functions. It means, that there is no way to create/change YANG module programmatically. However, all the YANG model definitions are available and can be examined through the C structures. All the context's modules together form YANG Schema for the data being instantiated.
Any YANG module is represented as lys_module. In fact, the module is represented in two different formats. As lys_module.parsed, there is a parsed schema reflecting the source YANG module. It is exactly what is read from the input. This format is good for converting from one format to another (YANG to YIN and vice versa), but it is not very useful for validating/manipulating YANG data. Therefore, there is lys_module.compiled storing the compiled YANG module. It is based on the parsed module, but all the references are resolved. It means that, for example, there are no grouping
s or typedef
s since they are supposed to be placed instead of uses
or type
references. This split also means, that the YANG module is fully validated after compilation of the parsed representation of the module. YANG submodules are available only in the parsed representation. When a submodule is compiled, it is fully