-- small error handling bug fixes; allows xml-handler to handle variable input
[bkell-clj.git] / src / xml_handler.clj
blobcbdc8e41d4baf9e28892cbbad2ba7dc89932d6b9
2 (use 'helpers) 
4 (import 'java.io.ByteArrayInputStream) 
5 (require 'clojure.xml)
9 (defmulti xml_handler   (fn [input handler] 
10                           [
11                             (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput input ) 
12                               :AXmlCommandInput   ;; com.interrupt.bookkeeping.cc.node.AXmlCommandInput
13                               :Node   ;;com.interrupt.bookkeeping.cc.node.Node
14                             )
15                             :handler 
16                           ])
21 (defmethod xml_handler [:Node :handler] [node handler] 
22                         
23    (try 
24       (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput (. node getCommandInput) )
25         (xml_handler (. node getCommandInput) handler)
26         (println "EEeee.. xml_hanlder not processing")
27       )
28       (catch Exception e 
29         (println "EEeee.. xml_hanlder not processing"))
30    ) 
33 (defmethod xml_handler [:AXmlCommandInput :handler] [xinput handler]
34   
35    (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput xinput )
36                         (do 
37                            
38                            (println "XML input[" xinput "]")
39                            (let [xml-string (filterSpacesFromXML (. xinput toString))] 
40                                         
41                                         (println "XML filtered[" xml-string "]")
42                                         (handler (clojure.xml/parse (ByteArrayInputStream. (.getBytes xml-string "UTF-8"))))
43                                         
44                            )
45                            
46                         )
47    )