Skip to content

Commit

Permalink
added/changes some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
senior committed Jan 27, 2012
1 parent d122801 commit 9ac25a0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/clojure/clojure/data/xml.clj
Expand Up @@ -249,8 +249,8 @@
(.getEncoding stream) ")"))))) (.getEncoding stream) ")")))))


(defn emit-stream (defn emit-stream
"Prints the given Element tree as XML text to *out*. See element-tree. "Prints the given Element tree as XML text to stream.
Options: Options:
:indent <num> Amount to increase indent depth each time :indent <num> Amount to increase indent depth each time
:encoding <str> Character encoding to use" :encoding <str> Character encoding to use"
[e ^java.io.Writer stream & {:as opts}] [e ^java.io.Writer stream & {:as opts}]
Expand All @@ -265,7 +265,12 @@
(.writeEndDocument writer) (.writeEndDocument writer)
stream)) 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)) (apply emit-stream e *out* opts))


(defn indenting-transformer [] (defn indenting-transformer []
Expand All @@ -274,7 +279,11 @@
(.setOutputProperty (javax.xml.transform.OutputKeys/METHOD) "xml") (.setOutputProperty (javax.xml.transform.OutputKeys/METHOD) "xml")
(.setOutputProperty "{http://xml.apache.org/xslt}indent-amount" "2"))) (.setOutputProperty "{http://xml.apache.org/xslt}indent-amount" "2")))


(defn indent [e ^java.io.Writer stream & {:as opts}] (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.) (let [sw (java.io.StringWriter.)
_ (apply emit-stream e sw opts) _ (apply emit-stream e sw opts)
source (-> sw .toString java.io.StringReader. javax.xml.transform.stream.StreamSource.) source (-> sw .toString java.io.StringReader. javax.xml.transform.stream.StreamSource.)
Expand Down

0 comments on commit 9ac25a0

Please sign in to comment.