Skip to content

Instantly share code, notes, and snippets.

@laurentpetit
Created September 18, 2013 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laurentpetit/6615228 to your computer and use it in GitHub Desktop.
Save laurentpetit/6615228 to your computer and use it in GitHub Desktop.
(defn make-parse-tree-node
[t children-vec]
(let [[combined count] (children-info children-vec)]
{:tag t
:content children-vec
:build-id *build-id*
:count count
:content-cumulative-count combined
:broken? (or (#{::unexpected :chimera} t)
(some #{::unexpected :chimera} (cons t (map :tag children-vec)))
false)
}))
(defn xml-vzip
"Returns a zipper for xml elements (as from xml/parse),
given a root element"
{:added "1.0"}
[root]
(z/zipper (complement string?)
(fn [node] (or (:content node) []))
(fn [node children]
(make-parse-tree-node
(:tag node)
(vec children)))
root))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment