Monday, November 6, 2023

How To Create and use NodeSet from a delimited String or Vice-Versa in OIC Integrations

 In many cases in our Integrations we get node set and we want to convert  it to a delimited string Or we get delimited string and we want to convert to Node Set to iterate.

For the above requirements, We can use below two functions:

  • oraext:create-delimited-string()
  • oraext:create-nodeset-from-delimited-string()

Let us take each of these Functions in detail.

oraext:create-delimited-string()

This function allows us to convert a nodeset to delimited string of our choice.

The syntax is like below:

oraext:create-delimited-string (nodeSetValue, delimiter) 

Let us take example where we extract requisitions which provides us the requisitions as nodes in xml.

We want to convert the requisition numbers to string list with a delimiter value so that we can send this in IN clause to our BIP Data model query or to any API call.

Below are the screenshots for the same:

Here we are using an assign var to create requisition number list with '!' delimiter:

 

 

 

 

 In the runtime the reqn nodes will get assigned as list as shown in below screenshot.

 

 

 

 oraext:create-nodeset-from-delimited-string()

Not Let us take example where we receive a delimited string and we want to iterate over each value in the string.For this we can use  "oraext:create-nodeset-from-delimited-string()"

The syntax for the above function is:

 oraext:create-nodeset-from-delimited-string (qName, delimitedString, delimiter)

Let us take example where we get company codes csv list  as input to our integrations. We need to iterate over each company to get corresponding ledger and submit import journals in Oracle Fusion.

We can use a stage write operation to store the node set and then read the file.

 

We can use simple csv schema.

 

 

Now in the mapper  we should use like below having for each on nodeset:

We can use the function like below :

oraext:create-nodeset-from-delimited-string ("dummy", $g_Company, "," )

or

oraext:create-nodeset-from-delimited-string ("{http://xmlns.oracle.com/DelimitedStringDemo}Company", $g_Company, "," )

 

 For the company value we should use  current() as shown in below screenshot.

 

 

Below is how it looks like when we open the mapper in code mode :

 

 

<xsl:template match="/" xml:id="id_11">
              <nstrgmpr:Write xml:id="id_12">
                    <ns27:CompanySet>
                          <xsl:for-each select="oraext:create-nodeset-from-delimited-string (&quot;dummy&quot;, $g_Company, &quot;,&quot; )">
                                <ns27:Company xml:id="id_47">
                                      <ns27:Company xml:id="id_48">
                                            <xsl:value-of xml:id="id_49" select="current()"/>
                                      </ns27:Company>
                                </ns27:Company>
                          </xsl:for-each>
                    </ns27:CompanySet>
              </nstrgmpr:Write>
        </xsl:template> 


After writing this to the file we can read them as nodes.

Let us see how it works in runtime:

We got the company list as below:


 

Now using the above function we will convert it to nodeset.

 


<Write
    xmlns:ns0="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
    xmlns:ns2="http://www.oracle.com/XSL/Transform/java/com.bea.wli.sb.resources.icsxpathfunctions.ICSInstanceTrackingFunctions"
    xmlns:ns60="http://xmlns.oracle.com/ics/tracking/ics_tracking_context.xsd"
    xmlns:ns1="http://xmlns.oracle.com/cloud/adapter/stagefile/WriteCompanyParameters_REQUEST"
    xmlns:ns3="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath555608184"
    xmlns:nsmpr2="http://xmlns.oracle.com/cloud/adapter/atpdatabase/SelectMetaDataDetails_REQUEST/types"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:nsmpr0="http://xmlns.oracle.com/cloud/adapter/atpdatabase/GetMetaDataFromATP_REQUEST/types"
    xmlns:dvm="http://www.oracle.com/XSL/Transform/java/com.bea.wli.sb.functions.dvm.DVMFunctions"
    xmlns:ns59="http://xmlns.oracle.com/procmon"
    xmlns:nsmpr1="http://www.oracle.com/2014/03/ic/integration/metadata"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    xmlns:orajs9="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath844588718"
    xmlns:orajs7="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath86288"
    xmlns:orajs8="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1135195139"
    xmlns:orajs5="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath683541370"
    xmlns:orajs6="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath2135626643"
    xmlns:orajs3="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1245826793"
    xmlns:orajs4="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1330629646"
    xmlns:orajs1="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath321139187"
    xmlns:orajs2="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath111998477"
    xmlns:orajs0="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath56709502"
    xmlns:tns="http://xmlns.oracle.com/cloud/adapter/atpdatabase/GetMetaDataFromATP_REQUEST"
    xmlns:orajs20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath695137620"
    xmlns:orajs21="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath908128362"
    xmlns:orajs22="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1604224522"
    xmlns:orajs23="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath559919345"
    xmlns:orajs24="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath894434103"
    xmlns:orajs25="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1790659086"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:orajs10="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath592748751"
    xmlns:orajs11="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath590003995"
    xmlns:orajs16="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1958287109"
    xmlns:orajs17="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1563931494"
    xmlns:orajs18="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1029648371"
    xmlns:orajs19="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1365001469"
    xmlns:orajs12="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath76481190"
    xmlns:orajs13="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath51512327"
    xmlns:orajs14="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1022848056"
    xmlns:flt="http://xmlns.oracle.com/cloud/generic/service/fault"
    xmlns:orajs15="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath145366618"
    xmlns:ns24="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/RestTrigger_REQUEST/RESTINREQ"
    xmlns:ns23="http://xml.oracle.com/adapters/extension"
    xmlns:ns28="http://xmlns.oracle.com/cloud/ics/file/v1/types"
    xmlns:ns27="http://TargetNamespace.com/fileReference/WriteCompanyParameters"
    xmlns:ns25="http://xml.oracle.com/types/REST/RestTrigger_REQUEST"
    xmlns:nstrgmpr="http://xmlns.oracle.com/cloud/adapter/stagefile/WriteCompanyParameters_REQUEST/types"
    xmlns:ns29="http://xmlns.oracle.com/cloud/staging/write"
    xmlns="http://xmlns.oracle.com/cloud/adapter/stagefile/WriteCompanyParameters_REQUEST/types">
    <ns27:CompanySet>
        <ns27:Company>
            <ns27:Company>CO100</ns27:Company>
        </ns27:Company>
        <ns27:Company>
            <ns27:Company>CO101</ns27:Company>
        </ns27:Company>
        <ns27:Company>
            <ns27:Company>CO201</ns27:Company>
        </ns27:Company>
        <ns27:Company>
            <ns27:Company>CO202</ns27:Company>
        </ns27:Company>
    </ns27:CompanySet>
</Write>

 

 Now let us see the read response for this file: The read file will also have same csv schema as write file.

 


 

 

 

No comments:

Post a Comment