Skip to Content
0

adding prefixes in the field names

Dec 28, 2016 at 12:48 PM

116

avatar image

Hi All,

in our mapping requirement i have implement one logic

input xml

<janardhan>1234</janardhan>

output xml

<gsp:janardhan>1234</gsp:janardhan>

need to add extra prefixes, could you please tell how can i achieve this requirement.

Regards,

Janardhan

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Raghuraman S Dec 29, 2016 at 06:26 AM
0

Hello Jana,

You can try the XSLT code in the below link,Replace ns0 with GSP and message type name.

https://archive.sap.com/discussions/thread/3202784

Share
10 |10000 characters needed characters left characters exceeded
janardhan reddy Dec 30, 2016 at 06:38 AM
0

HI Raghu,

I want to add those prefixes for specific fields only in the target side, could you please let me know how can i add this?

i am new to XSLT mapping, can you please let me know which tool i need to install to support for SAP PI 7.1

Regards,

Janardhan

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello Jana,

You can do XSLT in XML altova spy and then import it the mapping as external defintion in SAP PI.

0

Hi Raghu,

that requirement i got through udf as per the below link, the ouput also i am able to see in xml. but when i open that file in xml format the document is not opening.

https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/

while opening the output file i am getting error like

input xml:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:hthtr xmlns:ns0="http://apse.com">
   <namevaluepair>
      <name>janardhan</name>
      <value>1234</value>
   </namevaluepair>
</ns0:hthtr>

output xml:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:grgrg xmlns:ns0="http://apse.com"><namevaluepair><gsk:janardhan>1234</gsk:janardhan></namevaluepair></ns0:grgrg>

capture.png (4.0 kB)
0

Your output XML is invalid because the prefix gsk is not bound i.e it is not declared , for exaple prefix ns0 is declared as xmlns:ns0="http://apse.com" , hence if you want to use the gsk then you need to define as xmlns:gsk="http://apse.com"

0

Hi Manoj,

Thank you so much for your response. i have few other fields also without gsk in output file should populate. how can i define those namespaces and if possible how can i achieve thorugh xslt coding or any standard format is there?

Regards,

Janardhan

0
avatar image
Former Member Dec 31, 2016 at 03:57 PM
0

Hi Janardan,

Use simple java mapping and replace the nodes with the string you require.

Thnaks,

Apu

Share
10 |10000 characters needed characters left characters exceeded