<< Back to previous view

[DXML-47] Failed to emit CDATA in ClojureScript Created: 26/Jul/17  Updated: 26/Jul/17

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

Type: Defect Priority: Major
Reporter: Heehong Moon Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Emitting CDATA in ClojureScript causes an error.

dev:cljs.user=> (xml/emit-str (xml/element :a {} "test"))
"<a>test</a>"
dev:cljs.user=> (xml/emit-str (xml/element :a {} (xml/cdata "<b></b>")))
#object[Error Error: No protocol method AsQName.qname-uri defined for type null: ]
   cljs.core/missing-protocol (jar:file:/Users/bbirec/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs:270:4)
   clojure.data.xml.protocols/qname-uri (jar:file:/Users/bbirec/.m2/repository/org/clojure/data.xml/0.2.0-alpha2/data.xml-0.2.0-alpha2.jar!/clojure/data/xml/protocols.cljc:13:1)
   clojure.data.xml.name/qname-uri (jar:file:/Users/bbirec/.m2/repository/org/clojure/data.xml/0.2.0-alpha2/data.xml-0.2.0-alpha2.jar!/clojure/data/xml/name.cljc:42:4)
   Function.clojure.data.xml.js.dom.element_STAR_.cljs$core$IFn$_invoke$arity$3 (jar:file:/Users/bbirec/.m2/repository/org/clojure/data.xml/0.2.0-alpha2/data.xml-0.2.0-alpha2.jar!/clojure/data/xml/js/dom.cljs:32:36)
   clojure.data.xml.js.dom/element* (jar:file:/Users/bbirec/.m2/repository/org/clojure/data.xml/0.2.0-alpha2/data.xml-0.2.0-alpha2.jar!/clojure/data/xml/js/dom.cljs:15:1)
   clojure$data$xml$js$dom$element_node (jar:file:/Users/bbirec/.m2/repository/org/clojure/data.xml/0.2.0-alpha2/data.xml-0.2.0-alpha2.jar!/clojure/data/xml/js/dom.cljs:97:30)
   cljs.core.map.cljs$core$IFn$_invoke$arity$2 (jar:file:/Users/bbirec/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs:4466:30)
   cljs.core.LazySeq.sval (jar:file:/Users/bbirec/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs:3223:18)
   cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (jar:file:/Users/bbirec/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs:3277:12)
nil
dev:cljs.user=>





[DXML-44] AbstractMethodError: Method clojure/data/xml/node/Element.empty() Created: 03/Apr/17  Updated: 08/May/17

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

Type: Defect Priority: Major
Reporter: Alan Thompson Assignee: Ryan Senior
Resolution: Unresolved Votes: 2
Labels: bug
Environment:

Ubuntu 16.04, Java8, Clojure 1.8.0



 Description   

When trying to use `postwalk`, I get this error:

Caused by: java.lang.AbstractMethodError: Method clojure/data/xml/node/Element.empty()Lclojure/lang/IPersistentCollection; is abstract
at clojure.data.xml.node.Element.empty(node.clj)
at clojure.core$empty.invokeStatic(core.clj:5043)
at clojure.walk$walk.invokeStatic(walk.clj:49)
at clojure.walk$postwalk.invokeStatic(walk.clj:52)
at clojure.walk$postwalk.invoke(walk.clj:52)

The problem does not occur with version 0.0.8



 Comments   
Comment by Aaron Iba [ 08/May/17 6:47 PM ]

I had the same problem. If you're looking for a workaround, you prewalk special casing clojure.data.xml.node.Element values:

(walk/prewalk (fn [x]
                (if (instance? clojure.data.xml.node.Element x)
                  (into {} x)
                  (do-whatever x)))
              x)




[DXML-32] data.xml fails when used with Java 9 Created: 27/May/16  Updated: 07/Mar/17

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

