Monday, October 2, 2023

OIC - Split comma separated string values to Array | Use of create-nodeset-from-delimited-string() function in XSLT

UseCase: Here, we will show you how to split an input, received as comma separated string values( here, emails) into array of values using create-nodeset-from-delimited-string() function.

Logic steps:

  • Create a rest trigger connection
  • Create an app driven integration and configure using request and response jsons
  • Map the request to response using create-nodeset-from-delimited-string() function.

Input json:

{

"Emails":""

}

output json:

{

"Emails":[{

"Email":"",

},{

"Email":""

}]

}

XSLT code:

<nstrgmpr:executeResponse>

<nstrgdf1:response-wrapper>

<nstrgdf1:Emails>

<xsl:for-each select="oraext:create-nodeset-from-delimited-string('{http://test.com/sample/xml}value',/nstrgmpr:execute/nstrgdf1:request-wrapper/nstrgdf1:Emails,',')">

<nstrgdf1:Email>

<xsl:value-of select="."/>

</nstrgdf1:Email>

</xsl:for-each>

</nstrgdf1:Emails>

</nstrgdf1:response-wrapper>

</nstrgmpr:executeresponse>


Details steps with screenshots:



Rest configure to input comma separated strings and get back response as array.








Map the rest request which is the comma separated strings to array using create-nodeset-from-delimited-string() function.



Test:

Note: we can also use oraext:create-delimited-string() XSLT function to convert nodes to delimited string.

Reference:


No comments:

Post a Comment

Featured Post

OIC - how can I use XSLT functions to remove leading zeros from numeric and alphanumeric fields?

To remove leading zeros from an numeric field in Oracle Integration Cloud (OIC) using XSLT, you can Use number() Function The number() funct...