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

how to validate xml file ?

Former Member
0 Likes
761

I try to validate my xml import file but I can't find proper validation and error message.

the source where it originates is a system where also texts can be entered manually which are part of the xml file.

I discoverd myself that & and ! are characters which are not allowed. but I'm looking for a way to check this before I process the xml file.

I have this coding and I found smum_xml_parse but still the error is not clear about what is wrong ?

try.
    CALL TRANSFORMATION ('ID')
    SOURCE XML it_xml_import
    RESULT order_header_in = st_sdhd1 order_conditions_in = ta_cond  order_partners = ta_parnr  order_text = ta_sdtext order_items_in = ta_sditm
      .


CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
    ASSIGN COMPONENT 'ERROR' OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = xslt_message.

data: gt_temp type STANDARD TABLE OF SMUM_XMLTB.
itx_xml_import = it_xml_import.
CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = itx_xml_import
  tables
    xml_table       = gt_temp
    return          = ta_ret2
          .


ENDTRY.

the xslt_message is also very unclear of what is exactly wrong with the file.

are there any function which can give me more detailed information about the xml file and what is wrong with it ?

Edited by: A. de Smidt on Feb 1, 2010 10:34 AM

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
607

The ampersand is not allowed in XML CDATA, you must use the entity &amp;amp;

I try to validate my xml import file but I can't find proper validation and error message.

the source where it originates is a system where also texts can be entered manually which are part of the xml file.

I discoverd myself that & and ! are characters which are not allowed. but I'm looking for a way to check this before I process the xml file.

I have this coding and I found smum_xml_parse but still the error is not clear about what is wrong ?

try.
    CALL TRANSFORMATION ('ID')
    SOURCE XML it_xml_import
    RESULT order_header_in = st_sdhd1 order_conditions_in = ta_cond  order_partners = ta_parnr  order_text = ta_sdtext order_items_in = ta_sditm
      .


CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
    ASSIGN COMPONENT 'ERROR' OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = xslt_message.

data: gt_temp type STANDARD TABLE OF SMUM_XMLTB.
itx_xml_import = it_xml_import.
CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = itx_xml_import
  tables
    xml_table       = gt_temp
    return          = ta_ret2
          .


ENDTRY.

the xslt_message is also very unclear of what is exactly wrong with the file.

are there any function which can give me more detailed information about the xml file and what is wrong with it ?

Edited by: A. de Smidt on Feb 1, 2010 10:34 AM

1 REPLY 1
Read only

rainer_hbenthal
Active Contributor
0 Likes
608

The ampersand is not allowed in XML CDATA, you must use the entity &amp;amp;