Skip to Content
0
Apr 29, 2015 at 01:49 AM

Dynamic XSLT source code generation based upon internal table

337 Views

Hi,

Is there anyway to generate dynamic XSLT source code based upon final structure of output internal table and call dynamic generated XSLT in program?

CALL TRANSFORMATION z_transformation

PARAMETERS

p_shared_string = lo_shared_str_nodeset

SOURCE XML g_sheet_data

RESULT lt_data = i_data[].

Source code example of XSLT transformation -

<xsl:template match="/">

<asx:abap version="1.0">

<asx:values>

<LT_DATA> "Internal table

<xsl:for-each select="ss:worksheet/ss:sheetData/ss:row">

<xsl:if test="position() &gt; 1">

<item>

<FIELD1>

<xsl:variable name="cell_id" select="concat('A', position())"/>

<xsl:variable name="v_index" select="ss:c[@r=$cell_id][@t='s']/ss:v"/>

<xsl:if test="$v_index">

<xsl:value-of select="$V_SHARED_STRING/sst/si[$v_index + 1]/t"/>

</xsl:if>

<xsl:if test="not($v_index)">

<xsl:value-of select="ss:c[@r=$cell_id]/ss:v"/>

</xsl:if>

</FIELD1>

</item>

</xsl:if>

</xsl:for-each>

</LT_DATA> "internal table

</asx:values>

</asx:abap>

</xsl:template>

</xsl:transform>