Type: Defect Priority: Major
Reporter: Toby Crawley Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Java 9's module system (Jigsaw) appears to prevent loading of some of the XML classes. Java 9 isn't due to be released until March 2017, so there isn't a huge rush to fix this, but I wanted to make you aware. Unfortunately, I don't have enough knowledge of the module system to suggest the proper fix/workaround.

tcrawley@katahdin ~/w/c/data.xml> mvn test
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building data.xml 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ data.xml ---
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:add-source (add-clojure-source-dirs) @ data.xml ---
[INFO] Source directory: /home/tcrawley/work/clojure/data.xml/src/main/clojure added.
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:add-resource (add-clojure-source-dirs) @ data.xml ---
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:add-test-source (add-clojure-test-source-dirs) @ data.xml ---
[INFO] Test Source directory: /home/tcrawley/work/clojure/data.xml/src/test/clojure added.
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:add-test-resource (add-clojure-test-source-dirs) @ data.xml ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ data.xml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/tcrawley/work/clojure/data.xml/src/main/resources
[INFO] Copying 13 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ data.xml ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- clojure-maven-plugin:1.3.13:compile (clojure-compile) @ data.xml ---
Compiling clojure.data.xml.name to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.node to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.name to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.emit to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.prxml to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.impl to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.tree to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.pprint to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.process to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.protocols to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.parse to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.event to /tmp/classes8428993250598039353.dir
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ data.xml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ data.xml ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ data.xml ---
[INFO] 
[INFO] --- clojure-maven-plugin:1.3.13:test (clojure-test) @ data.xml ---
Exception in thread "main" java.lang.IllegalAccessException: class clojure.lang.Reflector cannot access class com.sun.xml.internal.stream.XMLInputFactoryImpl (in module java.xml) because module java.xml does not export com.sun.xml.internal.stream to unnamed module @1704f67f, compiling:(test_emit.clj:18)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3387)
	at clojure.lang.Compiler$DefExpr.eval(Compiler.java:398)
	at clojure.lang.Compiler.eval(Compiler.java:6516)
	at clojure.lang.Compiler.load(Compiler.java:6952)
	at clojure.lang.RT.loadResourceScript(RT.java:359)
	at clojure.lang.RT.loadResourceScript(RT.java:350)
	at clojure.lang.RT.load(RT.java:429)
	at clojure.lang.RT.load(RT.java:400)
	at clojure.core$load$fn__4890.invoke(core.clj:5415)
	at clojure.core$load.doInvoke(core.clj:5414)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5227)
	at clojure.core$load_lib.doInvoke(core.clj:5264)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:603)
	at clojure.core$load_libs.doInvoke(core.clj:5298)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:603)
	at clojure.core$require.doInvoke(core.clj:5381)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval1038.invoke(run-test9074553612640357429.clj:5)
	at clojure.lang.Compiler.eval(Compiler.java:6511)
	at clojure.lang.Compiler.load(Compiler.java:6952)
	at clojure.lang.Compiler.loadFile(Compiler.java:6912)
	at clojure.main$load_script.invoke(main.clj:283)
	at clojure.main$script_opt.invoke(main.clj:343)
	at clojure.main$main.doInvoke(main.clj:427)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.lang.Var.invoke(Var.java:415)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.Var.applyTo(Var.java:532)
	at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalAccessException: class clojure.lang.Reflector cannot access class com.sun.xml.internal.stream.XMLInputFactoryImpl (in module java.xml) because module java.xml does not export com.sun.xml.internal.stream to unnamed module @1704f67f
	at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base@9-ea/Reflection.java:405)
	at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base@9-ea/Reflection.java:396)
	at jdk.internal.reflect.Reflection.ensureMemberAccess(java.base@9-ea/Reflection.java:98)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(java.base@9-ea/AccessibleObject.java:355)
	at java.lang.reflect.AccessibleObject.checkAccess(java.base@9-ea/AccessibleObject.java:347)
	at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:525)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
	at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
	at clojure.data.xml.jvm.parse$make_stream_reader.invoke(parse.clj:116)
	at clojure.data.xml$event_seq.invoke(xml.clj:57)
	at clojure.data.xml$parse.doInvoke(xml.clj:67)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at clojure.core$comp$fn__4034.invoke(core.clj:2279)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3382)
	... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.133 s
