<< Back to previous view

[DXML-31] Parsed events cannot be emitted Created: 28/Mar/16  Updated: 29/Aug/16  Resolved: 28/Aug/16

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

Type: Defect Priority: Trivial
Reporter: Hans Hübner Assignee: Ryan Senior
Resolution: Not Reproducible Votes: 0
Labels: None
Environment:

Clojure 1.7



 Description   

Events parsed with clojure.data.xml/source-seq cannot be serialized with clojure.data.xml/emit-event because the former puts characters parsed from XML elements into the `:characters` key of the events returned, but the latter expects them to be under the `:chars` key. I would propose that emit-event is changed so that it accepts both `:chars` and `:characters` as key for characters to be serialized, as that will provide the required backwards compatiblity.



 Comments   
Comment by Ryan Senior [ 28/Aug/16 1:35 PM ]

I believe this has been fixed when the namespace related changes came in. Try it again with 0.1.0-beta1 or higher and reopen if it's still an issue.

Comment by Hans Hübner [ 29/Aug/16 6:21 AM ]

Writing that it is "fixed" is a nice way of saying that the functionality has been removed altogether





[DXML-33] No XML namespace attribute emitted for namespaced sibling elements Created: 18/Jun/16  Updated: 28/Aug/16  Resolved: 28/Aug/16

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

Type: Defect Priority: Major
Reporter: David Bürgin Assignee: Ryan Senior
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-DXML-33-fix-emit-of-generated-prefixes.patch    

 Description   

Following namespaced sibling elements don't get an XML namespace attribute when emitting XML using data.xml.

(xml/declare-ns
  :example.a "http://example.org/a"
  :example.b "http://example.org/b")

(def example-element
  (xml/sexp-as-element
    [:example.a/outer
     [:example.b/inner-1]
     [:example.b/inner-2]]))

Emitting example-element with emit-str results in the following invalid XML (reformatted):

<?xml version="1.0" encoding="UTF-8"?>
<a:outer xmlns:a="http://example.org/a">
  <b:inner-1 xmlns:b="http://example.org/b"></b:inner-1>
  <b:inner-2></b:inner-2>
</a:outer>

This issue may be related to DXML-30.



 Comments   
Comment by David Bürgin [ 18/Jun/16 12:11 PM ]

The work-around I found is to declare the prefixes for all namespace URIs in the root element:

(def example-element
  (xml/sexp-as-element
    [:example.a/outer
     {:xmlns/ea "http://example.org/a"
      :xmlns/eb "http://example.org/b"}
     [:example.b/inner-1]
     [:example.b/inner-2]]))

Perhaps also to consider in this issue: sometimes redundant XML namespace attributes are emitted, when they could be pulled up into a parent element instead.

(xml/emit-str
  (xml/sexp-as-element
    [:example.a/outer
     [:example.b/inner-1
      [:example.c/innermost-1]]
     [:example.c/inner-2]]))
<?xml version="1.0" encoding="UTF-8"?>
<a:outer xmlns:a="http://example.org/a">
  <b:inner-1 xmlns:b="http://example.org/b">
    <c:innermost-1 xmlns:c="http://example.org/c"></c:innermost-1>
  </b:inner-1>
  <d:inner-2 xmlns:d="http://example.org/c"></d:inner-2>
</a:outer>

Though to be sure this output is valid, so perhaps this part works as designed.

Comment by Herwig Hochleitner [ 04/Aug/16 5:16 AM ]

It works as designed. The emitter doesn't auto - pull-up namespaces, because that would require a second pass over the tree, while data.xml is designed to be stream-able. Use clojure.data.xml.process/aggregate-xmlns if you want that extra pass to clean up xmlns.

*EDIT* No, the sibling element part doesn't work as designed, investigating ...

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

I've fixed a bug in the emitter state handling, which I believe should fix the issue. Please try the attached patch.

Comment by David Bürgin [ 05/Aug/16 3:39 AM ]

Thank you. With the patch, the output is now valid:

<?xml version="1.0" encoding="UTF-8"?>
<a:outer xmlns:a="http://example.org/a">
  <b:inner-1 xmlns:b="http://example.org/b"></b:inner-1>
  <c:inner-2 xmlns:c="http://example.org/b"></c:inner-2>
</a:outer>
Comment by Ryan Senior [ 28/Aug/16 1:33 PM ]

