Skip to Content
avatar image
Former Member

splitting the elements

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 03, 2010 at 10:39 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      @ 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.

  • avatar image
    Former Member
    Sep 03, 2010 at 10:34 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • Sep 03, 2010 at 10:37 AM

    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

    Add comment
    10|10000 characters needed characters exceeded