Blog Archive

Tuesday, September 12, 2017

Removing namespace, adding namespace and required prefix as per message mapping using xslt






Om


HI

  <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
 <xsl:output method="xml" indent="yes"/>
<!-- copy elements -->


<xsl:template match="*">
<xsl:if test="name()='EmployeeChangesResponse'">
    <xsl:element name="ns0:{local-name()}"
 namespace="http://heineken.com/ZA/EmployeeData">
        
         <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
    </xsl:if>
    <xsl:if test="not(name()='EmployeeChangesResponse')">
   
        <xsl:element name="{local-name()}"
                 >
         <xsl:apply-templates select="@* | node()"/>
   </xsl:element>
    </xsl:if>
</xsl:template>
</xsl:stylesheet> 

<?xml version="1.0" encoding="UTF-8"?>
<EmployeeChangesResponse 
xmlns="http://www.payspace.co.za/webservices/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <EmployeeChangesResult>
  <ReturnCode>1006</ReturnCode>
  <ReturnMessage>Ok</ReturnMessage>
  <Errors />
 </EmployeeChangesResult>
</EmployeeChangesResponse>


  

No comments:

Post a Comment