cancel
Showing results for 
Search instead for 
Did you mean: 

How to Replace the string with Blank using XSLT Mapping

maheswarareddykonda
Active Contributor
0 Kudos

Hi Experts


i want to do one small conversion using XSLT mapping,


here is input data :


{"ns0:MT_Source":{   "field1": null,   "field2": "ec92a1e9-cef0-48aa-8800-a2e500ce8b1c",   "field3": null,   "Subnode": [   {      "field4": 80,      "field5":"Kilograms",      "field6": null,      "field7": "12345678-0003-0000-0000-000000000012",      "field8": null,      "field9": "DFF5JGJ3N5",      "WasteStreamCodes": "200301"

   },{}   ]}}

and expected output data :

{   "field1": null,   "field2": "ec92a1e9-cef0-48aa-8800-a2e500ce8b1c",   "field3": null,   "Subnode": [   {      "field4": 80,      "field5": "Kilograms",

      "field6": null,      "field7": "12345678-0003-0000-0000-000000000012",      "field8": null,      "field9": ["DFF5JGJ3N5"],      "WasteStreamCodes": ["200301"]

   }   ]}

in above output data below things has been done:

1:deleted -  {"ns0:MT_Source":

2:added- Square brackets"[]" for DFF5JGJ3N5 and 200301(these two values always comes different values)

3:deleted -    ,{}  at 3rd line

can any one please help me the XSLT code?

Thanks in Advance!!

Thanks & Regards,

Maheswarareddy

Accepted Solutions (0)

Answers (2)

Answers (2)

iaki_vila
Active Contributor
0 Kudos

Hi all,

If i'm not wrong you have a JSON format and XSLT doesn't support it.

Also to use the function provided by Azhar you will

need to use XSLT 2.0, you will need a PI 7.31 SP10 or 7.4 SP05 (Use Custom XSLT Transformer to Support XSLT 2.0 in XLST Mappings (New) - What's New in SAP NetWeaver...)

Regards.

maheswarareddykonda
Active Contributor
0 Kudos

Hi Both,

I was expecting the code for that , but thanks for coming back on my post

Yes Inaki, you are right ..i am trying to change little json formate as per my requirement..

since i am not able to write XSLT code..i had to go for java mapping to achieve the same.

but here also i am facing some exception..below is the post which i raised another for that..pls have a look.

http://scn.sap.com/thread/3747566

Thanks & Regards,

Maheswarareddy

azharshaikh
Active Contributor
0 Kudos

Hi,

You can achieve this using translate function in XSLT.

eg:

fn:translate(string1,string2,string3) --> Converts string1 by replacing the characters in string2 with the characters in string3

Refer:

XPath, XQuery, and XSLT Function Reference

Regards,

Azhar