Hi Experts,
Can you please help me with the XSLT code to replace the below xml to the one I need. There are three prefixes ns0,ns1 and ns2 which are to be replaced with tem,ep4 and ep41.
Input Structure
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://tempuri.org/" xmlns:ns1="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common" xmlns:ns2="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities">
<soapenv:Header />
<soapenv:Body>
<ns0:PrintCertificateByContractNumber>
<ns0:ContractNumber>300004</ns0:ContractNumber>
<ns0:Credentials>
<ns1:Password>a2fP2te254b0d0d74bDe</ns1:Password>
<ns1:ResponseStatusList>
<ns2:ResponseStatus>
<ns2:ErrorMessage />
<ns2:ResponseType>Error</ns2:ResponseType>
</ns2:ResponseStatus>
</ns1:ResponseStatusList>
<ns1:UserName>e.eppcointegration</ns1:UserName>
<ns1:UserReferenceNumber />
</ns0:Credentials>
</ns0:PrintCertificateByContractNumber>
</soapenv:Body>
</soapenv:Envelope>
Output Structure
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ep4="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common" xmlns:ep41="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities" xmlns:tem="http://tempuri.org/">
<soapenv:Header />
<soapenv:Body>
<tem:PrintCertificateByContractNumber>
<tem:ContractNumber>300001</tem:ContractNumber>
<tem:Credentials>
<ep4:Password>a2fP2te254b0d0d74bDe</ep4:Password>
<ep4:ResponseStatusList>
<ep41:ResponseStatus>
<ep41:ErrorMessage />
<ep41:ResponseType>Error</ep41:ResponseType>
</ep41:ResponseStatus>
</ep4:ResponseStatusList>
<ep4:UserName>e.eppcointegration</ep4:UserName>
<ep4:UserReferenceNumber>1234567890</ep4:UserReferenceNumber>
</tem:Credentials>
</tem:PrintCertificateByContractNumber>
</soapenv:Body>
</soapenv:Envelope>
Request clarification before answering.
Hi!
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tem="http://tempuri.org/"
xmlns:ep4="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common"
xmlns:ep41="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities"
version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:ep4="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common"
xmlns:ep41="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities">
<soapenv:Header/>
<soapenv:Body>
<xsl:apply-templates select="@* | node()"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="ns0:*" xmlns:ns0="http://tempuri.org/">
<xsl:element name="tem:{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="ns1:*" xmlns:ns1="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common">
<xsl:element name="ep4:{local-name()}" namespace="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities.Common">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="ns2:*" xmlns:ns2="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities">
<xsl:element name="ep41:{local-name()}" namespace="http://schemas.datacontract.org/2004/07/EP4.Integration.Entities">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.