cancel
Showing results for 
Search instead for 
Did you mean: 

splitting the elements

Former Member
0 Kudos

Hi ,

I am getting as a,b,c as element tag I need to split and pass a b and c to the receiver element tag

<Element>a,b,c</Element>

I need to get the output like the below

<Element>a</Element>

<Element>b</Element>

<Element>c</Element>

Please suggest me how to do this

Thanks

Prasad

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prasad,

First on the receiver structure, rightclick on the field 'Element' & duplicate it 2 more times.

Once this is done, on the first receiver 'Element', use the mapping as:

Source Element ---> Substring1 --> Receiver Element1

Then,

Source Element ---> Substring2 --> Receiver Element2

Source Element ---> Substring3 --> Receiver Element3

The values for Substring 1, 2 & 3 will depend upon the Source element value.

-Supriya.

Former Member
0 Kudos

@ Supriya,

First on the receiver structure, rightclick on the field 'Element' & duplicate it 2 more times.

What will happen if there are 100 values in the source element? Will you be duplicating the receiver element 100 times???

@ Prasad,

Go for the UDF suggested above.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Input will be : Var1 type string

Execution type: All values of a queue.

String delimiter ="," ;

String[] temp = var1[0].split(delimiter);

for(int i=0;i<temp.length;i++)

{

result.addValue(temp i );("i" is under square brackets)

}

Thanks

Amit

Edited by: AmitSri on Sep 3, 2010 12:40 PM

Former Member
0 Kudos

Create a UDF with 2 input parameters as "instr" & "delimiter" and pass the constant "comma" to the delimiter & Element to instr input parameters.

String[] outstr  = instr[0].split(delimiter[0]);

 for (int i = 0; i < outstr.length; i++)
    result.addValue(outstr<i>);

Just make sure the target "Element" has 0..Unbounded occurrance.

Former Member
0 Kudos

Java Area import, Line 7:

<identifier> expected import ; ^ 1 error

I am getting the above error and also can u explain how to pass the two parameter plz brief me

Former Member
0 Kudos

When you will create the UDF then you have to define "instr" & "delimeter" as an argument. Default values will be 'a' or 'var1'.

Secondly do not copy and poste the code directly from SDN becasue it carries some hidden footprints which creates some strange problems. So copy the code from here then first paste it on notepad and then you can copy it again from your notepad to use it.