Skip to content

Commit 6a66ee5

Browse files
committed
check and refresh all examples
1 parent 891855d commit 6a66ee5

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,17 @@ or
9292
<foo><bar><baz>The baz value</baz></bar></foo>")]
9393
(xml/parse input-xml))
9494

95-
#clojure.data.xml.Element{:tag :foo,
96-
:attrs {},
97-
:content (#clojure.data.xml.Element{:tag :bar,
98-
:attrs {},
99-
:content (#clojure.data.xml.Element{:tag :baz,
100-
:attrs {},
101-
:content ("The baz value")})})}
95+
#xml/element{:tag :foo,
96+
:content [#xml/element{:tag :bar,
97+
:content [#xml/element{:tag :baz,
98+
:content ["The baz value"]}]}]}
10299

103100
The data is returned as defrecords and can be manipulated using the
104101
normal clojure data structure functions. Additional parsing options
105102
can be passed via key pairs:
106103

107104
(xml/parse-str "<a><![CDATA[\nfoo bar\n]]><![CDATA[\nbaz\n]]></a>" :coalescing false)
108-
#clojure.data.xml.Element{:tag :a, :attrs {}, :content ("\nfoo bar\n" "\nbaz\n")}
105+
#xml/element{:tag :a, :content ["\nfoo bar\n" "\nbaz\n"]}
109106

110107
XML elements can be created using the typical defrecord constructor
111108
functions or the element function used below or just a plain map with :tag :attrs :content keys, and written using a
@@ -134,7 +131,7 @@ Comments and CDATA can also be emitted as an S-expression with the special tag n
134131

135132
(= (xml/element :tag {:attr "value"}
136133
(xml/element :body {} (xml/cdata "not parsed <stuff")))
137-
(xml/sexp-as-element [:tag {:attr "value"} [:body {} [:-cdata "not parsed <stuff"]]]
134+
(xml/sexp-as-element [:tag {:attr "value"} [:body {} [:-cdata "not parsed <stuff"]]]))
138135
;;-> true
139136

140137
XML can be "round tripped" through the library:
@@ -147,7 +144,7 @@ XML can be "round tripped" through the library:
147144
(with-open [input (java.io.FileInputStream. "/tmp/foo.xml")]
148145
(xml/parse input)))
149146

150-
#clojure.data.xml.Element{:tag :foo, :attrs {:foo-attr "foo value"}...}
147+
#xml/element{:tag :foo, :attrs {:foo-attr "foo value"}...}
151148

152149
There are also some string based functions that are useful for
153150
debugging.
@@ -186,10 +183,10 @@ CDATA can be emitted:
186183

187184
But will be read as regular character data:
188185

189-
(xml/parse-str (xml/emit-str (element :foo {}
186+
(xml/parse-str (xml/emit-str (xml/element :foo {}
190187
(xml/cdata "<non><escaped><info><here>"))))
191188

192-
#clojure.data.xml.Element{:tag :foo, :attrs {}, :content ("<non><escaped><info><here>")}
189+
#xml/element{:tag :foo, :content ["<non><escaped><info><here>"]}
193190

194191
Comments can also be emitted:
195192

@@ -219,9 +216,7 @@ Below is an example of parsing an XHTML document:
219216
(xml/parse-str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
220217
<foo:html xmlns:foo=\"http://www.w3.org/1999/xhtml\"/>")
221218

222-
#...Element{:tag :xmlns.http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml/html,
223-
:attrs {},
224-
:content ()}
219+
#xml/element{:tag :xmlns.http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml/html}
225220

226221
Emitting namespaced XML is usually done by using `alias-uri` in combination with clojure's built-in `::kw-ns/shorthands`:
227222

@@ -238,7 +233,7 @@ Emitting namespaced XML is usually done by using `alias-uri` in combination with
238233

239234
It is also allowable to use `javax.xml.namespace.QName` instances, as well as strings with the informal `{ns}n` encoding.
240235

241-
(xml/emit-str {:tag (qname "http://www.w3.org/1999/xhtml" "html")})
236+
(xml/emit-str {:tag (xml/qname "http://www.w3.org/1999/xhtml" "html")})
242237
(xml/emit-str {:tag "{http://www.w3.org/1999/xhtml}html"})
243238

244239
<?xml version=\"1.0\" encoding=\"UTF-8\"?><a:html xmlns:a=\"http://www.w3.org/1999/xhtml\"></a:html>
@@ -297,7 +292,7 @@ By default the parser attaches location information as element meta,
297292
(deftest test-location-meta
298293
(let [input "<a><b/>\n<b/></a>"
299294
location-meta (comp :clojure.data.xml/location-info meta)]
300-
(is (= 1 (-> input xml/parse-str location-meta :line-number)))
295+
(is (= 1 (-> input xml/parse-str location-meta :line-number)))))
301296

302297
To elide location information, pass `:location-info false` to the parser:
303298

0 commit comments

Comments
 (0)