In data.xml, there is currently no feature, equivalent to `xmlns="..."` on an xml tag. A tag in the empty namespace is kept as such.
for a reason: to have perfect round-trippability and value equality for parsed xml
However, mapping the empty namespace to a default namespace is valid for many use cases, including:
processing output from an HTML parser
Even though, notational brevity looks like a use case, that could benefit from the lexical scoping, a macro can provide, there is no clear use case and the reduced possibility of using arbitrary code in an xml fragment would probably make this inconvenient to use.
Processing, on the other hand, needs a dynamically scoped transformation, and lots of use cases for notational brevity can also be implemented with this.
So the use cases for implementing a dynamically scoped transformation are good.
As for API, setting an :xmlns attribute seems desirable for a couple of reasons:
no interference with round-tripping:
the above, striken-through reason doesn't apply, because the parser will never yield fragments with :xmlns attributes included
limited effect on compositionality:
setting an :xmlns attribute would be indistinguishable from applying a transformation, dynamically scoped down to another :xmlns.
negligible API breakage (for -alpha)
The current use case for setting an :xmlns attribute is a shortcut for setting it into metadata. It:
is a subset of the new behavior,
only breaks when trying to embed non-namespaced xml into a fragment with an overridden :xmlns (unlikely)
can be replicated with a function, setting metadata
knowledge transfer from xml syntax
Therefore, the dynamically scoped default-xmlns feature should be exposed via setting :xmlns attributes for the emitter.
https://dev.clojure.org/display/DXML/Namespaced+XML should be updated, to reflect this rationale.
already suggested this, so that will be re-opened as well.