Now I want to augment it in the second module as follows:
module b
{
namespace "my:namespace";
prefix a;
import b {
prefix b;
}
augment "/b:mygrouping/b:firstcontainer/b:modules"{
leaf thirdmodule;
}
}
This does not work, apparently because a grouping cannot be augmented. But there must be a way, since what I really want to extend is the list, not the grouping itself.
Is there another way to have the intended result using another way ?
Grouping are a conceptual aggregation of nodes, and they do not exist in the final schema i.e. when you use a uses xyz_grouping clause in schema, the compiler internally copies all the elements of xyz_grouping within it.
If you do not use any uses statement the grouping has no effect on final schema.
Another option is that augment can be a substatement on the uses statement, so rather than have a separate standalone augment statement, you can at the point where you “use” the grouping, also augment it whatever way you want.
If your requirement is to have dynamic enumerations (i.e. be able to add new enumerations), you should replace the enumeration with an identityref type. Refer to: https://tools.ietf.org/html/rfc8407#section-4.11.1 for an example.
Or, if you want to restrict certain values, you can use the ‘if-feature’ statement, or a ‘must’ statement.