[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:
Issue split
split from YANGTOOLS-1543 XmlStringInstanceIdentifierCodec is u... Resolved

 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.


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