Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrettyPrinter adds empty attribute with xmlns #28

Merged
merged 2 commits into from
Dec 3, 2014

Conversation

ashawley
Copy link
Member

An element with an xmlns attribute gets converted to a string correctly, but using the pretty printer to convert the XML to a string adds an extra, empty attribute. I have no insight on how to fix the pretty printer.

There is a failing unit test provided by this pull request that can reproduce this issue:

[error] Test scala.xml.XMLTest.issue28 failed: expected:<...x:foo xmlns:x="gaga"[]/>> but was:<...x:foo xmlns:x="gaga"[ xmlns=""]/>>
:9:19: '/' expected instead of ''                  ^
:9:19: name expected, but char '' cannot start a name                  ^

@ashawley ashawley force-pushed the pretty-print-ns-defect branch from 232439e to 6dfc129 Compare September 15, 2014 13:00
ashawley added a commit to ashawley/scala-xml that referenced this pull request Sep 15, 2014
	* src/test/scala/scala/xml/XMLTest.scala (issue28): New unit test
@adriaanm
Copy link
Contributor

adriaanm commented Dec 3, 2014

Thanks for the test case! Even better than a bug report :-) I hope a fix will come forth! (I don't have any insights here either, unfortunately.)

	* src/test/scala/scala/xml/XMLTest.scala (issue28): New unit test
@ashawley ashawley force-pushed the pretty-print-ns-defect branch from 6dfc129 to c1e8e96 Compare December 3, 2014 19:01
ashawley added a commit to ashawley/scala-xml that referenced this pull request Dec 3, 2014
@ashawley
Copy link
Member Author

ashawley commented Dec 3, 2014

@adriaanm Looks like it might be an improper use of null as a default argument. Should it be TopScope instead? I'm not familiar with the code base to know for sure, nor whether other references to null in the formatter should be fixed as well.

	* src/main/scala/com/jonasboner/PrettyPrinter.scala (format):
	Modify namespace binding default argument to TopScope, was null.
@ashawley ashawley force-pushed the pretty-print-ns-defect branch from c1e8e96 to a53d11c Compare December 3, 2014 19:09
@adriaanm
Copy link
Contributor

adriaanm commented Dec 3, 2014

We're about to find out thanks to Travis :-)

@adriaanm
Copy link
Contributor

adriaanm commented Dec 3, 2014

Cool! Could you ping one of the other recent PR submitters to get a second opinion? I really have no clue about namespacing in xml.

@ashawley ashawley changed the title Unit test for #28 PrettyPrinter adds empty attribute with xmlns PrettyPrinter adds empty attribute with xmlns Dec 3, 2014
@ashawley
Copy link
Member Author

ashawley commented Dec 3, 2014

@bartschuller, Any interest in reviewing a fix for the defect where the PrettyPrinter makes an empty namespace attribute? @adriaanm wants a second opinion

<x:foo xmlns:x="bar" xmlns="" />

@bartschuller
Copy link

I agree, In XML with namespaces you sometimes need to invent xmlns attributes, but this is not such a case. Expected behavior here is that what you put in is what you get out.

@adriaanm
Copy link
Contributor

adriaanm commented Dec 3, 2014

Thank you both! Very happy to see such quick turnaround (sorry I was the blocking factor here -- happy to take myself out of the loop if someone would like to step up and manage pull requests).

adriaanm added a commit that referenced this pull request Dec 3, 2014
PrettyPrinter adds empty attribute with xmlns
@adriaanm adriaanm merged commit e03e68e into scala:master Dec 3, 2014
@adriaanm adriaanm modified the milestone: 1.0.3 Dec 4, 2014
@ashawley ashawley deleted the pretty-print-ns-defect branch August 10, 2015 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants