Skip to Content
0
Feb 26, 2014 at 02:54 PM

XSLT for Name/Value pairs Help needed

212 Views

hello Experts,

I am trying to use XSLT to transform returned data in a soap envelope to ABAP. I do these transformations for other data and it works however in this case, the return is different. I am getting name/value elements rather than named elements which I can easily map to ABAP structures.

Here is a sample of what I get returned and here is what I have in my current transformation. Hopefully someone can help me so I can read the name/value pairs propertly.

Thanks!

<soap:Envelope>

<RetrieveResponseMsg>

<Results xsi:type="DataExtensionObject"><PartnerKey xsi:nil="true" /><ObjectIDxsi:nil="true"/><Type>DataExtensionObject</Type>

<Properties>

<Property>

<Name>CEID</Name>

<Value>TEST</Value>

</Property><Property>

<Name>ERQ_ID</Name>

<Value>TEST</Value>

</Property>

</Properties>

</Results>

</RetrieveResponseMsg>

</soap:Body></soap:Envelope>

My current transformation, as I was trying to use choose, when....

<xsl:template match="/">

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

<asx:values>

<RESPONSES>

<xsl:apply-templates/>

</RESPONSES>

</asx:values>

</asx:abap>

</xsl:template>

<xsl:template match="RetrieveResponseMsg">

<RESPONSES>

<OVERALLSTATUS>

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

</OVERALLSTATUS>



<DATAEXTENSIONOBJECT>

<xsl:for-each select="Results/Properties">

<structure>

<xsl:choose>

<xsl:when test="Name='CEID'">

<CEID>

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

</CEID>

</xsl:when>

<xsl:when test="Property/Name='ERQ_ID'">

<ERQ_ID>

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

</ERQ_ID>

</xsl:when>

</xsl:choose>

</structure>

</xsl:for-each>

</DATAEXTENSIONOBJECT>

</RESPONSES>

</xsl:template>

</xsl:transform>