On Sun, Nov 30, 2008 at 5:12 PM, Joel L <[EMAIL PROTECTED]> wrote:
>
> I've hit a wall trying to work with tree like data structures,
> specifically the xml-seq. I want to translate clojure.xml's xml
> representation into something close to compojure's html data
> structure.
>
> eg:
> {:tag :div :attrs {:class "foo"}
> :content
> [{:tag :h1 :attrs nil :content ["Title"]}
> {:tag :p :attrs nil :content ["Test"]}]}
>
> ->
>
> [:div {:class "foo"} [:h1 "Title"] [:p "Test"]]
This has not been deeply tested:
(defn f [{:keys [tag attrs content] :as other}]
(if tag
(vec (concat [tag]
(when attrs [attrs])
(when-let [s (map f content)] (vec s))))
other))
--Chouser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---