     root))
 
 
-(defn- attr-prefix [sreader index]
+(defn- attr-prefix [^XMLStreamReader sreader index]
   (let [p (.getAttributePrefix sreader index)]
     (when-not (str/blank? p)
       p)))

;;;; XML Emitting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn emit-stream
  "Prints the given Element tree as XML text to *out*. See element-tree.
  Options:
    :indent <num>            Amount to increase indent depth each time
    :encoding <str>          Character encoding to use"
  [e stream & {:as opts}]
  (let [writer (-> (javax.xml.stream.XMLOutputFactory/newInstance)
                 (.createXMLStreamWriter stream))
        encoding (or (:encoding opts) "UTF-8")]

    (when (and (instance? java.io.OutputStreamWriter stream)
               (not= (Charset/forName encoding) (Charset/forName (.getEncoding stream))))
      (throw (Exception. (str "Output encoding of stream (" encoding
                              ") doesn't match declaration ("
                              (.getEncoding stream) ")"))))
    
    (.writeStartDocument writer (or (:encoding opts) "UTF-8") "1.0")
    (emit-element e writer)

  Emit
  (emit-element [e writer]
    (let [nspace (namespace (:tag e))
          qname (name (:tag e))
          ^javax.xml.stream.XMLStreamWriter writer writer]
      (.writeStartElement writer ""  qname (or nspace ""))
      (write-attributes e writer)
      (doseq [c (:content e)]
