<< Back to previous view

[DXML-25] Emit Empty Elements using EmptyElementTag Created: 09/Jul/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: Alexander Kiel Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: enhancement, patch
Environment:

Does not apply


Patch: Code and Test

 Description   

Currently data.xml emits empty elements (elements without content) using start and end tags. The XML spec also allows special empty tags like <foo/>.

I need to serialize XML using such special empty tags because a device, I want to communicate with, does require empty tags. The device is just not able to parse XML messages using start and end tags.

I created a branch on GitHub where I implemented empty tags in the emit function. I'm not familiar how to create a patch. So for now here is the link to the compare view.

As I wrote in my commit message we should discuss, whether a option to the emit function would be a better solution.



 Comments   
Comment by Herwig Hochleitner [ 03/Oct/16 6:42 PM ]

I think, this is a worthwhile change, not because we want to support broken xml receivers, but because some xml dialects lean heavily on lots of attr-only tags for byte savings, even going so far as to encode whole polymorphic data structures in attr string values, as seen in svg.

For that reason, of not wanting to take on complexity arising from broken receivers, I'd vote against an emitter flag.

Would you be willing to sign a contributor's agreement and rebase your changes?





[DXML-29] ClojureScript support Created: 13/Nov/15  Updated: 07/Dec/16  Resolved: 07/Dec/16

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

Type: Enhancement Priority: Minor
Reporter: Artem Yarulin Assignee: Herwig Hochleitner
Resolution: Completed Votes: 0
Labels: None


 Description   

Parsing XML(and HTML) is very often task and currently it requires a lot of effort and use of different libraries and wrappers around JS libs.

We can dramatically simplify it if we migrate data.xml to ClojureScript.

I'm maintaining koh library which has proof-of-concept XML support for Node and Browsers https://github.com/artemyarulin/koh/blob/master/src/koh/xml.cljs

The general idea is that we can utilise DOMParser object in order to parse string to XML tree. It has a decent browser support https://developer.mozilla.org/en-US/docs/Web/API/DOMParser and has a NodeJS implementation which follows the same API https://github.com/jindw/xmldom

What do you think about this feature?
I can pretty much follow the same guidelines from http://dev.clojure.org/jira/browse/DZIP-5 and implement it in the same way

Thanks



 Comments   
Comment by Herwig Hochleitner [ 04/Aug/16 2:40 PM ]

I'm working on clojurescript support in a separate branch: https://github.com/clojure/data.xml/tree/cljs
It can extend browser-native DOM objects to work with clojure data protocols.
Let me know what you think.

Comment by Artem Yarulin [ 05/Aug/16 4:18 AM ]

Oh, that's super cool! If you need any testing - feel free to ping me, I'll be happy to help

Comment by Herwig Hochleitner [ 08/Aug/16 1:37 PM ]

Thanks for the offer! In fact, the clojurescript support is in a testable state right now and I'm utilizing it for a cljs webdav library: https://github.com/webnf/davstore/blob/master/src/server/webnf/davstore/dav/xml.cljc

The main thing preventing it from being ready is, that I've utilized .cljc and reader tags. As of my last information, our CI doesn't support .cljc yet, for the test matrix and also it's unclear how to target clojure versions < 1.7

I'd be happy to the clojurescript support tested, though. We can still copy+paste into separate clj and cljs files, when we decide to release, if cljc support for contrib projects isn't ready by then.

Comment by Herwig Hochleitner [ 07/Dec/16 9:48 PM ]

will be released as part of 0.2.0-alpha1





