         :else form))
     class))
 
-(defn new-stuff-2 [class-result]
+(defn add-results-to-dp-xml [xml-data class-result]
   (clojure.walk/postwalk
     (fn [form]
       (cond

                                 ;(xml/element :Class {:Name "Changed Class"})
                                 form)
        :else form))
    raw-xml-2))

(def class-node
  (xml/element :Class {}
               (xml/element :Foo {})
               (xml/element :DanceList {}
                            (xml/element :Dance {})
                            (xml/element :Dance {})
                            (xml/element :Dance {}))
               (xml/element :Bar {})))

(get-dance-count-from-class-node class-node)



(xml/parse (java.io.FileInputStream. "test/tango/examples/real-example-kungsor.xml"))

(def foo (xml/emit-str (new-stuff-2 (first class-results))))
(spit "export4.xml" foo )

;(make-mark-list-node a-marks)
;(make-couple-node a-couple-data 7 3 6)
;(make-result-node a-result-array 1 3)

;(defn sanitize [cmp]
;  (let [index (participant-index cmp)]
;    (clojure.walk/postwalk
;      (fn [form]
;        (cond
;          ;; replace participant-number with participant id in results
;          (:result/participant-number form) (dissoc
;                                              (assoc form :result/participant
;                                                          {:participant/id
;                                                           (get index
;                                                                (:result/participant-number form))})
;                                              :result/participant-number)
;
;          ;; adjudicator id should be in map form for lookup ref.
;          (:judging/adjudicator form) (assoc form :judging/adjudicator
;                                                  {:adjudicator/id (:judging/adjudicator form)})
;
;          ;; remove nil values
;          (map? form) (let [m (into {} (remove (comp nil? second) form))]
;                        (when (seq m)
;                          m))
;
;          :else form))
;      cmp)))

(def class-results [{:class-name "Disco Freestyle B-klass J Po"
                     :result {:ajudicators [{:number 2}
                                            {:number 4}
                                            {:number 5}]
                              :dances [{:name "X-Quick Forward"}
                                       {:name "Quick"}]
                              :result-array [{:dancer-number 30
                                              :marks [true false true]}
                                             {:dancer-number 31
                                              :marks [true true true]}
                                             {:dancer-number 32
                                              :marks [false false true]}]}}
                    {:class-name "Disco Freestyle B-klass J Fl"
                     :result {:ajudicators [{:number 1}
                                            {:number 2}
                                            {:number 4}]
                              :dances [{:name "X-Quick"}]
                              :result-array [{:dancer-number 40
                                              :marks [true false false]}
                                             {:dancer-number 41
                                              :marks [true true true]}
                                             ]}}
                    ])

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; API
(defn export-results [stuff]
  (log/info (str "Export Results with " stuff)))

                                              :marks [false false true]}]}}
                    ])

(defn get-dance-count-from-class-node [class-node]
  (let [dance-list-node (first (filter #(= (:tag %) :DanceList) (:content class-node)))]
    (count (:content dance-list-node))))
