<< Back to previous view

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

Status: Open
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: Unresolved Votes: 0
Labels: bug


 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.






[DXML-27] Element java.util.Date throws IllegalArgumentException Created: 15/Jun/15  Updated: 15/Jun/15

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

Type: Defect Priority: Major
Reporter: Adam Neilson Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: bug
Environment:

Clojure version 1.7
data.xml 0.8
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)



 Description   

This seems very similar to DXML-14 but given the lib has been in the wild a while I would have expected this to have been reported already. Can't find a bug report though so submitted here for the record.

I ran this the first time and it seemed fine but all subsequent executions result in this error:

(emit-str (element :something {} #inst "2015-06-15T16:53:18.470-00:00"))
IllegalArgumentException No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: java.util.Date  clojure.core/-cache-protocol-fn (core_deftype.clj:544)


 Comments   
Comment by Adam Neilson [ 15/Jun/15 12:18 PM ]

Actually clojure version is 1.6.0





[DXML-15] data.xml can't parse own output if there's a colon in an attribute name Created: 03/Apr/13  Updated: 03/Apr/13

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

Type: Defect Priority: Major
Reporter: ben wolfson Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None
Environment:

data.xml 0.0.7



 Description   

Observe:

> (x/emit-str (x/element :NC {"xmlns" "http://example.com" "xmlns:xsi" "http://www.w3.org/2001/XMLSchema-instance" "xsi:schemaLocation" "http://www.example.com/schema.xsd"} (x/element :Foo {} "bar")))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><NC xsi:schemaLocation=\"http://www.example.com/schema.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://example.com\"><Foo>bar</Foo></NC>"
> (x/parse-str *1)
#clojure.data.xml.Element{:tag :NC, :attrs {:xsi/schemaLocation "http://www.example.com/schema.xsd"}, :content (#clojure.data.xml.Element{:tag :Foo, :attrs {}, :content ("bar")})}
a> (x/emit-str *1)
XMLStreamException Prefix cannot be null com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute (XMLStreamWriterImpl.java:574)
app.services.external.experian.internal.test-data>

(a) the xmlns and xmlns:xsi attributes have disappeared. Not the point of this issue but worth pointing out.
(b) "xsi:schemaLocation" has become :xsi/schemaLocation
(c) emitting a string blows up.






[DXML-13] Support for preserving whitespace between tags Created: 10/Feb/13  Updated: 09/Jan/15

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

Type: Enhancement Priority: Major
Reporter: Kevin Albrecht Assignee: Ryan Senior
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.





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

Status: Open
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: Unresolved Votes: 2
Labels: None

Attachments: XML File web.xml    

 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.






Generated at Fri May 27 13:26:06 CDT 2016 using JIRA 4.4#649-r158309.