cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT

former_member10771
Active Participant
0 Kudos

Hi All,

Can someone please help me to parse this using XSLT mapping.

I am doing SOAP to RFC scenario. The sender adapter is not able to pick this file.
This is the sample format coming from source

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:http="http:\www.test.com\POC">
   <soapenv:Header>
      <http:XHeader>
         <applicationName></applicationName>
         <correlationId></correlationId>
         <UserInfo>
            <UserType></UserType>
            <Id></Id>
         </UserInfo>
      </http:XHeader>
   </soapenv:Header>
   <soapenv:Body>
      <http:MT_SRC>
         <N1></N1>
         <N2></N2>
      </http:MT_SRC>
   </soapenv:Body>

</soapenv:Envelope>

In the target after mapping I am passing only N1 and N2. The problem is not able to parse this. Can someone help me with XSLT mapping.

Target

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

<ns1:ZpiTest xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style"><Num1></Num1><Num2></Num2></ns1:ZpiTest>

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

You only need to be careful with the prefixes.

With this input XML:


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

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:http="http:\www.test.com\POC">

    <soapenv:Header>

        <http:XHeader>

            <applicationName/>

            <correlationId/>

            <UserInfo>

                <UserType/>

                <Id/>

            </UserInfo>

        </http:XHeader>

    </soapenv:Header>

    <soapenv:Body>

        <http:MT_SRC>

            <N1>HELLO</N1>

            <N2>WORLD</N2>

        </http:MT_SRC>

    </soapenv:Body>

</soapenv:Envelope>

And with this XSL:


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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:http="http:\www.test.com\POC" exclude-result-prefixes="soapenv http">

    <xsl:output method="xml"/>

    <xsl:template match="/">

        <ns1:ZpiTest xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style">

            <Num1>

                <xsl:value-of select="/soapenv:Envelope/soapenv:Body/http:MT_SRC/N1"/>

            </Num1>

            <Num2>

                <xsl:value-of select="/soapenv:Envelope/soapenv:Body/http:MT_SRC/N2"/>

            </Num2>

        </ns1:ZpiTest>

    </xsl:template>

</xsl:stylesheet>

You will get this:


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

<ns1:ZpiTest xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style">

    <Num1>HELLO</Num1>

    <Num2>WORLD</Num2>

</ns1:ZpiTest>

If you don't have the SOAP envelope inside the PI you can ommit the SOAP prefixes.

Hope this helps.

Regards.

former_member10771
Active Participant
0 Kudos

Hi Inaki,


Thank you so much for the response. It worked. One more small clarification the header information will remain same for all the interfaces . So how can I generalise the above code so that it can be reused elsewhere to remove the header.

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

You can set several XSL/message mappinds/Java mapping inside one operation mapping.

You can use this XSL to skip the SOAP header like first mapping:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >

    <xsl:output omit-xml-declaration="yes" indent="yes"/>

    <xsl:template match="node()|@*">

        <xsl:copy>

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

        </xsl:copy>

    </xsl:template>

    <xsl:template match="soapenv:Envelope/soapenv:Header"/>

</xsl:stylesheet>

Regards.

Answers (0)