Skip to content

Commit 63386cf

Browse files
committed
DXML-62: add :xml/... shorthand namespace
1 parent ad559c2 commit 63386cf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/clojure/clojure/data/xml/name.cljc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@
7474
(if-let [ns (namespace kw)]
7575
(if (.startsWith ns "xmlns.")
7676
(decode-uri (subs ns 6))
77-
(if (= "xmlns" ns)
78-
xmlns-uri
77+
(case ns
78+
"xmlns" xmlns-uri
79+
"xml" xml-uri
7980
(throw (ex-info "Keyword ns is not an xmlns. Needs to be in the form :xmlns.<encoded-uri>/<local>"
8081
{:kw kw}))))
8182
"")))

src/test/clojure/clojure/data/xml/test_emit.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@
239239
(is (= (emit-str {:tag :el :attrs {:xmlns/xmlns "http://www.w3.org/2000/xmlns/"}})
240240
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><el/>"))
241241
(is (= (emit-str {:tag :el :attrs {:xmlns/xml "http://www.w3.org/XML/1998/namespace" ::xml/lang "en"}})
242+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><el xml:lang=\"en\"/>"))
243+
(is (= (emit-str {:tag :el :attrs {:xml/lang "en"}})
242244
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><el xml:lang=\"en\"/>")))
243245

244246
(deftest test-empty-elements

0 commit comments

Comments
 (0)