The patch hs been applied and will be included in the 0.1.0-beta2 release.





[DXML-30] Generate inconsistent namespace prefixes for subtrees, randomly omit namespace URIs in non-prefixed elements Created: 20/Jan/16  Updated: 28/Aug/16  Resolved: 28/Aug/16

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

Type: Task Priority: Major
Reporter: Vlad Kozin Assignee: Ryan Senior
Resolution: Completed Votes: 1
Labels: bug

Attachments: Text File 0002-DXML-30-fix-emit-of-default-namespaces.patch    

 Description   
Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(xml/indent-str (xml/parse-str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
            <tradeDocument xmlns=\"http://www.fpml.org/FpML-5/confirmation\">
               <trade>Some trade</trade>
               <party>Party1</party>
               <party>Party2</party>
            </tradeDocument>"))

SAXParseException The prefix "b" for element "b:party" is not bound. com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (AbstractSAXParser.java:1239)

To see clearly what's wrong:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(println (xml/emit-str (xml/parse-str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
            <tradeDocument xmlns=\"http://www.fpml.org/FpML-5/confirmation\">
               <trade>Some trade</trade>
               <party>Party1</party>
               <party>Party2</party>
            </tradeDocument>")))

run through external formatter to see the problem

Unable to find source-code formatter for language: shell. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
$ pbpaste | xmllint --format - 
-:1: namespace error : Namespace prefix b on party is not defined
e xmlns:b="http://www.fpml.org/FpML-5/confirmation">Some trade</b:trade><b:party
                                                                               ^
-:1: namespace error : Namespace prefix b on party is not defined
l.org/FpML-5/confirmation">Some trade</b:trade><b:party>Party1</b:party><b:party
                                                                               ^
<?xml version="1.0" encoding="UTF-8"?>
<a:tradeDocument xmlns:a="http://www.fpml.org/FpML-5/confirmation" xmlns="http://www.fpml.org/FpML-5/confirmation">
  <b:trade xmlns:b="http://www.fpml.org/FpML-5/confirmation">Some trade</b:trade>
  <b:party>Party1</b:party>
  <b:party>Party2</b:party>
</a:tradeDocument>

Obvious problem here: no namespace URI is defined on <party> elements hence the error.

More general problem: input provided defines a default namespace so any non-prefixed tag is assumed to come from such namespace. I think a user can reasonably expect a roundtrip through parse/emit to not mess with that and preserve default namespace and therefore not introduce prefixes. Current behavior may not be wrong technically, but it is baffling and unexpected.



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

Fixed on top of 0001-DXML-33-fix-emit-of-generated-prefixes.patch

Comment by Ryan Senior [ 28/Aug/16 1:32 PM ]

The patch hs been applied and will be included in the 0.1.0-beta2 release.





[DXML-10] Support for DOCTYPE when emitting XML Created: 14/Nov/12  Updated: 28/Aug/16  Resolved: 28/Aug/16

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

Type: Enhancement Priority: Major
Reporter: Thomas Greve Kristensen Assignee: Ryan Senior
Resolution: Completed Votes: 3
Labels: None

Attachments: Text File DXML-10-Add-support-for-doctype-declarations.patch     XML File web.xml    
Patch: Code and Test

 Description   

Some consumers of XML files require an explicit DOCTYPE to accept an XML file. data.xml does not currently support the specification of doctypes when emitting XML. When XML is parsed, I believe DOCTYPEs are silently ignored, so there is no representation in the data model for them. The best design is possibly an :doctype option in clojure.data.xml/emit ?

I've attached a web.xml as example.



 Comments   
Comment by Christian Egli [ 04/Jul/16 9:15 AM ]

Patch that adds support for doctype declarations when emitting XML

Comment by Christian Egli [ 23/Aug/16 7:41 AM ]

Is there anything I can do to move this issue forward? I have a local hack around this issue which prevents me from upgrading org.clojure/data.xml. OTOH I really need the new namespace support, so a new version containing both the namespace and the DOCTYPE support would be fantastic.

Thanks

Comment by Ryan Senior [ 28/Aug/16 1:31 PM ]

Thanks for the patch! This has been applied and will be included in beta2 (which will be released soon)





Generated at Tue Aug 30 10:00:30 CDT 2016 using JIRA 4.4#649-r158309.