-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Using JAXP on XMLPrinter implementation #4166
Conversation
Replace "manual" generation of XML by use of JAXP API. The test cases were replaced as well so they now check for XML document equality instead of string equality.
What does that codecov fail mean? It seems it's not related to the code in the commits, but related to some bug in codecov. Is it possible to rerun that specific check? |
} | ||
} | ||
|
||
public Document getDocument(String xml) throws SAXException, IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no need to close the inputStream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per JavaDoc, closing a ByteArrayInputStream has no effect.
} | ||
|
||
public StringWriter stringWriterOutput(Node node, String name) { | ||
StringWriter stringWriter = new StringWriter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine that this method allows you to implement data streaming in a file, perhaps you can specify in javadoc that the resource returned by the method must be closed by the user?
Thank you for this interesting development. There are some outstanding questions and it seems to me that it would be interesting to add some comments to clarify the intentions of certain added methods. A few additional unit test cases would also be welcome to illustrate the use of the new methods and more particularly the data streaming that you mention. |
you are right it's not related to the code. |
I've made minor changes and added documentation as well as additional tests. Also, I've made changes in small dedicated commits hoping that will make the revision easier. |
No need to worry about which charset is used, as the same is going to be used for saving and loading.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4166 +/- ##
===============================================
+ Coverage 57.975% 57.985% +0.009%
Complexity 2334 2334
===============================================
Files 645 645
Lines 34535 34576 +41
Branches 5981 5976 -5
===============================================
+ Hits 20022 20049 +27
- Misses 12354 12369 +15
+ Partials 2159 2158 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
Thank you for this contribution. |
Fixes #2749
The original implementation "manually" generates XML and does not take care of special cases, when illegal characters are present on attribute values. The proposed solution avoid the "manual" generation of XML, by using JAXP API for outputing XML structure.
Also, instead of generating the complete XML string in memory, user of XMLPrinter has now the option of streaming data directly to an output file, by using public methods of the class.