Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix issue #5697 by exporting
#xmlComment
elements when callingexport/3
orexport_simple/3
and similar functions.If we want to preserve the original document formatting, this will be impossible to solve only from the export side. The
xmerl_scan
functions strip white space after comments when creating the element records, and the original text elements are lost.Top level comments like the example in #5697 will only be exported if we create and export as a document. There is no function to export an
#xmlDocument
directly, could be a possible enhancement.The callback module
xmerl_xml_indented
doesn't indent properly if input data has text elements used for indentation. I allow for indentation of comments like the example in test 45formatter_pass
where there is no indentation in the input. I updated the test case to insert the newly exported comment.I tried to implement an alternative PR that preserves formatting by changing
xmerl_scan
to not strip white space after comments. These would be read as extra text elements. Unfortunately this breaks more than 60 unit tests, mostly related to DTD validation. It would be a larger PR and introduce more risk of breaking something. I didn't have time to investigate a solution for this alternative to work.