Tuesday, September 15, 2026

OIC - Split Semicolon-Separated Values Using tokenize() in XSLT

Introduction

While developing integrations in Oracle Integration Cloud (OIC), we may receive a field containing multiple values separated by a delimiter such as a semicolon (;).

For example:

"ImpactedAccountID": [

  "5354181000",

  "7789253000;4889253000",

  "6823624000",

  "9235902000",

  "5091223000",

  "2279450000;3457280000;7236081000;7131391000",

  "7131391000",

  "7131391000",

  "3457280000",

  "5200100000"

]

In this scenario, simply looping through ImpactedAccountID will not split values such as:

7789253000;4889253000

into separate account IDs.

OIC XSLT provides the tokenize() function, which can be used to split a string based on a delimiter.

Use Case

We receive an incident payload containing an ImpactedAccountID array.

Some array elements contain a single account ID, while others contain multiple account IDs separated by semicolon (;).

Input

{

  "VoltageDipIncidentDate": "09-07-2026",

  "VoltageDipIncidentTime": "15:14",

  "IncidentID": "INC 1350000262",

  "ImpactedAccountID": [

    "5354181000",

    "7789253000;4889253000",

    "6823624000",

    "9235902000",

    "5091223000",

    "2279450000;3457280000;7236081000;7131391000",

    "7131391000",

    "7131391000",

    "3457280000",

    "5200100000",

    "5173284000",

    "4523013000",

    "3506184000",

    "4136450000",

    "3264642000"

  ]

}

Our requirement is to transform this into multiple individual accountId elements.

Solution

We can use the XSLT tokenize() function.

The basic syntax is:

tokenize(string, delimiter)

For our requirement:

tokenize(string(.), ';')

This tells XSLT: Take the current value and split it wherever a semicolon (;) is found.

XSLT Code

The following is the same logic used in the provided XSLT:

<xsl:for-each

    select="/nssrcmpr:execute/ns15:request-wrapper/ns15:ImpactedAccountID">

    <xsl:for-each select="tokenize(string(.), ';')">

        <ns23:accounts>

            <ns23:accountId>

                <xsl:value-of select="normalize-space(.)"/>

            </ns23:accountId>

        </ns23:accounts>

    </xsl:for-each>

</xsl:for-each>



How the Logic Works

There are two xsl:for-each loops.

1. Outer for-each

<xsl:for-each

    select="/nssrcmpr:execute/ns15:request-wrapper/ns15:ImpactedAccountID">

The outer loop iterates through every element of the ImpactedAccountID array.

For example, it receives values one by one:

5354181000

7789253000;4889253000

6823624000

9235902000

...

2. tokenize() splits the current value

Inside the outer loop:

<xsl:for-each select="tokenize(string(.), ';')">

Here: string(.) -- gets the current value.

The second parameter: ';' --defines the delimiter.

For example:

7789253000;4889253000

becomes:

7789253000

4889253000

Similarly:

2279450000;3457280000;7236081000;7131391000

becomes four separate values:

2279450000

3457280000

7236081000

7131391000

3. Create the Target Element

For every token, we create:

<ns23:accounts>

    <ns23:accountId>

        <xsl:value-of select="normalize-space(.)"/>

    </ns23:accountId>

</ns23:accounts>

The current token is represented by: .

Therefore:

<xsl:value-of select="normalize-space(.)"/>

writes the current account ID into accountId.

normalize-space() is useful to remove unnecessary leading/trailing whitespace.

Example

Suppose the input contains:

"ImpactedAccountID": [

    "5354181000",

    "7789253000;4889253000",

    "6823624000"

]

Processing

First iteration:

5354181000

tokenize() returns:

5354181000

Second iteration:

7789253000;4889253000

tokenize() returns:

7789253000

4889253000

Third iteration:

6823624000

returns:

6823624000

Output

The resulting XML will contain individual accountId values:

<ns23:accounts>    <ns23:accountId>5354181000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>   <ns23:accountId>7789253000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>    <ns23:accountId>4889253000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>   <ns23:accountId>6823624000</ns23:accountId>

</ns23:accounts>

Output for the Provided Sample

For the provided input, values such as:

7789253000;4889253000

are converted to:

<ns23:accounts>   <ns23:accountId>7789253000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>   <ns23:accountId>4889253000</ns23:accountId>

</ns23:accounts>

And:

2279450000;3457280000;7236081000;7131391000

becomes:

<ns23:accounts>  <ns23:accountId>2279450000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>   <ns23:accountId>3457280000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>   <ns23:accountId>7236081000</ns23:accountId>

</ns23:accounts>

<ns23:accounts>  <ns23:accountId>7131391000</ns23:accountId>

</ns23:accounts>

Complete Logic in Simple Terms

The complete processing can be understood as:

ImpactedAccountID array

        ↓

Outer for-each

        ↓

Pick one value

        ↓

Check/Split using tokenize()

        ↓

Delimiter = ;

        ↓

Create accountId for every token

        ↓

normalize-space()

        ↓

Final XML

Key XSLT statement

tokenize(string(.), ';')

means: Split the current string wherever ; occurs and process each resulting value separately.

Conclusion

The tokenize() function is very useful in OIC when an incoming field contains delimiter-separated values.

Instead of manually manipulating the string, we can use:

<xsl:for-each select="tokenize(string(.), ';')">

This approach allows OIC to handle both:

5354181000

and:

7789253000;4889253000

using the same XSLT logic.

Important: The outer for-each handles the original ImpactedAccountID array, while the inner for-each handles the individual values produced by tokenize().

No comments:

Post a Comment

Featured Post

OIC - Split Semicolon-Separated Values Using tokenize() in XSLT

Introduction While developing integrations in Oracle Integration Cloud (OIC), we may receive a field containing multiple values separated by...