i have asked with the same question but not with the namespace
i have an xml like..this
<?xml version = '1.0' encoding = 'UTF-8'?> <FinalDbGetUserId> <FinalDbGetUserIdOutputCollection xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/FinalDbGetUserId" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/FinalDbGetUserId"> <ns0:USERUBSCRIBERS> <ns0:USER_ID>237</ns0:USER_ID> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201114</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>207</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> </ns0:USERUBSCRIBERS> <ns0:USERUBSCRIBERS> <ns0:USER_ID>237</ns0:USER_ID> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201119</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>212</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> </ns0:USERUBSCRIBERS> <ns0:USERUBSCRIBERS> <ns0:USER_ID>237</ns0:USER_ID> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201129</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>230</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> </ns0:USERUBSCRIBERS> </FinalDbGetUserIdOutputCollection> </FinalDbGetUserId>
output should be like
<FinalDbGetUserId> <FinalDbGetUserIdOutputCollection xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/FinalDbGetUserId" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/FinalDbGetUserId"> <ns0:USERUBSCRIBERS> <ns0:USER_ID>237</ns0:USER_ID> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201114</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>207</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201119</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>212</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> <ns0:BusinessEntity> <ns0:NEVADA_BUSINESS_ID>NV0511201129</ns0:NEVADA_BUSINESS_ID> <ns0:BUSINESS_ENTITY_ID>230</ns0:BUSINESS_ENTITY_ID> </ns0:BusinessEntity> </ns0:USERUBSCRIBERS> </FinalDbGetUserIdOutputCollection> </FinalDbGetUserId>
Following is the below xslt, that i was trying and not getting the desired result
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="kuserID" match="USERUBSCRIBERS" use="USER_ID"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"> <xsl:sort select="USER_ID" data-type="number"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match= "USERUBSCRIBERS|USER_ID |BusinessEntity"/> <xsl:template match= "USERUBSCRIBERS [generate-id() = generate-id(key('kuserID', USER_ID)[1]) ]"> <USERUBSCRIBERS> <xsl:copy-of select="USER_ID"/> <xsl:apply-templates mode="copy" select="key('kuserID',USER_ID)" /> </USERUBSCRIBERS> </xsl:template> <xsl:template match="USERUBSCRIBERS" mode="copy"> <BusinessEntity> <xsl:apply-templates/> </BusinessEntity> </xsl:template> </xsl:stylesheet>
i am getting the output same as input and there is no change. may be i am doing mistake, but not getting what the mistake is .... trying to find it out