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: 

XSLT for Name/Value pairs Help needed

former_member183993
Participant
0 Kudos

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>

1 ACCEPTED SOLUTION

former_member183993
Participant
0 Kudos

All,

Funny thing, I just figured this out.

My solution was simple actually.  Transform the name/values into a structure for name/values, then map to the proper structure with the field name and field value.  Bingo, quick and easy solution and seems to do the trick perfectly.

Thanks,

Chris

1 REPLY 1

former_member183993
Participant
0 Kudos

All,

Funny thing, I just figured this out.

My solution was simple actually.  Transform the name/values into a structure for name/values, then map to the proper structure with the field name and field value.  Bingo, quick and easy solution and seems to do the trick perfectly.

Thanks,

Chris