|
RFC7952 defines metadata annotations as a separate entity which semantically attaches to some data in a way which is compatible with XML attributes. Annotations are defined to not affect the data itself, but provide additional information (such as originating store in ietf-origin.yang) and can potentially be unrelated to the data itself (example-last-modified).
When we consider how this would play out in case of DataTree interactions, it is obvious that attributes are not part of NormalizedNode structure, but rather are a separate metadata tree whose layout mirrors NormalizedNodes. This means that a DataTree instance would maintain it separately, perhaps exposing an interface which would allow querying the metadata and data tree in unison or separately.
We therefore need to decouple yang.data.api.AttributesContainer from NormalizedNode implementations and reshape it in terms of a TreeNode structure – MetadataTree (or somesuch). This has the benefit of allowing the lifecycle to be disconnected, and thus the same NormalizedNode structure being attached to different MetadataTree.
In terms of NormalizedNodeStreamWriter and its events, though, the two trees should be fused, so that metadata in concert with data – i.e. event sources would walk both trees at the same time, emitting metadata content before emitting data content (to match XML semantics) and receivers would either directly emit it (XML, JSON container), cache-and-emit (JSON leaf), place it it a separate structure (ImmutableNormalizedNodeStreamWriter with metadata) or discard it (ImmutableNormalizedNodeStreamWriter with plain NormalizedNode result).
|