Application Development 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: 

ABAP Program that generates XML and calls an XSLT transformation,

Former Member
0 Kudos

Hello,

I am creating a program that creates some XML output, and I am using STRANS to create a transformation.

The file created looks like below before transformation.

<?xml version="1.0" encoding="utf-8" ?>

- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

- <asx:values>

- <EMPLOYEE_DATA>

- <item>

<EMPLOYEE_ID>00000010</EMPLOYEE_ID>

<FIRSTNAME>Joe</FIRSTNAME>

<SURNAME>Bloggs</SURNAME>

<DOB>1940-11-10</DOB>

<SALARY>200000.0</SALARY>

</item>

<item>

<EMPLOYEE_ID>00000055</EMPLOYEE_ID>

<FIRSTNAME>Lydia</FIRSTNAME>

<SURNAME>Jones</SURNAME>

<DOB>1965-03-09</DOB>

<SALARY>90000.0</SALARY>

</item>

</EMPLOYEE_DATA>

</asx:values>

</asx:abap>

I want to make EMPLOYEE_ID an attribute like in the following

and what I want to output is:

<?xml version="1.0" encoding="utf-8" ?>

- <asx:abap xmlns:asx="http://www.sap.com/abapxml">

- <asx:values>

- <EMPLOYEE_DATA>

- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000010">

<FIRSTNAME>Joe</FIRSTNAME>

<SURNAME>Bloggs</SURNAME>

<DOB>1940-11-10</DOB>

<SALARY>200000.0</SALARY>

</EMPLOYEE_DETAILS>

<EMPLOYEE_DETAILS EMPLOYEE_ID="00000055">

<FIRSTNAME>Lydia</FIRSTNAME>

<SURNAME>Jones</SURNAME>

<DOB>1965-03-09</DOB>

<SALARY>90000.0</SALARY>

</EMPLOYEE_DETAILS>

</EMPLOYEE_DATA>

</asx:values>

</asx:abap>

the XSLT I have cureently produces:

<?xml version="1.0" encoding="utf-8" ?>

- <asx:abap xmlns:asx="http://www.sap.com/abapxml">

- <asx:values>

- <EMPLOYEE_DATA>

- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000010">

<EMPLOYEE_ID>00000010</EMPLOYEE_ID>

<FIRSTNAME>Joe</FIRSTNAME>

<SURNAME>Bloggs</SURNAME>

<DOB>1940-11-10</DOB>

<SALARY>200000.0</SALARY>

</EMPLOYEE_DETAILS>

- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000038">

<EMPLOYEE_ID>00000038</EMPLOYEE_ID>

<FIRSTNAME>Fred</FIRSTNAME>

<SURNAME>Johnson</SURNAME>

<DOB>1960-12-11</DOB>

<SALARY>123450.0</SALARY>

</EMPLOYEE_DETAILS>

- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000055">

<EMPLOYEE_ID>00000055</EMPLOYEE_ID>

<FIRSTNAME>Lydia</FIRSTNAME>

<SURNAME>Jones</SURNAME>

<DOB>1965-03-09</DOB>

<SALARY>90000.0</SALARY>

</EMPLOYEE_DETAILS>

</EMPLOYEE_DATA>

</asx:values>

</asx:abap>

But it is repeating the Employee_ID, I want it to start from Firstname, the XSLT I have is:

<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="node()">

<xsl:copy>

<xsl:apply-templates select="node()"/>

</xsl:copy>

</xsl:template>

<xsl:template match="item">

<EMPLOYEE_DETAILS>

<xsl:attribute name="EMPLOYEE_ID">

<xsl:value-of select="EMPLOYEE_ID"/>

</xsl:attribute>

<xsl:apply-templates select="node()"/>

</EMPLOYEE_DETAILS>

</xsl:template>

</xsl:transform>

How do I get it to start from the next node?

Thanks

2 REPLIES 2

Former Member
0 Kudos

Hi

I am also trying the similar kind of requirement.

I am trying to convert XML file in to ABAP using transformations.

Problem

When I am trying to execute the Transformation (Selection is Transformation name, Source File Path) using STRANS it is giving the bellow message.

XSLT Tester

Runtime Errors

Reason : No valid XSLT program supplied

Could you please guide me how to test the Transformation using STRANS

Thanks

Nikhil.B

0 Kudos

Probably you try to execute simple transformation and this tool support only XSLT ones