 (extend-protocol AsInputSource
   String
   (input-source [s]
-    (let [^Reader r (if (.startsWith s "<")
+    (let [^Reader r (if (.startsWith s "<") ;; too "clever"? ... <shrug>
                       (StringReader. s)
                       (io/reader s))]
       (InputSource. r)))

         (apply concat))))


(defn ignore [events & event-types]
  (let [ignores (set event-types)]
    (remove (fn [e] (ignores (v 0))) events)))

(defn parse [in]
  (-> in
      event-seq
      merge-text
      (ignore :start-cdata :end-cdata)
      ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    ;; Text
    (characters [^chars ch ^long start ^long length]
      (f [:text (String. ch start length)]))

    ;; Keep track of which text came from a CDATA section
    (startCDATA []
