[YANGTOOLS-1544] Enhance XML prefix assignment Created: 29/Sep/23 Updated: 02/Oct/23 Resolved: 02/Oct/23 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | codecs |
| Affects Version/s: | None |
| Fix Version/s: | 9.0.9, 10.0.10, 11.0.3 |
| Type: | Improvement | Priority: | High |
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
When yang-data-codec-xml emits namespace declarations as part of, for example, instance-identifier writeout, we assign linear prefixes ('a', 'b') to any mapping we need to define, in their encounter order (and then write them out in any order). This is correct in XML terms, as parser are required to look at the NamespaceContext. Unfortunately this requires some cognitive load on people interacting with these XMLs and we can do better. RFCs since RFC6020 use YANG module stament's prefix statement argument as the XML prefix. This is not always desirable in the context of the XML document, where there are externally-defined mappings (which we want to reuse to reduce clutter). This is not even always possible, as an EffectiveModelContext is valid even when two distinct modules have the same prefix. Enhance RandomPrefix to prefer assignment of YANG-defined XML prefixes where possible, falling back to the current way of assignment. |