<< 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-23] Prefix is null in Inkscape SVG Created: 26/May/14  Updated: 19/Dec/15  Resolved: 19/Dec/15

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

Type: Defect Priority: Major
Reporter: Christian Weilbach Assignee: Ryan Senior
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Ubuntu 14.04 amd64, openjdk-7, clojure 1.6.0, data.xml 0.0.7.



 Description   

When loading a fairly basic inkscape XML (1) in data.xml with (emit-str (parse (io/reader ".../minimal.svg"))), I get:

XMLStreamException Prefix cannot be null
com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute (XMLStreamWriterImpl.java:575)
clojure.data.xml/write-attributes (xml.clj:39)
clojure.data.xml/emit-start-tag (xml.clj:50)
clojure.data.xml/emit-event (xml.clj:67)
clojure.data.xml/emit (xml.clj:367)
clojure.data.xml/emit-str (xml.clj:375)
xml-test.core/eval1512 (form-init517397699703209853.clj:1)
clojure.lang.Compiler.eval (Compiler.java:6703)
clojure.lang.Compiler.eval (Compiler.java:6666)
clojure.core/eval (core.clj:2927)
clojure.main/repl/read-eval-print-6625/fn-6628 (main.clj:239)
clojure.main/repl/read-eval-print--6625 (main.clj:239)

(1) https://gist.github.com/ghubber/34dbc54a9cf30ce68b8a



 Comments   
Comment by John Walker [ 13/Jun/14 9:26 PM ]

What is your system encoding?
Edit: Nevermind. It's specified in emit. Looks to be related to http://dev.clojure.org/jira/browse/DXML-4

Comment by Ryan Senior [ 19/Dec/15 9:33 AM ]

This is related to DXML-4. I have verified that your examples work in the new namespacing branch (which will soon be released as 0.1.0). Closing this as a duplicate of DXML-4.





[DXML-4] Namespaces support Created: 27/Mar/12  Updated: 13/Jan/16  Resolved: 13/Jan/16

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

Type: Enhancement Priority: Major
Reporter: Carlo Sciolla Assignee: Ryan Senior
Resolution: Completed Votes: 12
Labels: None

Attachments: Text File add_namespaces.patch     Text File add-namespace-support.patch     Text File roundtrip-documents.patch    
Patch: Code and Test

 Description   

Add support for both parsing and emitting namespace qualified tags and namespaces URI declarations.
It basically follows the underlying Java XML API in giving xmlns:foo attributes "special" treatment.



 Comments   
Comment by Ryan Senior [ 22/May/12 10:26 AM ]

I don't see a contributor agreement for you Carlo. Have you signed one? http://clojure.org/contributing

Comment by Gary Trakhman [ 19/Jun/12 6:09 PM ]

ping, is the patch still waiting for a signed CA?

Comment by Ryan Senior [ 26/Jun/12 12:14 PM ]

Yes

Comment by Robert Onslow [ 01/Dec/12 5:07 AM ]

Is this patch due reasonable soon?

Comment by Andy Fingerhut [ 21/Apr/13 7:04 PM ]

Link to a design page with some ideas for XML namespace support in Clojure: http://dev.clojure.org/display/DXML/Fuller+XML+support

Comment by Herwig Hochleitner [ 26/Mar/14 9:20 AM ]

I've taken another stab at this. Attached roundtrip-documents.patch implements roundtripping, which means reading and writing xmlns attributes and namespaces as is.

Further improvements, that would fall into the scope of this ticket, but should be implemented on top of correct roundtripping, hence another ticket might be in order:

  • functionality for normalizing prefixes
  • rewriting prefixes
  • finding a minimal set of prefix names and/or default namespace, for given fragment
Comment by Steve Suehs [ 26/Mar/14 4:04 PM ]

I could really use this. I'm tweaking poms and the xml headers with schema locations cause grief. If you are in Austin I'll buy you a beer.

Comment by Herwig Hochleitner [ 01/Apr/14 4:41 AM ]

Good to hear that. I've implemented a walker to resolve names in namespaced xml and have the emitter assign the prefix of a resolved name. You can review / use at your own peril from here: https://github.com/bendlas/data.xml

Right now, I'm doing cleanup passes and trying to get feedback from the before pushing for change.

Comment by Paul Gearon [ 21/May/14 12:53 AM ]

