cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace namespace tag with new value using -JAVA MAPPING

Former Member
0 Kudos

Hi Guys,

I need to replace namespace Tag in Target xml with a new value.

For Eg: My namespace Tag is - <ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com">

I want My target xml to have value- <ns0:TestHeader>

How can i achieve it using JAVA mapping?

Can you provide me the code to do so.

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Sarjana,

Not well-formed XML is only possible by Java Mapping. Please use below replace logic in Java map.

inputContent.replaceAll("<ns0:TestHeader xmlns:ns0=\"http://0020.TestHeader.SS.com\">", "<ns0:TestHeader>");


Link1, Link2.

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

The result would not be valid XML, so why do you want to do it?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Sarjana,

You can always add a namespace in the message type via this field:

Aside from that, you can add namespaces directly without using java mapping

Hope this helps,

Mark

former_member181985
Active Contributor
0 Kudos

Hi,

Use XMLAnonymizerBean with anonymizer.acceptNamespaces parameter: Adding XMLAnonymizerBean in the Module Processor - Adding Modules to the Module Processor - SAP Libr...

Also check this blog for better understanding on usage:

- praveen

Former Member
0 Kudos

Thnx for your quick response.

However,I want to keep namespace prefix as it is.

I only want to replace namespace with new value as follows keeping prefix same:

<ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com"> to <ns0:TestHeader>

All the blogs contain info about how to remove prefix, however I am looking to replace the namespace itself with new value.

Please suggest!