<< Back to previous view

[DXML-18] Not parsing multiple top-level elements Created: 24/Jun/13  Updated: 10/Nov/13  Resolved: 10/Nov/13

Status: Closed
Project: data.xml
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Alan Busby Assignee: Ryan Senior
Resolution: Declined Votes: 0
Labels: None
Environment:

[org.clojure/clojure "1.5.1"] and [org.clojure/data.xml "0.0.7"]



 Description   

(xml/parse-str "<a>1</a><b>2</b>")
Emits
{:tag :a, :attrs {}, :content ("1")}

Where did "b" go?



 Comments   
Comment by Alan Busby [ 24/Jun/13 7:43 AM ]

Sorry, feel free to close this.
Reviewing the code it appears that parse-str only accepts full XML documents and can't handle fragments, or is that incorrect?

Comment by Ryan Senior [ 10/Nov/13 10:39 PM ]

That's correct. Closing this as it's by design.





[DXML-20] Odd behaviour when using lein uberjar Created: 25/Sep/13  Updated: 10/Nov/13  Resolved: 10/Nov/13

Status: Closed
Project: data.xml
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Neil Laurance Assignee: Ryan Senior
Resolution: Declined Votes: 0
Labels: None
Environment:

Leiningen 2.3.2 on Java 1.7.0_11 Java HotSpot(TM) 64-Bit Server VM



 Description   

(For original query posted to leiningen project, see: https://github.com/technomancy/leiningen/issues/1334)

I have a trivial app:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns test-app.core
  (:require [clojure.data.xml :as dx])
  (:gen-class))

(def xml
  (dx/emit-str
   (dx/sexp-as-element
    [:hello
     [:world]])))

(defn -main
  [& args]
  (println xml))

And a lein project definition of:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(defproject test-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
    [org.clojure/clojure "1.5.1"]
    [org.clojure/data.xml "0.0.7"]]
  :main test-app.core
  :profiles {:uberjar {:aot :all}})

Attempting to run lein uberjar throws a stacktrace.

Attempting to run a second time without cleaning first succeeds.

Workaround is to change (def xml) to (defn xml []) and then invoke it.

Stacktrace is:

Warning: specified :main without including it in :aot. 
Implicit AOT of :main will be removed in Leiningen 3.0.0. 
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.
Compiling test-app.core
Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: clojure.data.xml.Element, compiling:(core.clj:6:3)
    at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3463)
    at clojure.lang.Compiler$DefExpr.eval(Compiler.java:408)
    at clojure.lang.Compiler.compile1(Compiler.java:7153)
    at clojure.lang.Compiler.compile(Compiler.java:7219)
    at clojure.lang.RT.compile(RT.java:398)
    at clojure.lang.RT.load(RT.java:438)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5018.invoke(core.clj:5530)
    at clojure.core$load.doInvoke(core.clj:5529)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5336)
    at clojure.core$compile$fn__5023.invoke(core.clj:5541)
    at clojure.core$compile.invoke(core.clj:5540)
    at user$eval9.invoke(form-init6653146504522592512.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6619)
    at clojure.lang.Compiler.eval(Compiler.java:6609)
    at clojure.lang.Compiler.load(Compiler.java:7064)
    at clojure.lang.Compiler.loadFile(Compiler.java:7020)
    at clojure.main$load_script.invoke(main.clj:294)
    at clojure.main$init_opt.invoke(main.clj:299)
    at clojure.main$initialize.invoke(main.clj:327)
    at clojure.main$null_opt.invoke(main.clj:362)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: clojure.data.xml.Element
    at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
    at clojure.data.xml$fn__136$G__131__141.invoke(xml.clj:73)
    at clojure.data.xml$flatten_elements$fn__189.invoke(xml.clj:129)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:484)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.data.xml$emit.doInvoke(xml.clj:366)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.data.xml$emit_str.invoke(xml.clj:375)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3458)
    ... 27 more
Compilation failed: Subprocess failed


 Comments   
Comment by Ryan Senior [ 10/Nov/13 10:35 PM ]

I think this is a broader issue with AOT. I'm thinking it's probably related to this: http://dev.clojure.org/jira/browse/CLJ-979. I've seen this in other code, but it's the first time I've seen it reported for data.xml. Wrapping it in a function is a good idea. I think avoiding AOT would also fix your issue.





Generated at Sun Nov 23 10:26:58 CST 2014 using JIRA 4.4#649-r158309.