[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.





[DXML-13] Support for preserving whitespace between tags Created: 10/Feb/13  Updated: 07/Dec/16

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

Type: Enhancement Priority: Major
Reporter: Kevin Albrecht Assignee: Herwig Hochleitner
Resolution: Unresolved Votes: 3
Labels: None

Attachments: Text File DXML-13.patch    

 Description   

XML parsers can support preserving white space nodes, but clojure.data.xml does not seem to support this functionality.

For example, the following should be able to return true (perhaps with an option to parse-str):

Desired Behavior
(= (clojure.data.xml/element :x {}
                             (clojure.data.xml/element :a {} "foo")
                             " "
                             (clojure.data.xml/element :a {} "bar"))
   (clojure.data.xml/parse-str
     (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
          "<x>"
          "<a>foo</a>"
          " "
          "<a>bar</a>"
          "</x>")))
;=> true

This is the current behavior:

Current Behavior
(= (clojure.data.xml/element :x {}
                             (clojure.data.xml/element :a {} "foo")
                             (clojure.data.xml/element :a {} "bar"))
   (clojure.data.xml/parse-str
     (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
          "<x>"
          "<a>foo</a>"
          " "
          "<a>bar</a>"
          "</x>")))
;=> true


 Comments   
Comment by Aron Nopanen [ 18/Aug/13 3:49 PM ]

Seconded.

The issue lies with the '.isWhiteSpace' check in this section of function pull-seq:

XMLStreamConstants/CHARACTERS
(if-let [text (and (not (.isWhiteSpace sreader))
(.getText sreader))]
(cons (event :characters nil nil text)
(pull-seq sreader))
(recur))

While the 'props' argument to parse/parse-str currently only holds XMLInputFactory options, perhaps a ':maintain-whitespace' option could be added that affects this behavior? It would be straightforward to pass the props into pull-seq to conditionally perform the .isWhiteSpace check.

Comment by Aron Nopanen [ 20/Aug/13 12:47 AM ]

I have attached a patch to support a :maintain-whitespace property to parse and parse-str. If set to 'true', whitespace-only nodes will not be stripped during the parsing process.

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

Hi Aron,

Thanks for the patch. Have sent in a contributor agreement? I didn't see you name here: http://clojure.org/contributing. Submitting patches to Clojure contrib libraries requires this.

Comment by Jason Gilman [ 08/Apr/14 6:51 AM ]

I'm running into this problem as well. Can this be fixed without using the contributed patch?

Comment by Jan-Paul Bultmann [ 15/Dec/14 5:15 PM ]

Aron Nopanen, the author of the patch is now in the contributors list after signing the agreement.
Is it still applicable or does it have to be adapted due to its age?

Comment by Jan-Paul Bultmann [ 09/Jan/15 8:28 AM ]

It seems that this is already resolved in Herwig's implementation.

So resolving DXML-4 will resolve this issue as well.

Comment by Herwig Hochleitner [ 03/Oct/16 6:09 PM ]

Taking a look. This is still present, after landing DXML-4. I'd be willing to get behind a :preserve-whitespace flag, but we need to take xml:space attributes into consideration. How should those interact with our flag?





[DXML-35] clojure.data.xml/indent should append a newline after the xml preamble Created: 18/Sep/16  Updated: 07/Dec/16

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

Type: Defect Priority: Minor
Reporter: Hans Hübner Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

clojure.data.xml 0.1.0-beta2



 Description   

Currently, indent and indent-str put the root element directly behind the preamble, without separating the two with a newline. This should be changed so that a newline is inserted.






[DXML-37] data.xml dependency resolution fails for v0.2.0-alpha1 Created: 07/Dec/16  Updated: 07/Dec/16

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

Type: Defect Priority: Major
Reporter: Jaseem V V Assignee: Herwig Hochleitner
Resolution: Unresolved Votes: 0
Labels: dependencies, documentation
Environment:

Operating System: All
Build: Leiningen



 Description   

Dependency resolution fails for latest version of data.xml from maven repository. The github page shows the following [org.clojure/data.xml "0.2.0-alpha1"] info but the maven repository does not have that version. The latest available from maven is v0.1.0-beta3. The jar is not showing in clojars as well.

Please add the jar to maven repository.



 Comments   
Comment by Herwig Hochleitner [ 07/Dec/16 5:50 AM ]

0.2.0-alpha1 is not yet released. I pushed a couple of commits while tinkering with jenkins, unfortunately, one was the readme update for the upcoming 0.2.0-alpha1





Generated at Sun Dec 11 02:07:17 CST 2016 using JIRA 4.4#649-r158309.