I’m using clojure.data.xml
0.2.0-alpha6 to merge two SVG documents into a new document.
As part of that, I’m creating a few new elements.
I think I’m using the namespace as intended, as per the c.d.xml README; for example:
(alias-uri 'svg "http://www.w3.org/2000/svg")
(element ::svg/svg {}
(element ::svg/g {}
(:content de)))
This is technically working just fine, but when I emit the new document (root elem) to a string
using emit-str
(or indent-str
), the namespace is assigned an alias and that alias is used for
all of the elements in the entire document; for example:
<a:svg xmlns:a="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1748 1740">
<a:g>...
The thing is, in this case, that alias isn’t necessary, as every element in the document is in the
same namespace, so it can be the default namespace. In other words, I’d prefer that the output look
like this:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1748 1740">
<g>...
Or, failing that, I’d like the alias to be svg
rather than a
, like this:
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1748 1740">
<svg:g>...
Does anyone know whether either of those scenarios are simple+easy to achieve with the current
versions of clojure.data.xml
?
I’ve tried explicitly adding the xmlns
attribute to the root elem — this works with 0.0.8 but not with 0.2.0-alpha6; strange things happen.
I’m asking this question because:
- I’m curious
- If this isn’t currently possible with 0.2.0, I’d want to turn this into a feature request.
Thanks!