Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ixml/cl_ixml.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ CLASS lcl_parser IMPLEMENTATION.
lv_xml = lv_xml+1.
ENDIF.

REPLACE ALL OCCURRENCES OF |\n| IN lv_xml WITH ||.
* newline handling: whitespace between tags is skipped below, a LF inside a value is kept

WHILE lv_xml IS NOT INITIAL.
CLEAR lo_node.
Expand Down
16 changes: 16 additions & 0 deletions src/ixml/cl_ixml.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CLASS ltcl_xml DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
METHODS parse_basic FOR TESTING RAISING cx_static_check.
METHODS root_element_after_crlf FOR TESTING RAISING cx_static_check.
METHODS first_child_after_crlf FOR TESTING RAISING cx_static_check.
METHODS parse_value_with_newline FOR TESTING RAISING cx_static_check.
METHODS parse_bom FOR TESTING RAISING cx_static_check.
METHODS parse_empty FOR TESTING RAISING cx_static_check.
METHODS parse_namespace FOR TESTING RAISING cx_static_check.
Expand Down Expand Up @@ -458,6 +459,21 @@ CLASS ltcl_xml IMPLEMENTATION.

ENDMETHOD.

METHOD parse_value_with_newline.

DATA lv_xml TYPE string.
DATA li_root TYPE REF TO if_ixml_element.

lv_xml = |<root><item>a\nb</item></root>|.

li_root = parse( lv_xml )->get_root_element( ).

cl_abap_unit_assert=>assert_equals(
act = li_root->get_first_child( )->get_value( )
exp = |a\nb| ).

ENDMETHOD.

METHOD parse_bom.

DATA lv_bom TYPE c LENGTH 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ CLASS ltcl_call_transformation DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATI
METHODS escape_char_data FOR TESTING RAISING cx_static_check.
METHODS escape_char_data_roundtrip FOR TESTING RAISING cx_static_check.
METHODS escape_entity_text_roundtrip FOR TESTING RAISING cx_static_check.
METHODS newline_roundtrip FOR TESTING RAISING cx_static_check.
METHODS to_string_simple FOR TESTING RAISING cx_static_check.
METHODS to_string_empty FOR TESTING RAISING cx_static_check.
METHODS to_string_array FOR TESTING RAISING cx_static_check.
Expand Down Expand Up @@ -336,6 +337,32 @@ CLASS ltcl_call_transformation IMPLEMENTATION.
exp = 'literal &lt; entity' ).
ENDMETHOD.

METHOD newline_roundtrip.
* a line break inside a value must survive the roundtrip
DATA lv_xml TYPE string.
DATA lv_exp TYPE string.
DATA: BEGIN OF ls_data,
field TYPE string,
END OF ls_data.

lv_exp = |a{ cl_abap_char_utilities=>newline }b|.
ls_data-field = lv_exp.

CALL TRANSFORMATION id
SOURCE data = ls_data
RESULT XML lv_xml.

CLEAR ls_data.

CALL TRANSFORMATION id
SOURCE XML lv_xml
RESULT data = ls_data.

cl_abap_unit_assert=>assert_equals(
act = ls_data-field
exp = lv_exp ).
ENDMETHOD.

METHOD convert_json_to_sxml.
DATA lo_writer TYPE REF TO cl_sxml_string_writer.
lo_writer = cl_sxml_string_writer=>create( ).
Expand Down