Created
February 28, 2014 22:09
-
-
Save ndrew/9281054 to your computer and use it in GitHub Desktop.
simple diff tool for comparing two demandware system-objecttype-extension xml
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
(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