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

XML space tag problem in XML simple transformation de-serialization

Rajesh_Amirinen
Explorer
0 Likes
2,251


Dear friends,

I have a problem while converting xml file into internal table (de-serialization) using simple transformation.

there is a tag like <tag> </tag> and I am using condition to check whether tag consist data or not.

because of the space value in the tag I am getting an exception 'CX_ST_COND_CHECK_FAIL' during the condition check.

before deserialization, i am removing empty tags from the xml by using below statement.

REPLACE ALL OCCURRENCES OF REGEX '<\w+/>' IN l_string WITH ''.

but because the tag has the space value it is not getting removed from the XML.

and i am using below code to check is there any tag with empty value. at this condition, because of space value

i am getting the exception  'CX_ST_COND_CHECK_FAIL'.

              <tt:cond check="DENIAL_CODE!=''">

                <DenialCode tt:value-ref="DENIAL_CODE"/>

              </tt:cond>

please advise on this.

Regards,

Rajesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,278

If xml is well formed, below regular expression can be used.

If xml is ill formed, the transformation will fail anyways.

DATA lv_str TYPE string VALUE '<tag1><tag2><tag> </tag><tag>asdf<tag><tag> </tag></tag2><tag1>'.

REPLACE ALL OCCURRENCES OF REGEX '<\w+> </\w+>' IN lv_str WITH ''.

WRITE lv_str.


Dear friends,

I have a problem while converting xml file into internal table (de-serialization) using simple transformation.

there is a tag like <tag> </tag> and I am using condition to check whether tag consist data or not.

because of the space value in the tag I am getting an exception 'CX_ST_COND_CHECK_FAIL' during the condition check.

before deserialization, i am removing empty tags from the xml by using below statement.

REPLACE ALL OCCURRENCES OF REGEX '<\w+/>' IN l_string WITH ''.

but because the tag has the space value it is not getting removed from the XML.

and i am using below code to check is there any tag with empty value. at this condition, because of space value

i am getting the exception  'CX_ST_COND_CHECK_FAIL'.

              <tt:cond check="DENIAL_CODE!=''">

                <DenialCode tt:value-ref="DENIAL_CODE"/>

              </tt:cond>

please advise on this.

Regards,

Rajesh

4 REPLIES 4
Read only

Former Member
0 Likes
1,279

If xml is well formed, below regular expression can be used.

If xml is ill formed, the transformation will fail anyways.

DATA lv_str TYPE string VALUE '<tag1><tag2><tag> </tag><tag>asdf<tag><tag> </tag></tag2><tag1>'.

REPLACE ALL OCCURRENCES OF REGEX '<\w+> </\w+>' IN lv_str WITH ''.

WRITE lv_str.

Read only

0 Likes
1,278

Thank you Manish,

it seems you code is working fine, but are you sure that it will not delete any other tags.

let me know your comments.

Regards,

Rajesh A.

Read only

0 Likes
1,278

It should work fine for well formed xml. Potentially it will also delete occurrences like <tag> </anothertag> but that is not expected in real xml.

Read only

0 Likes
1,278

Thank you so much for your help.