on 2024 May 28 2:49 AM
Dear Experts,
My scenario : proxy <--> PI <---> rest mode of communication : Synchronous
i have a requirement, i am getting 3 xml fields as shown in the below in the input payload need to convert them as a single json string. could you please help on this to write an XSLT code. i am new to this xslt code.
input fields :
client_id
client_secret
grant_type
Thanks in advance.
Best Regards,
Nagaraju
Request clarification before answering.
i am giving solution to myself.
i have changed the xslt code like below now it is working fine what i expected also i got token as a reposne.
XSLT code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="urn://x-www-form-urlencoded/checking/atreceiver/rest">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>client_id=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/client_id"/>
<xsl:text>&client_secret=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/client_secret"/>
<xsl:text>&grant_type=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/grant_type"/>
</xsl:template>
</xsl:stylesheet>
thank you Ismail for your response.
Best regards,
Nagaraju.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nagaraju,
The below XSLT will suits for requirement,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:text>{</xsl:text>
<xsl:text>"client_id": "</xsl:text>
<xsl:value-of select="/request/client_id"/>
<xsl:text>", </xsl:text>
<xsl:text>"client_secret": "</xsl:text>
<xsl:value-of select="/request/client_secret"/>
<xsl:text>", </xsl:text>
<xsl:text>"grant_type": "</xsl:text>
<xsl:value-of select="/request/grant_type"/>
<xsl:text>"}</xsl:text>
</xsl:template>
</xsl:stylesheet>
Thanks,
Ismail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Ismail,
thanks for you immediate response. sorry its my bad i have not given clarity in my question about my requirment, i have checked in the operation mapping but i am not getting the proper output what i have expected.
let me explain my requirement first. i have to send the data ( 3 fields ) to the rest api in the body level especially x-www-form-urlencoded. i have read some of few blogs in sap but they have achieved this requirement through java mapping but i don't want to go this approach because i don't have any knowledge on java. so i choose xslt mapping approach. even i have tried the xslt code in the chatgpt also but not getting as excepted, chatgpt code level getting single sting as a out put but not getting values. i would request you could you please make the changes in the chatgpt code if possible.
your xslt code response in Operation mapping:
My requirement in the postman collection :
my request payload in the operation mapping :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_x_www_form_urlencoded_REQ xmlns:ns0="urn://x-www-form-urlencoded/checking/atreceiver/rest">
<client_id>sfv24</client_id>
<client_secret>45g34</client_secret>
<grant_type>doif4</grant_type>
</ns0:MT_x_www_form_urlencoded_REQ>
expecting output :
client_id=iweu245&client_secret=oirt3453&grant_type=u4wonok64
output level field & vlaues seperated by "=" ( equals to ) and seperator : "&"
chatgpt xslt code :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="urn://x-www-form-urlencoded/checking/atreceiver/rest">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>client_id=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/ns0:client_id"/>
<xsl:text>&client_secret=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/ns0:client_secret"/>
<xsl:text>&grant_type=</xsl:text>
<xsl:value-of select="//ns0:MT_x_www_form_urlencoded_REQ/ns0:grant_type"/>
</xsl:template>
</xsl:stylesheet>
chatgpt xslt code output in operation mapping:
Thanks in advance.
Best Regards,
Nagaraju
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.