[YANGTOOLS-961] Integrate NormalizedNodes with RFC7952 metadata/attributes Created: 28/Feb/19  Updated: 04/Apr/19  Resolved: 04/Apr/19

Status: Resolved
Project: yangtools
Component/s: data-impl
Affects Version/s: None
Fix Version/s: 3.0.0

Type: Task Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
blocks YANGTOOLS-960 Update NormalizedNodeStreamWriter int... Resolved
blocks MDSAL-357 RFC7952 metadata should be transporte... Confirmed
Relates
relates to YANGTOOLS-369 Data Tree: improve DataContainerNode ... Resolved

 Description   

Current integration of NormalizedNodes and XML attributes is tacky in multiple ways:

  • ImmutableNormalizedNodeStreamWriter completely ignores attributes
  • attribute streaming is bolted on as a separate NormalizedNodeStreamWriter interface
  • attributes are Map<QName,String> pairs, which means they are not normalized
  • the integration completely ignores RFC7952 guidance
  • attributes do not contribute to hashCode/equals

The only user of attributes is NETCONF, which uses yang.data.api.ModifyAction, a manifestation of RFC6241 Section 7.2 – which should be easy to update.

 



 Comments   
Comment by Robert Varga [ 28/Feb/19 ]

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).

Generated at Wed Feb 07 20:54:48 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.