     (.writeEndDocument writer)
     stream))
 
-(defn emit [e & {:as opts}]
+(defn emit
+  "Prints the given Element tree as XML text to *out*.
+   Options:
+    :indent <num>            Amount to increase indent depth each time
+    :encoding <str>          Character encoding to use"
+  [e & {:as opts}]
   (apply emit-stream e *out* opts))
 
 (defn indenting-transformer []

                            (.getEncoding stream) ")")))))

(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 ^java.io.Writer stream & {:as opts}]

    (.setOutputProperty (javax.xml.transform.OutputKeys/METHOD) "xml")
    (.setOutputProperty "{http://xml.apache.org/xslt}indent-amount" "2")))

(defn indent
  "Uses emit-stream to emit XML and indents the result.  WARNING: this is slow
   it will emit the XML and read it in again to indent it.  Intended for 
   debugging/testing only."
  [e ^java.io.Writer stream & {:as opts}]
  (let [sw (java.io.StringWriter.)
        _ (apply emit-stream e sw opts)
        source (-> sw .toString java.io.StringReader. javax.xml.transform.stream.StreamSource.)