[INFO] Finished at: 2016-05-27T17:48:41-04:00
[INFO] Final Memory: 13M/300M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.theoryinpractise:clojure-maven-plugin:1.3.13:test (clojure-test) on project data.xml: Clojure failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
tcrawley@katahdin ~/w/c/data.xml> java -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+119)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+119, mixed mode)


 Comments   
Comment by Toby Crawley [ 22/Nov/16 10:02 AM ]

This is caused by http://dev.clojure.org/jira/browse/CLJ-2066

Comment by Herwig Hochleitner [ 22/Nov/16 9:38 PM ]

Unless the reflector is fixed on time for a java 9 release, we'll have to work around this in data.xml by adding appropriate annotations to avoid reflection.

Comment by Alex Miller [ 07/Mar/17 3:29 PM ]

This can be reproduced with the following code:

(def fac (javax.xml.stream.XMLInputFactory/newInstance))
(.createXMLStreamReader fac (java.io.StringReader. ""))




[DXML-46] Reflection warnings in data.xml Created: 11/Jul/17  Updated: 11/Jul/17

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

Type: Defect Priority: Minor
Reporter: Michael Blume Assignee: Michael Blume
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File DXML-46-v1.patch    

 Description   
$ lein check
Compiling namespace clojure.data.xml.event
Reflection warning, clojure/data/xml/impl.clj:66:3 - call to java.lang.String ctor can't be resolved.
Compiling namespace clojure.data.xml.impl
Reflection warning, clojure/data/xml/impl.clj:66:3 - call to java.lang.String ctor can't be resolved.
Compiling namespace clojure.data.xml.jvm.emit
Compiling namespace clojure.data.xml.jvm.name
Compiling namespace clojure.data.xml.jvm.parse
Reflection warning, clojure/data/xml/jvm/parse.clj:131:5 - call to method createXMLStreamReader can't be resolved (target class is unknown).
Compiling namespace clojure.data.xml.jvm.pprint
Compiling namespace clojure.data.xml.name
Compiling namespace clojure.data.xml.node
Compiling namespace clojure.data.xml.process
Compiling namespace clojure.data.xml.protocols
Compiling namespace clojure.data.xml.prxml
Compiling namespace clojure.data.xml.pu-map
Compiling namespace clojure.data.xml.tree
Compiling namespace clojure.data.xml


 Comments   
Comment by Michael Blume [ 11/Jul/17 5:35 PM ]

Arguably the hint in b64-encode should be provided as a return hint in data.codec, but this seemed like the quicker fix.





[DXML-45] Support UTF-8 XML beginning with BOM Created: 27/Apr/17  Updated: 02/May/17

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

Type: Task Priority: Minor
Reporter: Jeff Wong Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


 Description   

It would be great to be able to parse UTF-8 encoded files beginning with a BOM byte order mark character, as it would give better native support for XML in the wild.

Currently, I'm having a few of these xml files throw a "content not allowed in prolog" exception:
http://stackoverflow.com/questions/4569123/content-is-not-allowed-in-prolog-saxparserexception



 Comments   
Comment by Herwig Hochleitner [ 02/May/17 9:46 AM ]

Following your stackoverflow link, this seems to be related to a couple of java bugs, that are marked as `wontfix` due to expectations of existing tools and the recommendation in the tickets is for applications to deal with the BOM themselves.

