cgrand/enlive

<?xml ... ?> being stripped from XML output

Janiczek opened this issue · 6 comments

Enlive version [enlive "1.1.4"] strips out the <?xml ... ?> declaration from the output (which it probably shouldn't).

  • test.rss
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"></rss>
  • test.clj
(defn render [nodes]
  (apply str nodes))

(deftemplate test (xml-resource "test.rss") [])

(defroutes routes
  (GET "/test" [] (render (test))))
  • output (GET /test)
<rss version="2.0"></rss>

I can still confirm this, has there been any workaround?

It's jackson, again. You can check out: #43

Hi Jackson,
Thanks for pointing me to that issue, I think I understand what the fix was but I can't for the life of me understand what the syntax for DTD node would be in Enlive? Or is this something else?

Also is it still a bug if this happens when using XML templates directly (as in they have the doctype declaration at the top, but it still get stripped out rather then left alone)

Thanks again!

:D i actually meant Jackson - the XML parser library :) but after checking I understood that I was stupid and it's called jsoup.

It happens with DTDs, schema definition or any top head that doesn't have closing tag. JSoup is HTML parser, not XML. So you may expect all kinds of fuzziness because of that.. you could try tagsoup backend or anything else (there should be other things available on the internets)

Hah! Thought you meant you were the original issue author on a different account, but realize now that his name isn't Jackson ether.

Thanks for this, I don't quite know how to add a different parser, but Ill run through the docs again. Is this issue also the fault of JSoup: #111

As a note I tried pluggable parsers for my xml tests earlier:

(deftemplate feed {:parser xml-parser} (xml-resource "templates/feed.xml")
  [posts kind path]
  [:feed :link] (content path)
  ;[:feed :updated] (content (-> posts first :date))
  [:feed :author :name] (content "Boris Kourtoukov")
  [:feed :id] (content "urn:first-rest:feed")
  [:feed] (append (map feed-entry posts)))

But I got similar output as #111