DFDL schemas are XML schemas and so DFDL inherits the namespace system of XML and XML Schema for composing large schemas from smaller ones, for reusing schema files, and for managing name conflicts.
A DFDL Infoset isn’t necessarily represented as XML however.
Some representations won’t have any ability to deal with namespaces (JSON for example), and so Daffodil will sometimes issue warnings when compiling a schema if the namespace usage will not allow unambiguous representation without namespaces.
Most representations of DFDL Infosets will, like XML, use some representation of the namespaces of elements, and in textual forms this will most commonly be by way of namespace prefixes.
XML is not the only representation that uses namespaces, however, so this should not be taken as an entirely XML-specific discussion.
There are these goals for namespace-binding minimization.
-
Clarity: Infosets that have redundant namespace bindings are very hard to read and understand, and require namespace-binding-aware tooling to compare them, or clumsy post-processing to remove the excess bindings.
-
Performance: Attaching an element to the infoset at runtime should take constant time.
-
Consistency: The prefix-to-namespace bindings used should be drawn from those expressed on the DFDL schema by the schema author, and the prefixes used and bindings introduced when an element is attached to the infoset should be consistent with the set of namespace prefix definitions in place at the point where the element’s declaration lexically appears in the DFDL schema.
These goals are in some tension.
Consider 4 elements named A, B, C, and Q.
Suppose element A contains element B, which contains element Q.
Suppose elsewhere in the same infoset element A contains element C which contains element Q.
From the perspective of element Q, the set of namespace bindings surrounding it are those from (A, B) or those from (A, C).
Suppose element Q requires, and introduces, a namespace with prefix "qns" bound to namespace "urn:Q_Namespace".
Suppose element C also introduces this same namespace binding.
Then when element Q appears inside element B, its namespace binding for "qns" is needed.
But when element Q appears inside element C, its namespace binding for "qns" is redundant with one already provided by element C.
The conclusion is that the minmal set of namespace bindings introduced by an element depends on the nesting of elements.
The basic technique is to store, on the runtime element data structure (DPathElementCompileInfo), the complete set of lexical namespace bindings present for the element declaration in the DFDL schema document.