on 07-24-2015 7:55 AM
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>
<?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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
<?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>
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.
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.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.