data.zip: add clojure.zip/xml-zip; clojure.xml lives in jolt-lang/xml

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.
This commit is contained in:
Yogthos 2026-06-27 14:49:49 -04:00
parent a83ff6ce40
commit 745d22260f
2 changed files with 13 additions and 0 deletions

View file

@ -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 * [core.contracts](https://github.com/clojure/core.contracts) — programming by
contract (`contract`/`with-constraints`/`provide`), over contract (`contract`/`with-constraints`/`provide`), over
[core.unify](https://github.com/clojure/core.unify). [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`; * [tick](https://github.com/juxt/tick) — date/time over Jolt's `java.time`;
`#time/…` literals via `time-literals`. `#time/…` literals via `time-literals`.
* [transit-jolt](https://github.com/jolt-lang/transit-jolt) — Transit (JSON) read/write * [transit-jolt](https://github.com/jolt-lang/transit-jolt) — Transit (JSON) read/write

View file

@ -28,6 +28,16 @@
[root] [root]
(zipper vector? seq (fn [node children] (with-meta (vec children) (meta node))) 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 node "Returns the node at loc" [loc] (nth loc 0))
(defn branch? "Returns true if the node at loc is a branch" (defn branch? "Returns true if the node at loc is a branch"