Skip to Content
0
Aug 20, 2015 at 11:09 AM

XSLT mapping

177 Views

Hi Experts,

i am new to XSLT mapping , but i used few xslt codes which were found in few blogs, and those are running fine..but need to keep both codintions in single code..below are codes

Code1: this is doing removing the all namespaces in payload

<?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"/>
  <xsl:template match="*">
    <xsl:element name="{local-name(.)}">
      <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="@*">
    <xsl:attribute name="{local-name(.)}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
  <xsl:template match="@*[local-name(.)='noNamespaceSchemaLocation']"/>
</xsl:stylesheet>

Code2: its doing adding my required Message type and namespace with tacking header and body from payload

<?xml version="1.0" encoding="UTF-8"?>  
<xsl:stylesheet version="1.0" exclude-result-prefixes="ns0 ns1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://Softel.com/xi/Softel_SC_PLANNING/GPEO/TransactionalData" xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" >  
   <xsl:output method="xml" encoding="UTF-8"/>  
   <xsl:template match="/">  
      <ns0:Envelope xmlns:ns0="http:Business.com" >
            <xsl:copy>  
               <xsl:apply-templates select="//Header"/>  
            </xsl:copy>  
            <xsl:copy>  
               <xsl:apply-templates select="//Body"/>  
            </xsl:copy>       
      </ns0:Envelope>  
   </xsl:template>  
   <xsl:template match="*">  
      <xsl:element name="{local-name()}">  
         <xsl:apply-templates select="@* | node()"/>  
      </xsl:element>  
   </xsl:template>  
   <xsl:template match="@*">  
      <xsl:attribute name="{local-name()}">  
         <xsl:value-of select="."/>  
      </xsl:attribute>  
   </xsl:template>  
</xsl:stylesheet>

please help me if both condition are possible to merge in single code and achieve.

Thanks,

Maheswarareddy