Use YANG-derived prefixes
All XML examples starting from RFC6020 onwards use a module's prefix to
identify the module.
This is not something that is universally feasible to do, as the
document context may indicate a different namespace mapping, which may
be more efficient to use.
Such assignments may also conflict with already-assigned prefixes and
redefining XML namespaces increases cognitive load in analysis -- hence
we have to avoid that.
Also prefix assignments are not a global namespace, so we could easily
end up with ambigous mappings. This is unlikely, but it can easily
happen.
With an EffectiveModelContext we can perform analysis on what is valid
within that enclosed world and use that as a guide. When
NamespacePrefixes decides current RandomPrefix (which is not random at
all!) does not have a mapping, we can consult an analysis object to give
us guidance.
This patch renames RandomPrefix to 'NamespacePrefixes' and introduces
PreferredPrefixes, which can be computed from an EffectiveModelContext.
These two then act in unison to assign prefixes based on prefix
statements present in modules forming an EffectiveModelContext whenever
we need to do such a thing.
JIRA: YANGTOOLS-1544
Change-Id: Iafc5806f53d8927e46f059287e2ae3ed2c77ff26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
16 files changed: