Issue parsing and then emitting xml:lang attribute.

Description

There is an issue occurring somewhere in the chain of:

```
(require '[clojure.data.xml :as xml])
(-> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo xml:lang=\"en\"></foo>" xml/parse-str pprint)
```

Which results in the following error:

```
XMLStreamException Prefix cannot be null com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute (XMLStreamWriterImpl.java:575)
```

It appears, after some brief exploration, that this comes from emitting the string which is parsed into a keyword with a namespace. The following results show this:

```
user=> (-> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo xml:lang=\"en\"></foo>" xml/parse-str pprint)
{:tag :foo, :attrs {:xml/lang "en"}, :content ()}
```

and

```
user=> (xml/emit-str (xml/element :foo {:xml:lang "en"}))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo xml:lang=\"en\"></foo>"
```

Environment

Using org.clojure/data.xml "0.0.8", org.clojure/clojure "1.9.0-alpha10", and Leiningen 2.6.1 on Java 1.8.0_76 OpenJDK 64-Bit Server VM.

Activity

Show:

Herwig HochleitnerOctober 3, 2016 at 11:49 PM

Won't fix for data.xml-0.0.x

Herwig HochleitnerOctober 3, 2016 at 11:47 PM

data.xml-0.0.8 doesn't have namespace support. Your first example works, starting with -beta1
Your second example works, because you're directly emitting xml:lang and the xml: prefix happens to be implicitly defined in xml.

importSeptember 1, 2016 at 7:13 PM

Comment made by: im_ferris

There is an error in my report, the first code example, related to what causes the error, should read:

(-> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo xml:lang=\"en\"></foo>" xml/parse-str xml/emit-str)

Declined

Details

Assignee

Reporter

Priority

Created September 1, 2016 at 7:11 PM
Updated October 3, 2016 at 11:49 PM
Resolved October 3, 2016 at 11:49 PM