Since data.xml promises to process xml from raw bytes (because it accepts InputStreams), there is a choice: Either discontinue the InputStream interface and require users to pass Readers that correctly handle their input (e.g. https://commons.apache.org/proper/commons-io/javadocs/api-2.2/org/apache/commons/io/input/XmlStreamReader.html) or use a Reader implementation that can do so, when creating an input source from a stream.

For ease of maintenance, it's tempting to go with removing the byte-based interface, but I'm open to arguments to why data.xml should deal with this.

Comment by Jeff Wong [ 02/May/17 12:28 PM ]

This was more of a suggestion - After reading up about input and input streams, I can understand why this may be out of scope.

I was naive in thinking that handling input via a clojure.java.io/reader would be able to parse an xml file properly, as I was unaware of the BOM issues until I hit the exception. Even though the related JVM fix for BOMs would break backwards compatability and thus rejected, it would still be helpful if another underlying parsing library handled the input and BOMs.

At least consider adding a recommended list of readers for those unfamiliar with XML parsing in java. It is difficult to anticipate these kinds of gotchas for developers unfamiliar with BOMs, readers, and XML (such as myself), especially when the same files pass validation in other languages.





[DXML-41] README - applicability of xml-seq, xml-zip? Created: 12/Feb/17  Updated: 14/Feb/17

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

Type: Enhancement Priority: Minor
Reporter: Phill Wolf Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Clojure's core library includes clojure.xml and two other very useful functions evidently designed to work with data from clojure.xml: xml-seq and clojure.zip/xml-zip.

Is it intended that xml-seq and xml-zip work with data from clojure.data.xml and, in particular, its release-0.2 XML-namespace-related improvements?

Let's enhance the clojure.data.xml README to clarify whether, or to what degree, it should be OK to use clojure.data.xml with xml-seq and xml-zip.



 Comments   
Comment by Herwig Hochleitner [ 14/Feb/17 5:17 AM ]

I have used clojure.data.xml with xml-zip (as well as with clojure.data.zip.xml) and it worked as expected. I'd expect the same from xml-seq.

We should verify this behavior in the test suite and announce it in the readme.
Patches welcome.





[DXML-40] README FileWriter example fails if platform default encoding is not UTF-8 Created: 12/Feb/17  Updated: 12/Feb/17

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

Type: Enhancement Priority: Minor
Reporter: Phill Wolf Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


 Description   

README.md illustrates writing an XML file with java.io.FileWriter. Therefore the example works only if the Java platform's default encoding is UTF-8. Suggestion: The README would present a more widely usable technique by using clojure.java.io/writer, whose default encoding is UTF-8 everywhere.

Sample program using the README example:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns garble
  (:require [clojure.data.xml :refer [element emit]]))
(defn -main
  "Tries to write an XML file"
  []
  (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))))

Invocation 1 (overriding Java's default encoding because Java is inclined to use UTF-8 on my computer):

java -cp ... -Dfile.encoding=US-ASCII clojure.main -m garble

Result:

java.lang.Exception: Output encoding of stream (UTF-8) doesn't match declaration (ASCII)

Invocation 2:

java -cp ... -Dfile.encoding=UTF-8 clojure.main -m garble

Result: successfully writes /tmp/foo.xml






[DXML-22] Adding hiccup generation function for elements Created: 24/Feb/14  Updated: 07/Dec/16

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

Type: Enhancement Priority: Minor
Reporter: Chris Zheng Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

N/a



 Description   

This is for completeness really. See pull request https://github.com/clojure/data.xml/pull/10

I would like to:

  • generate an element using hiccup (already exists)
  • generate hiccup using an element (proposed)


 Comments   
Comment by Chris Zheng [ 28/Mar/14 7:22 AM ]

I'm hoping someone can at least give some feedback to this ticket.

Comment by Ryan Senior [ 28/Mar/14 7:53 AM ]

Hi Chris,

Thanks for the reminder on this. I'll have more time to dig in this weekend, but off the top of my head I think more will need to be done on this, both on implementation and on testing. I think what you have now won't work with comments or cdata. One way to flesh some of that out is to create round trip types of tests in src/test/clojure/clojure/data/xml/test_sexp.clj.





Generated at Sat Jul 29 06:54:57 CDT 2017 using JIRA 4.4#649-r158309.