Hello Friends,
I am new to this XSLT-ABAP transformation. I went through the blogs and forums and got a fair bit of idea on this. Now, i am trying to create a simple program/ xslt transformation to test the scenario. Once this is successfull i need to implement this in our project.
I am not sure, where and what i am doing wrong. Kindly check the below given XSLT/ XML/ ABAP Program and correct me.
My XML File looks as given below:
<?xml version="1.0" encoding="utf-8" ?> - <List> - <ITEM> <ITEMQUALF>ITEM1</ITEMQUALF> <MATERIAL>MAT1</MATERIAL> </ITEM> - <ITEM> <ITEMQUALF>ITEM2</ITEMQUALF> <MATERIAL>MAT2</MATERIAL> </ITEM> - <ITEM> <ITEMQUALF>ITEM3</ITEMQUALF> <MATERIAL>MAT3</MATERIAL> </ITEM> </List>
My XSLT Transformation looks as given below:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0"> <xsl:strip-space elements="*"/> <xsl:template match="*"> <List> <xsl:for-each select="ITEM"> <xsl:element name="ITEM"> <xsl:element name="ITEMQUALF"> <xsl:value-of select="ITEMQUALF"/> </xsl:element> <xsl:element name="MATERIAL"> <xsl:value-of select="MATERIAL"/> </xsl:element> </xsl:element> </xsl:for-each> </List> </xsl:template></xsl:transform>
My ABAP program looks as below:
REPORT ztest_ram. TYPES: BEGIN OF ty_test, itemqualf TYPE char10, material TYPE char10, END OF ty_test, ty_t_test TYPE STANDARD TABLE OF ty_test. DATA: l_xml TYPE REF TO cl_xml_document, t_test TYPE ty_t_test, wa_person TYPE LINE OF ty_t_test, t_xml_out TYPE string, v_retcode TYPE sy-subrc, v_totalsize TYPE i. DATA: gs_rif_ex TYPE REF TO cx_root, gs_var_text TYPE string. * Create object CREATE OBJECT l_xml. * Call method to import data from file CALL METHOD l_xml->import_from_file EXPORTING filename = 'C:\xml\xml_test.xml' RECEIVING retcode = v_retcode. * Call method to Render into string CALL METHOD l_xml->render_2_string IMPORTING retcode = v_retcode stream = t_xml_out size = v_totalsize. * Call Transformation TRY. CALL TRANSFORMATION (`ZXSLT_RAM`) SOURCE XML t_xml_out RESULT outtab = t_test. CATCH cx_root INTO gs_rif_ex. gs_var_text = gs_rif_ex->get_text( ). MESSAGE gs_var_text TYPE 'E'. ENDTRY.
When i run this ABAP program to fetch the data from XML in to Internal table, i get the error message:
Incorrect element List for XML-ABAP transformation
I am really not sure how to proceed further. Could any one help me on this?
Note: Please do not paste the same links, as i have gone through most of them.
Thank you.
Best Regards,
Ram.