Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Prevent Simple Transformation from unescaping SOURCE XML

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,324

Hello,
I have XML string + Simple Transformation like this:

... <tag1 att1="& lt; text"> ...
... <tt:cond><tt:attribute name="att1" value-ref="ATT1_VALUE"/></tt:cond> ...

And the problem is that after CALL TRANSFORMATION I get unescaped value in ABAP field:
ATT1_VALUE = "< text"
but I want:
ATT1_VALUE = "& lt; text"

Code example:

CALL TRANSFORMATION zsimple_transformation
        SOURCE XML i_xml_string "UTF-8 string

Is there a easy way how to get value as it is (escaped)?

EDIT: There will be probably problem showing & lt ; (without spaces) and < in sap forum. I will edit afterwards and try add spaces. I hope you get what I mean...

-- Tomas --
1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,126

What you get in the ABAP variable (< text) is not an error, it's actually the correct value, it corresponds "exactly" to what is in the XML.

If you want & lt; text in the ABAP variable, you have to change the original XML attribute value to & amp; lt; text or use <![CDATA[& lt; text]]>

Hello,
I have XML string + Simple Transformation like this:

... <tag1 att1="& lt; text"> ...
... <tt:cond><tt:attribute name="att1" value-ref="ATT1_VALUE"/></tt:cond> ...

And the problem is that after CALL TRANSFORMATION I get unescaped value in ABAP field:
ATT1_VALUE = "< text"
but I want:
ATT1_VALUE = "& lt; text"

Code example:

CALL TRANSFORMATION zsimple_transformation
        SOURCE XML i_xml_string "UTF-8 string

Is there a easy way how to get value as it is (escaped)?

EDIT: There will be probably problem showing & lt ; (without spaces) and < in sap forum. I will edit afterwards and try add spaces. I hope you get what I mean...

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,127

What you get in the ABAP variable (< text) is not an error, it's actually the correct value, it corresponds "exactly" to what is in the XML.

If you want & lt; text in the ABAP variable, you have to change the original XML attribute value to & amp; lt; text or use <![CDATA[& lt; text]]>

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
1,126

sandra.rossi Thank you. You are right and I got to the same conclusion. If you please convert / copy it as an answer I will accept it 🙂

The value after TRANSFORMATION is correct and my problem is later in the process where we are sending this value in different XML (and there is actually missing escape XML value functionality, which makes second XML invalid).

-- Tomas --