Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (clojure.data.xml/emit-str (element :e {:attr "x"} (element :e1) (element :e2)))
- ; Generates:
- ; "<?xml version=\"1.0\" encoding=\"UTF-8\"?><e attr=\"x\"><e1></e1><e2></e2></t>"
- ; However, I need to generate elements from a data str, so I've something like:
- (clojure.data.xml/emit-str (element :e
- {:attr "x"}
- (for [e '[:e1 :e2]]
- (element e))))
- ; which results in...
- ; IllegalArgumentException No implementation of method: :emit-element of protocol:
- ; #'clojure.data.xml/Emit found for class: clojure.lang.LazySeq clojure.core/-cache-
- ; protocol-fn (core_deftype.clj:527)
- ;
- ; I.e., (element) doesn't destructure the result of the (for)
- ; I can see this if I use clojure.data.xml/emit instead of emit-str:
- (pprint (element :e
- {:attr "x"}
- (for [e '[:e1 :e2]]
- (element e))))
- ; This outputs:
- {:tag :e,
- :attrs {:attr "x"},
- :content
- (({:tag :e1, :attrs {}, :content ()}
- {:tag :e2, :attrs {}, :content ()}))}
- ; which has the :e1 and :e2 elements in a superfluous seq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement