This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-29
Channels
- # announcements (7)
- # asami (13)
- # babashka (22)
- # beginners (52)
- # calva (95)
- # clj-kondo (14)
- # cljs-dev (7)
- # clojars (5)
- # clojure (94)
- # clojure-austin (5)
- # clojure-dev (15)
- # clojure-europe (25)
- # clojure-nl (18)
- # clojure-uk (15)
- # clojuredesign-podcast (28)
- # clojurescript (63)
- # copenhagen-clojurians (1)
- # cursive (3)
- # datalevin (7)
- # datascript (13)
- # datomic (13)
- # duct (14)
- # emacs (24)
- # events (1)
- # fulcro (13)
- # graphql (7)
- # kaocha (4)
- # lambdaisland (6)
- # lsp (22)
- # music (5)
- # off-topic (24)
- # rdf (1)
- # re-frame (3)
- # reitit (9)
- # shadow-cljs (23)
- # sql (15)
- # testing (4)
- # tools-build (6)
- # vim (7)
- # vscode (7)
- # xtdb (21)
Can anyone tell me why I cannot use clojure.data.xml/parse to parse xml (works) and then convert it back to string with clojure.data.xml/emit-str? I get the following error:
(let [input (
parsed (clojure.data.xml/parse input)
parsed-with-headers {:headers {"Soap" "
:body parsed}
back-to-string (clojure.data.xml/emit-str parsed-with-headers)]
(clojure.pprint/pprint back-to-string))
; Execution error (IllegalArgumentException) at clojure.data.xml/fn$G (xml.clj:73).
; No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: clojure.lang.PersistentArrayMap
The parsed-with-headers
format is not as the emit-str
expects. See the examples on https://github.com/clojure/data.xml/.
> XML elements can be created using the typical defrecord constructor functions or the element function used below or just a plain map with :tag :attrs :content keys ...
to use the sexp-as-element I need to parse every tag to output it again am i right? I just want to add a tag with subtags to an existing xml without having to parse and rebuild the entire xml
Hmm I can see that an xml can be 'roundtripped' by creating one and then reading it back. I cannot find how to write back a read xml file.
I have tried this too:
(let [input (
parsed (clojure.data.xml/parse input)]
(with-open [out-file (
(emit parsed out-file)))
But that gives me the following error:
Prefix cannot be null
And I tried to solve that by adding the parsed-with-headers:
(let [input (
parsed (clojure.data.xml/parse input)
parsed-with-headers {:headers {"Soap" "
:body parsed}]
(with-open [out-file (
(emit parsed-with-headers out-file)))
That gives me this error:
No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: clojure.lang.PersistentArrayMap
Which comes back to the initial question.
The parsed xml starts like this:
#clojure.data.xml.Element
{:attrs #:xsi{:schemaLocation
"
:content
(#clojure.data.xml.Element
{:attrs {},
:content
(#clojure.data.xml.Element
{:attrs {}, :content ("573"), :tag :Berichtcode}
#clojure.data.xml.Element