From 745d22260fe0b8e5d2cd18ac811a06a1f57dd86b Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 27 Jun 2026 14:49:49 -0400 Subject: [PATCH] data.zip: add clojure.zip/xml-zip; clojure.xml lives in jolt-lang/xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clojure.zip was missing xml-zip — a zipper over xml {:tag :content} elements, which clojure.data.zip and any xml-zipper code needs. Added (runtime, loaded on require). clojure.data.zip's whole xml suite (9/9) then passes, once XML parsing is provided: clojure.xml/parse now ships in jolt-lang/xml over its javax.xml.stream pull parser (committed there). Listed in docs/libraries.md + the site. --- docs/libraries.md | 3 +++ stdlib/clojure/zip.clj | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/libraries.md b/docs/libraries.md index 4065e65..c186820 100644 --- a/docs/libraries.md +++ b/docs/libraries.md @@ -57,6 +57,9 @@ e.g. the [ring-app example](https://github.com/jolt-lang/examples/tree/main/ring * [core.contracts](https://github.com/clojure/core.contracts) — programming by contract (`contract`/`with-constraints`/`provide`), over [core.unify](https://github.com/clojure/core.unify). +* [data.zip](https://github.com/clojure/data.zip) — zipper navigation, including + `clojure.data.zip.xml`; XML parsing via [jolt-lang/xml](https://github.com/jolt-lang/xml) + (which now ships `clojure.xml/parse`). * [tick](https://github.com/juxt/tick) — date/time over Jolt's `java.time`; `#time/…` literals via `time-literals`. * [transit-jolt](https://github.com/jolt-lang/transit-jolt) — Transit (JSON) read/write diff --git a/stdlib/clojure/zip.clj b/stdlib/clojure/zip.clj index a375742..af3e502 100644 --- a/stdlib/clojure/zip.clj +++ b/stdlib/clojure/zip.clj @@ -28,6 +28,16 @@ [root] (zipper vector? seq (fn [node children] (with-meta (vec children) (meta node))) root)) +(defn xml-zip + "Returns a zipper for xml elements (as from clojure.xml/parse), given a root + element" + [root] + (zipper (complement string?) + (comp seq :content) + (fn [node children] + (assoc node :content (and children (apply vector children)))) + root)) + (defn node "Returns the node at loc" [loc] (nth loc 0)) (defn branch? "Returns true if the node at loc is a branch"