Welcome! Please see the About page for a little more info on how this works.

0 votes
in Docs by
The clojure.xml parse docstring mentions that parameter s "can be a File, InputStream or String naming a URI."  But those choices do not cover a common case, parsing the value of a String.  Actually, parse also allows InputSource, which solves the problem.  The docstring should mention InputSource (or clarify its omission, if not inadvertent).


user> (use '[clojure.xml :as xml])
nil
user> (import '[java.io StringReader])
java.io.StringReader
user> (import '[org.xml.sax InputSource])
org.xml.sax.InputSource
user> (xml/parse (InputSource. (StringReader. "<egg>green</egg>")))
{:tag :egg, :attrs nil, :content ["green"]}


*Approach:* Update doc-string to reflect that s also can be an InputSource
*Patch:* CLJ-1290.patch
*Screened by:*

3 Answers

0 votes
by

Comment made by: edipofederle

You and mean that de (doc xml/parse) should include also "can be a xml String" ?
I don't know if I understand you right.
Thanks.

0 votes
by

Comment made by: pbwolf

{{InputSource}} is the use of {{xml/parse}} that is not encompassed by the docstring:

(xml/parse (InputSource. (StringReader. "<egg>green</egg>")))

Perhaps {{xml/parse}} aimed to hide {{InputSource}} by making specific provision for some of {{InputSource}}'s capabilities. But reading a {{String}} is important, and {{xml/parse}} does not accept a {{StringReader}}, so {{InputSource}} remains important.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1290 (reported by alex+import)
...