Emitting XML element with :xmlns attribute doesn't work as expected


Affects version 0.2.0-alpha2, 0.0.8 doesn't have this problem.

user=> (require '[clojure.data.xml :as xml])
user=> (xml/emit-str {:tag :RDF :attrs {:xmlns "http://www.w3.org/1999/02/22-rdf-syntax-ns"}})
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><RDF></RDF>"


java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)


Herwig Hochleitner
December 26, 2017, 8:47 PM

I was thinking about a replacement mechanism for your use case. Turns out, I was wrong about declining this. See DXML-52 for a rationale.

December 22, 2017, 7:56 AM

Comment made by: brutasse

Thank you. We have to cope with a host of XML consumers in many languages, broken in various ways so it's very important to have complete control over the output.

For now we've reverted to 0.0.8. We'll see if we switch to the ::R/* notation but it's less pleasant to read.

Herwig Hochleitner
December 17, 2017, 6:29 PM

Since any non-broken xml consumer shouldn't care about that difference, data.xml emits prefixes at will.
It does, however, try to keep emitted prefixes to a minimum and you can exploit that behavior to get the serialisation, you want:


December 14, 2017, 1:26 PM

Comment made by: brutasse

With -alpha5, this generates prefixed tags/attrs:

<?xml version="1.0" encoding="UTF-8"?><a:RDF xmlns:a="http://www.w3.org/1999/02/22-rdf-syntax-ns"/>

How would one emit <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns"/> with 0.2?

Herwig Hochleitner
March 27, 2017, 4:01 PM

btw, with current xmlns support, you would write your fragment like:


Herwig Hochleitner


Yegor Timoshenko