   Emit
   (emit-element [e writer]
     (let [nspace (namespace (:tag e))
-          qname (name (: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)]

(defprotocol Emit
  (emit-element [element writer]))

(defn write-attributes [{:keys (attrs)} writer]
  (doseq [[k v] attrs]
    (.writeAttribute writer (str (namespace k)) (name k) (str v))))


(defrecord CData [content]
  Emit
  (emit-element [e writer]
    (.writeCData ^javax.xml.stream.XMLStreamWriter writer (:content e))))

(defrecord Comment [content]
  Emit
  (emit-element [e writer]
    (.writeComment ^javax.xml.stream.XMLStreamWriter writer (:content e))))

(extend-protocol Emit
  String
  (emit-element [e writer]
    (.writeCharacters ^javax.xml.stream.XMLStreamWriter writer e)))

(defn element [tag & [attrs & content]]
  (Element. tag (or attrs {}) content))
