Skip to content

Instantly share code, notes, and snippets.

@ndrew
Created February 28, 2014 22:09
Show Gist options
  • Save ndrew/9281054 to your computer and use it in GitHub Desktop.
Save ndrew/9281054 to your computer and use it in GitHub Desktop.
simple diff tool for comparing two demandware system-objecttype-extension xml
(ns demandware-so-parser.core
(:require [clojure.xml :as xml]
[clojure.pprint :as debug]
[clojure.data :refer :all]))
(defn collect-type-ids[d cb]
(reduce (fn [a b] (assoc a (:type-id (:attrs b)) (cb b))) {} (:content d)))
(defn collect-custom-attributes[d]
(reduce (fn[a b]
(if (= :custom-attribute-definitions (:tag b))
(do
(reduce (fn[res el]
(conj res (:attribute-id (:attrs el)))) a (:content b)))
a )) #{} (:content d)))
(defn -main [& args]
(let [d1 (xml/parse (java.io.File. "system-objecttype-extensions.xml")) ; first file
d2 (xml/parse (java.io.File. "so_02252014.xml")) ; second
data1 (collect-type-ids d1 collect-custom-attributes)
data2 (collect-type-ids d2 collect-custom-attributes)]
(debug/pprint
(second (diff data1 data2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment