 
     event-seq))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Transformations of event streams
-(defn throw-if-error [[type ex :as evt]]
-  (if (= :error type)
-    (throw ex)
-    evt))
 
 (defn throw-on-error [events]
-  (map throw-if-error events))
-
-
-;; swiped from data.xml:
-(defn attrs->map [^Attributes atts]
-  (into {} (for [^Long i (range (.getLength atts))]
-             [(keyword (.getQName atts i))
-              (.getValue atts i)])))
-
-(defn mapify-attrs
-  "Tranform start-element events so that attributes are stored in a
-  map, rather than an Attributes instance."
-  [events]
-  (map (fn [[type tag attrs :as evt]]
-         (if (= type :start-element)
-           [:start-element tag (attrs->map attrs)]
+  (map (fn [[type exc :as evt]]
+         (if (= :error type)
+           (throw exc)
            evt))
        events))
+
 
 (defn merge-adjacent-text
   "Transform the event stream so that adjacent bits of text are

        ;; <exception>].  This transformation will re-throw them.
        e (throw-on-error e)

        ;; Turn Attributes on start-element events into maps.
        e (mapify-attrs e)

        ;; SAX parsers can emit multiple "characters" events for one
        ;; piece of text (for example, when it contains entities, such
        ;; as &amp;). It's generally more convenient to work with

       If false, nodes of the corresponding type are discarded.

     :namespaces
       Sets namespace-awareness in the SAX parser. See below.

   Namespace-awareness has the following effects:

   When set to false, XML namespaces are more-or-less ignored, and
   tags and attributes are stored as they appear textually in the
   XML, including prefixes.

   When set to true, namespace URIs are stored as part of Elements'
   values, and prefix information is stored in metadata.

   Specifically, setting this when parsing causes the following
   differences in the resulting tree, where each point below lists the
   effects of setting :namespaces to true (t) or false (f):

    * xmlns declarations:
       t: stored in metadata as :xmlns-decls
       f: present in the attrs map, like regular attributes
        
    * The ns field of Elements:
       t: the namespace URI (or nil, for the default namespace)
       f: always nil

    * The tag field of Elements:
       t: the localName only (no prefix)
       f: the QName (prefix:tagname)

    * Unprefixed attributes:
       t: attribute name as a keyword
       f: attribute name as a keyword

    * Prefixed (namespaced) attributes:
       t: vector of [:localName ns-uri], with {:prefix prefix} metadata
       f: the QName as a keyword (prefix:attrname)

    * Other stuff that I can't remember right now:
       t: ???
       f: ???

   "
  
  [source & [opts]]
