Wednesday, December 27, 2023

remove multi mapping tags in sap pi , not in sap cpi. remove namesspaces step2 select node step3 add required ns

remove namespaces, select node, add namesapce











<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

    <ns0:Message1>

<Parent>

<Child1>Value1</Child1>

<Child2>Value2</Child2>

<Child3>Value3</Child3>

<Child4>

<field1>Value4</field1>

<field2>Value5</field2>

</Child4>

</Parent>

</ns0:Message1>

</ns0:Messages>


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output indent="yes"/>

  <!-- Match the root element to start processing -->

  <xsl:template match="/">

    <!-- Apply templates starting from the third node -->

    <xsl:apply-templates select="//Parent"/>

  </xsl:template>


  <!-- Match any node and copy it to the output -->

  <xsl:template match="node()">

    <xsl:copy>

      <xsl:apply-templates select="@* | node()"/>

    </xsl:copy>

  </xsl:template>


</xsl:stylesheet>

<?xml version="1.0" encoding="UTF-8"?>
<Parent>
     <Child1>Value1</Child1>
     <Child2>Value2</Child2>
     <Child3>Value3</Child3>
     <Child4>
       <field1>Value4</field1>
       <field2>Value5</field2>
     </Child4>
   </Parent>
--------------
<?xml version="1.0" encoding="UTF-8"?>
<Messages>
    <Message1>    
   <Parent>
     <Child1>Value1</Child1>
     <Child2>Value2</Child2>
     <Child3>Value3</Child3>
     <Child4>
       <field1>Value4</field1>
       <field2>Value5</field2>
     </Child4>
   </Parent>
  </Message1>
</Messages>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
  <!-- Match the root element to start processing -->
  <xsl:template match="/">
    <!-- Apply templates starting from the third node -->
    <xsl:apply-templates select="//Parent"/>
  </xsl:template>

  <!-- Match any node and copy it to the output -->
  <xsl:template match="node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

<?xml version="1.0" encoding="UTF-8"?>
<Parent>
     <Child1>Value1</Child1>
     <Child2>Value2</Child2>
     <Child3>Value3</Child3>
     <Child4>
       <field1>Value4</field1>
       <field2>Value5</field2>
     </Child4>
   </Parent>
-------------

<?xml version="1.0" encoding="UTF-8"?>
<Parent>
         <Child1>Value1</Child1>
     <Child2>Value2</Child2>
     <Child3>Value3</Child3>
     <Child4>
       <field1>Value4</field1>
       <field2>Value5</field2>
     </Child4>
</Parent>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
  <!-- Template to match and copy nodes with the ns1 namespace -->
  <xsl:template match="Parent">
    <ns1:root xmlns:ns1="http://tcs.com/venkat">
      <xsl:copy-of select="./*"/>
    </ns1:root>
  </xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<ns1:root xmlns:ns1="http://tcs.com/venkat">
   <Child1>Value1</Child1>
   <Child2>Value2</Child2>
   <Child3>Value3</Child3>
   <Child4>
       <field1>Value4</field1>
       <field2>Value5</field2>
     </Child4>
</ns1:root>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home