cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Error

former_member10771
Active Participant
0 Kudos

Hi All,

I need to delete these nodes using XSLT mapping . I have written the below code but its not giving me the desired result.

Input is

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

<ns3:Messages xmlns:ns3="http://sap.com/xi/XI/SplitAndMerge">

<ns3:Message1>

<ns0:CustReq_sync xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global">

  <Header />

<Customer>

  <SenderID>22</SenderID>

  <ReceiverID>44</ReceiverID>

</Customer>

  </ns0:CustReq_sync>

  </ns3:Message1>

  </ns3:Messages>

This is the XSLT mapping I have done. Somehow this is not giving the desired output. Can you please let me know what is wrong here.

I want only the values within the Customer .

<Customer>

  <SenderID>22</SenderID>

  <ReceiverID>44</ReceiverID>

</Customer>

XSLT code.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns3="http://sap.com/xi/XI/SplitAndMerge
xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global>
<xsl:output method="xml"/>
<xsl:template match="CustReq_sync"> 
<xsl:copy>
      <xsl:for-each select="Customer">
        <xsl:apply-templates select="." />
      </xsl:for-each>
</xsl:copy>
  </xsl:template>

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183816
Active Participant
0 Kudos

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:ns3="http://sap.com/xi/XI/SplitAndMerge"

xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global">

<xsl:template match="/">

<xsl:copy-of select="ns3:Messages/ns3:Message1/ns0:CustReq_sync/Customer"/>

</xsl:template>

</xsl:stylesheet>

former_member10771
Active Participant
0 Kudos

Thanks Ambuj.

This one worked .

One clarification How do I modify the above code if there is one more node under customer.

<ns0:CustReq_sync xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global">

  <Header />

<Customer>

  <SenderID>22</SenderID>

  <ReceiverID>44</ReceiverID>

     <Organisation>

      <Value>12</Value>

      </Organisation>

</Customer>

  </ns0:CustReq_sync>

former_member183816
Active Participant
0 Kudos

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:ns3="http://sap.com/xi/XI/SplitAndMerge"

xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global">

<xsl:template match="/">

<xsl:copy-of select="ns3:Messages/ns3:Message1/ns0:CustReq_sync/Customer/Organisation"/>

</xsl:template>

</xsl:stylesheet>

Output:

<Organisation>

      <Value>12</Value>

</Organisation>

former_member10771
Active Participant
0 Kudos


Hi Ambuj,

That is what I had done and it gives me the value 12. But I need the entire structure.

<Customer>

  <SenderID>22</SenderID>

  <ReceiverID>44</ReceiverID>

     <Organisation>

      <Value>12</Value>

      </Organisation>

</Customer>

Since it comes within the Customer node. I need all the three values because customer is the parent node and organisation is the node within customer.

So ideally I need to get output as 22 44 and 12

But if I add to above code it gives me only organisation.

former_member10771
Active Participant
0 Kudos

Hi All,

How can we get all the values from the parent node Customer. Currently I can get it for Organisation.

<xsl:copy-of select="ns3:Messages/ns3:Message1/ns0:CustReq_sync/Customer/Organisation"/>

<Customer>

  <SenderID>22</SenderID>

  <ReceiverID>44</ReceiverID>

     <Organisation>

      <Value>12</Value>

      </Organisation>

</Customer>

Can I know how can I get the details for both customer and organisation.

I want the ouput as 22 44 and 12. Currently I get only 12 since I have given Organisation. How can I get all of them.

former_member10771
Active Participant
0 Kudos

Hi All,

I modified this but still same issue . Not able to get the desired result.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global>
<xsl:output method="xml"/>
<xsl:template match="ns0:CustReq_sync"> 
<xsl:copy>
      <xsl:for-each select="Customer/SenderID">
        <xsl:apply-templates select="." />
      </xsl:for-each>
</xsl:copy>
  </xsl:template>

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