Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in data.xml by

I'm slowly converting some code from using xml/element to xml/sexp-as-element, and I've noticed a discrepancy. xml/element does (almost) no processing of the "content", inserting it directly (unless it's nil). xml/sexp-as-element calls (str) on the "content" if it's not seq of some kind (vector or ISeq) or a keyword. This means that (= (xml/element :foo {} 1) (xml/sexp-as-element [:foo 1])) is false.

There are probably other differences, but this one seems relatively big, as there's no way to use numbers in xml/sexp-as-element without calling extend-protocol yourself.

May I recommend/request adding this extension? It will make xml/sexp-as-element match xml/element for numbers, and make xml/sexp-as-element match hiccup in general.

(extend-protocol clojure.data.xml.protocols/AsElements
  java.lang.Number
  (as-elements [n] [n]))

Please log in or register to answer this question.

...