cancel
Showing results for 
Search instead for 
Did you mean: 

Removing nodes in target mapping

Former Member
0 Kudos

Hello,

I am working on a requirement where i need to remove top node and namespaces after mapping send data to third party via SOAP.

XML Anonymizer bean is not suitable as its only usefull for playing around namespaces. Need to use XSLT or JAVA map in OM.

Output of  Mapping will be:

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

<ns1:Target_MT xmlns:ns1="urn:creditdetails">

   <cardData>

      <headerData>

         <Number/>

         <Name/>

         <transaction/>

      </headerData>

   </cardData>

</ns1:Target_MT>



Need to send like this:

   <cardData>

      <headerData>

         <Number/>

         <Name/>

         <transaction/>

      </headerData>

   </cardData>


Any inputs with code sample will be appreciated.


Thanks for your help in advance.

Accepted Solutions (0)

Answers (7)

Answers (7)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Jan,

You can use the trick suggested by Mark in the above.

To remove the xml header line in the target, you can use xslt mapping for it.

For more information, pls check the below thread.

Former Member
0 Kudos

Hello Jan,

Do not specify anything in the XML namespace section of MT.

But however,the the tag

<?xml version="1.0" encoding="UTF-8"?> cannot be deleted as this represents the standard xml conversion thru PI.

Might small udf is required here to remove it.


Regards

Madhulatha

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Jan,

Just create a cardData type and use it in your message type. Just make sure to remove the namespace entry in the message type before saving it. No need to use JavaMap or XSLT.

Regards,

Mark

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Jan,

Can you check the below thread.

Former Member
0 Kudos

nodes needs to be removed as highlighted in red. not just namespaces.

Given links are not for this requirement.

vinaymittal
Contributor
0 Kudos

use this java mapping i haven't compiled it but it will work

import java.io.InputStream;

import java.io.OutputStream;

import java.util.Map;

import java.util.HashMap;

import java.io.IOException;

import java.io.FileReader;

import java.io.BufferedReader;

import java.io.*;

   

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class RemoveNamespace extends AbstractTransformation

{

     

  public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException

  {

         

    try {

  

       

   BufferedReader reader = new BufferedReader(new InputStreamReader(in.getInputPayload().getInputStream()));

   String line;

        while ((line = reader.readLine()) != null) {

            out.append(line);

        }

  //removing namespace in the string we have

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

  <ns1:Target_MT xmlns:ns1="urn:creditdetails">

  */

    

  line = line.substring(line.indexOf("urn:creditdetails")+20,line.length());

  /* </ns1:Target_MT>

  */

  line = line.substring(0,line.indexOf("ns1:Target_MT>")-2);

 

             

  out.getOutputPayload().getOutputStream().write(line.getBytes("UTF-8")); //writing to output

        }

  catch (Exception e)

  {

        e.printStackTrace();

         }

    

  }

        

}

vinaymittal
Contributor
0 Kudos

Hi Jan,

Mark is right that is the best possible solution (unless you have some restrictions on modifying the MT and removing the namespace in MT).

Java mapping may give you some error in future and its like killing an ant with a bazooka.

Regards

Vinay

vinaymittal
Contributor
0 Kudos

This will solve your problem

you have exactly same requirement here i suppose

former_member186851
Active Contributor
0 Kudos

Hello Jan,

Try the below link