Created
September 18, 2013 20:32
-
-
Save laurentpetit/6615228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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