Handle well-indented XML including comments#795
Merged
Conversation
The root cause for #782 was misuse of xmerl_scan:string/2, which doesn't emit spaces, comments between actual xml elements. It leaves them as #xmlText{} and #xmlComment{} - This commit changes to ignore them at walking around parsed dom tree. This diffset also includes a small refactoring that wraps all xmerl_scan:string/2 to one riak_cs_xml funcsion to control its usage. This also adds regression test as simple eunit test case. Conflicts: src/riak_cs_acl_utils.erl src/riak_cs_s3_response.erl
Contributor
There was a problem hiding this comment.
Really nitpicky, but why assign this to Xml, instead of just returning the string?
Contributor
Author
There was a problem hiding this comment.
Without binding Xml the indentation by erlang-mode.el becomes like this:
"<!-- comments here --> <AccessControlPolicy> <!-- comments here -->"
" <Owner> <!-- blah blah blah -->"
" <ID>eb874c6afce06925157eda682f1b3c6eb0f3b983bbee3673ae62f41cce21f6b1</ID>"
" <!-- c --> <DisplayName>admin</DisplayName> <!--"
" \n --> </Owner>"Also it's easy to put some ~p to do some formatting like io_lib:format(Xml, [ Blah, Blah, ... ]) for future improvement. Yes, I was trying that.
Contributor
|
Tests, code and manual testing all pass. +1 |
kuenishi
added a commit
that referenced
this pull request
Feb 8, 2014
Handle well-indented XML including comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The root cause for #782 was misuse of xmerl_scan:string/2, which doesn't emit spaces, comments between actual xml elements. It leaves them as #xmlText{} and #xmlComment{} - This commit changes to ignore them at walking around parsed dom tree. This diffset also includes a small refactoring that wraps all xmerl_scan:string/2 to one riak_cs_xml funcsion to control its usage.
This also adds regression test as simple eunit test case.
backport of #793