ixml parser: keep a line feed inside a value - #1225
Merged
Merged
Conversation
if_ixml_parser~parse removed every literal LF from the document before it tokenized it, so a value with a line break came back as one line - a string does not survive `CALL TRANSFORMATION id` and the parse back, and nothing writes a LF as a character reference either. The strip is not needed: the loop already skips whitespace between tags (SHIFT ... DELETING LEADING, and get_simple_spaces_for_cur_cp contains newline and CR), so removing it leaves the document structure as it was and keeps the LF where it belongs - in the text node. Tests: the asXML roundtrip of a two-line value, and the parser keeping the LF in a text node. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKSWLpid4QLV6XWAoPixbb
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.
What is wrong
if_ixml_parser~parseremoves every literal line feed from the documentbefore it starts tokenizing,
src/ixml/cl_ixml.clas.locals_imp.abap:A LF is not markup, it is character data, so the strip also hits the text
nodes. Nothing writes a LF as a character reference on the way out either
(
lcl_data_to_xml=>escape_textwrites&,<and>, added in #1193, andleaves the LF as it is), so there is no form in which a line break survives
the document.
The visible effect is the asXML roundtrip: a two-line value comes back as one
line.
The change
The strip is not needed. The parse loop already skips the whitespace between
tags itself, at the end of every iteration:
and
lv_whitespaceiscl_abap_char_utilities=>get_simple_spaces_for_cur_cp( ),which contains
newlineand the CR. So a pretty-printed document is readexactly as before — the indentation is dropped because it is whitespace
between tags, not because a LF was removed from the string. What changes is
only the text node: the line break stays where a system keeps it.
One line removed. The write side is untouched — a LF is legal raw in character
data, so no escaping is added and every value serializes byte for byte as it
does today.
Tests
kernel_call_transformation:newline_roundtrip— the two-line value above,through
CALL TRANSFORMATION idand backcl_ixml:parse_value_with_newline— the parser keeps the LF in the#textnodeThe two existing tests that cover this area,
root_element_after_crlfandfirst_child_after_crlf, are unchanged and still pass.npm testis green:abaplint: 0 issue(s) found, 735 file(s) analyzed, andthe full unit run passes.
Why it matters downstream
abap2UI5 is stateless per request: the app instance — every attribute of the
app class, including the strings bound to a TextArea — is serialized with
CALL TRANSFORMATION idinto the draft and parsed back on the next request(
z2ui5_cl_ui5_util_context=>xml_stringify/xml_parse). On the transpiledbackend that means the user types two lines and the next request has one.
abap2UI5 carries a local pre-transpile patch for this today; with this merged
the last one goes away.