I stupidly did this myself before realizing it was already done.
What is the current status? Still waiting on Carlo (since he's submitted a patch), looking to use Herwig's, or something else?

I wasn't totally happy with how I did it, since I used a binding for a parallel stack containing the current prefix->URI mappings. This was because QName prefixes are kept in the namespace of an element's keyword, but .writeStartElement and .writeAttribute need the URIs the prefix maps to, which wasn't being kept. It'd be nice to see if there's a better way.

Comment by Paul Gearon [ 21/May/14 10:36 AM ]

Submitting this patch, since the process requires a patch file. Carlo has not responded about the contributor agreement for 2 years, and none of the other attempts have been submitted as patches (edit: I've now seen Herwig's emails and realize that this is active).

Other implementations may be better, but I need to get the ball rolling on this.

Comment by Martin Clausen [ 27/Aug/14 2:35 PM ]

Carlo has signed a CA and is on the contributor list. Hope this means this much needed patch can be accpeted.

Comment by Thomas Engelschmidt [ 01/Nov/14 8:48 AM ]

Are there any plans on applying the patches ?

Comment by Ryan Senior [ 03/Nov/14 6:42 AM ]

We will be merging in Herwig's implementation soon. We're still waiting on getting him commit rights to the data.xml repo, so for now you can find his implementation here: https://github.com/bendlas/data.xml. We're planning on merging that into a namespaces branch where we'll hopefully have a beta release soon.

Comment by Christian Weilbach [ 25/May/15 8:37 AM ]

Any updates? This would probably resolve my problem as well: http://dev.clojure.org/jira/browse/DXML-23.

Comment by Joshua Griffith [ 16/Sep/15 10:41 AM ]

We ran into this problem when integrating with an external XML service. Are there any remaining barriers to this landing?

Comment by Ryan Senior [ 16/Sep/15 10:49 AM ]

Herwig is currently working on this in a fork (https://github.com/bendlas/data.xml), AFAIK his intention is to add it to data.xml once it's done

Comment by Joshua Griffith [ 12/Jan/16 7:53 PM ]

Is this closed? https://github.com/clojure/data.xml/commit/31558df7826fd388255bfe4c3b77ad4fbd8b89d1 suggests that it is.

Comment by Ryan Senior [ 13/Jan/16 8:43 AM ]

Correct, this was released as part of 0.1.0-beta1. Would love some feedback if you're using it.

Comment by Ryan Senior [ 13/Jan/16 8:43 AM ]

Released as 0.1.0-beta1





[DXML-28] pull-seq :characters events are not compatible with emit-event Created: 23/Sep/15  Updated: 13/Jan/16  Resolved: 13/Jan/16

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

Type: Defect Priority: Major
Reporter: Nils Blum-Oeste Assignee: Ryan Senior
Resolution: Completed Votes: 0
Labels: None
Environment:

data.xml-0.0.8


Attachments: Text File fixbug_dxml-28.patch    

 Description   

`pull-seq` generates an event with type `:characters` for `XMLStreamConstants/CHARACTERS`. `emit-event` only handles events with type `:chars` though.

Because of that, emitting events from the event sequence created by `pull-seq` can fail with `IllegalArgumentException No matching clause: :characters clojure.data.xml/emit-event (xml.clj:66)`



 Comments   
Comment by Nils Blum-Oeste [ 23/Sep/15 6:41 AM ]

Working on a patch

Comment by Nils Blum-Oeste [ 23/Sep/15 7:00 AM ]

Patch attached

Comment by Nils Blum-Oeste [ 15/Dec/15 1:29 AM ]

Any comments on this @Ryan ?
Anything needed for this?

Comment by Ryan Senior [ 15/Dec/15 8:39 AM ]

Thanks for the ping Nils. I'm working with Herwig to get namespaces in a 0.1.0 release. I'll also take a look at this for inclusion in 0.1.0 as well, should be this week.

Comment by Ryan Senior [ 19/Dec/15 9:31 AM ]

I have verified that this issue is fixed in the namespacing branch. I validated the fix with a test and it will be released shortly. I'll close this ticket once the release has happened.

Comment by Ryan Senior [ 13/Jan/16 8:45 AM ]

Released as part of 0.1.0-beta1





[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 Sat Feb 13 01:10:46 CST 2016 using JIRA 4.4#649-r158309.