/usr/share/doc/libdata-xml-clojure/html/README.html is in libdata-xml-clojure 0.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>data.xml</title>
</head>
<body><h1>data.xml</h1>
<p><a href="https://github.com/clojure/data.xml">data.xml</a> is a Clojure library for reading and writing XML data. This
library is the successor to
<a href="http://clojure.github.com/clojure-contrib/lazy-xml-api.html">lazy-xml</a>.
data.xml has the following features:</p>
<ul>
<li>Parses XML documents into Clojure data structures</li>
<li>Emits XML from Clojure data structures</li>
<li>No additional dependencies if using 1.6</li>
<li>Uses StAX internally</li>
<li>lazy - should allow parsing and emitting of large XML documents</li>
</ul>
<h2>JDK 1.5</h2>
<p>This library uses the pull parser that ships with JDK 1.6. If you running on JDK 1.6+, you do not need any
additional dependencies. If you are using JDK 1.5, you will need to include a dependency on StAX. More
information on this is available <a href="https://github.com/clojure/data.xml/blob/jdk16-pull-parser/jdk_15_readme.txt">here</a></p>
<h2>Bugs</h2>
<p>Please report bugs using JIRA <a href="http://dev.clojure.org/jira/browse/DXML">here</a>.</p>
<h2>Installation</h2>
<p>Latest stable release: 0.0.7</p>
<ul>
<li><p><a href="http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22data.xml%22">All Released Versions</a></p></li>
<li><p><a href="https://oss.sonatype.org/index.html#nexus-search;gav~org.clojure~data.xml~~~">Development Snapshot Versions</a></p></li>
</ul>
<h3>Maven</h3>
<p>For Maven projects, add the following XML in your <code>pom.xml</code>'s <code><dependencies></code> section:</p>
<pre><code><dependency>
<groupId>org.clojure</groupId>
<artifactId>data.xml</artifactId>
<version>0.0.7</version>
</dependency>
</code></pre>
<h3>Leiningen</h3>
<p>Add the following to the <code>project.clj</code> dependencies:</p>
<pre><code>[org.clojure/data.xml "0.0.7"]
</code></pre>
<h2>Examples</h2>
<p>The examples below assume you have added a <code>use</code> for data.xml:</p>
<pre><code>(use 'clojure.data.xml)
</code></pre>
<p>data.xml supports parsing and emitting XML. The parsing functions will
read XML from a
<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Reader.html">Reader</a>
or
<a href="http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html">InputStream</a>.</p>
<pre><code>(let [input-xml (java.io.StringReader. "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<foo><bar><baz>The baz value</baz></bar></foo>")]
(parse input-xml))
#clojure.data.xml.Element{:tag :foo,
:attrs {},
:content (#clojure.data.xml.Element{:tag :bar,
:attrs {},
:content (#clojure.data.xml.Element{:tag :baz,
:attrs {},
:content ("The baz value")})})}
</code></pre>
<p>The data is returned as defrecords and can be manipulated using the
normal clojure data structure functions. Additional parsing options
can be passed via key pairs:</p>
<pre><code>(parse-str "<a><![CDATA[\nfoo bar\n]]><![CDATA[\nbaz\n]]></a>" :coalescing false)
#clojure.data.xml.Element{:tag :a, :attrs {}, :content ("\nfoo bar\n" "\nbaz\n")}
</code></pre>
<p>XML elements can be created using the typical defrecord constructor
functions or the element function used below, and written using a
<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Writer.html">java.io.Writer</a>.:</p>
<pre><code>(let [tags (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value")))]
(with-open [out-file (java.io.FileWriter. "/tmp/foo.xml")]
(emit tags out-file)))
;;-> Writes XML to /tmp/foo.xml
</code></pre>
<p>The same can also be expressed using a more Hiccup-like style of defining the elements using sexp-as-element:</p>
<pre><code>(= (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value")))
(sexp-as-element
[:foo {:foo-attr "foo value"}
[:bar {:bar-attr "bar value"}
[:baz {} "The baz value"]]]))
;;-> true
</code></pre>
<p>Comments and CDATA can also be emitted as an S-expression with the special tag names :-cdata and :-comment:</p>
<pre><code>(= (element :tag {:attr "value"}
(element :body {} (cdata "not parsed <stuff")))
(sexp-as-element [:tag {:attr "value"} [:body {} [:-cdata "not parsed <stuff"]]]
;;-> true
</code></pre>
<p>XML can be "round tripped" through the library:</p>
<pre><code>(let [tags (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value")))]
(with-open [out-file (java.io.FileWriter. "/tmp/foo.xml")]
(emit tags out-file))
(with-open [input (java.io.FileInputStream. "/tmp/foo.xml")]
(parse input)))
#clojure.data.xml.Element{:tag :foo, :attrs {:foo-attr "foo value"}...}
</code></pre>
<p>There are also some string based functions that are useful for
debugging.</p>
<pre><code>(let [tags (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value")))]
(= tags (parse-str (emit-str tags))))
true
</code></pre>
<p>Indentation is supported, but should be treated as a debugging feature
as it's likely to be pretty slow:</p>
<pre><code>(print (indent-str (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value1")
(element :baz {} "The baz value2")
(element :baz {} "The baz value3")))))
<?xml version="1.0" encoding="UTF-8"?>
<foo foo-attr="foo value">
<bar bar-attr="bar value">
<baz>The baz value1</baz>
<baz>The baz value2</baz>
<baz>The baz value3</baz>
</bar>
</foo>
</code></pre>
<p>CDATA can be emitted:</p>
<pre><code>(emit-str (element :foo {}
(cdata "<non><escaped><info><here>")))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo><![CDATA[<non><escaped><info><here>]]></foo>"
</code></pre>
<p>But will be read as regular character data:</p>
<pre><code>(parse-str (emit-str (element :foo {}
(cdata "<non><escaped><info><here>"))))
#clojure.data.xml.Element{:tag :foo, :attrs {}, :content ("<non><escaped><info><here>")}
</code></pre>
<p>Comments can also be emitted:</p>
<pre><code>(emit-str (element :foo {}
(xml-comment "Just a <comment> goes here")
(element :bar {} "and another element")))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo><!--Just a <comment> goes here--><bar>and another element</bar></foo>"
</code></pre>
<p>But are ignored when read:</p>
<pre><code>(emit-str
(parse-str
(emit-str (element :foo {}
(xml-comment "Just a <comment> goes here")
(element :bar {} "and another element")))))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo><bar>and another element</bar></foo>"
</code></pre>
<p>Generated API docs for data.xml are available <a href="http://clojure.github.com/data.xml">here</a>.</p>
<h2>License</h2>
<p>Licensed under the <a href="http://www.opensource.org/licenses/eclipse-1.0.php">Eclipse Public License</a>.</p>
<h2>Developer Information</h2>
<ul>
<li><p><a href="https://github.com/clojure/data.xml">GitHub project</a></p></li>
<li><p><a href="http://dev.clojure.org/jira/browse/DXML">Bug Tracker</a></p></li>
<li><p><a href="http://build.clojure.org/job/data.xml/">Continuous Integration</a></p></li>
<li><p><a href="http://build.clojure.org/job/data.xml-test-matrix/">Compatibility Test Matrix</a></p></li>
</ul>
<h2>Contributing</h2>
<p>All contributions need to be made via patches attached to tickets in
<a href="http://dev.clojure.org/jira/browse/DXML">JIRA</a>. Check the
<a href="http://clojure.org/contributing">Contributing to Clojure</a> page for
more information.</p>
</body>
</html>
|