cancel
Showing results for 
Search instead for 
Did you mean: 

Manipulating node elements in a user defined function

Former Member
0 Kudos

Hi All,

I have a secnario like this:

Source Message

-


<address>

<line1>Line 1</line1>

<line2>Line 2</line2>

<line3>Line 3</line3>

</address>

-


Target Message

-


<address>Line1, Line2, Line3</address>

-


I want a mapping like as follows:

<address> --->concatenateAddresses ---> <address>

How can I access the individual lines from the source <address> element and concatenate them and pass to the target <address> element?

Is this possible?

Many Thanks,

Sandeep

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Michal,

Thanks for the quick response. But my requirement is slightly different. I cannot predict the number of times the line element occur. Actually the occurence of the <line> element is 0...unbounded. I made a mistake in the example i gave. it should be

<address>

<line>Joseph</line>

<line>St.Lawrence</line>

<line>Quebec</line>

...

<address>

In the above example the <line> element occurs multiple times and i want to concatenate all of them before mapping to the target <address>

Sorry for the confusion caused.

Thanks,

Sandeep

MichalKrawczyk
Active Contributor
0 Kudos

hi,

sure you can do it

you need to create a user advanced fuction (with check <b>Context or Queue</b>)

and inside this funciton you'll get the <b>line </b>

as array (table)

all you need is to loop at that array and

during the loop concat all values

and then

result.addValue(yourfinallongstring);

Regards,

michal

Former Member
0 Kudos

Hi,

jus run a loop in the advanced user defined funciton with line node as input as node line and

String s="";

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

{

s=s + , + a(i);//define it in the form of an array

}

return s;

MichalKrawczyk
Active Contributor
0 Kudos

hi,

>>>return s;

will not work as it has to be an

advanced user function

(that returns: result object)

as he has to store the whole array

Regards,

michal

Former Member
0 Kudos

Hi Michal,

That works perfectly. I have given you full 10 points

Thanks Everyone,

Sandeep

MichalKrawczyk
Active Contributor
0 Kudos

great it works

Regards,

michal

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sandeep Joseph,

I got same problem. Now i am going to write udf for this ,

Please send me java code which you have for this problem.

this is urgent. i will wait for this

Thanks and regards

sai

nisarkhan_n
Active Contributor
0 Kudos

this should work

{

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

{

field<i>=field<i>+;

}

result.addValue(field<i>);

}

justin_santhanam
Active Contributor
0 Kudos

Sai,

Do u have the same requirement as line item 0..unbounded and concatenate them to the single target line..

raj.

Former Member
0 Kudos

Hi,

<line1> concatenate <some field>---

<line2>

<line3> -


Concatenate----Target.

Just concatenate the line1 and line2 and then put the result into a field and then concatenate line3 to the outputfield.

Regards

Vijaya

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

in this case you just need to create a user function

that will take all 3 values (inbound)

and contatenate them

return a + b + c;

Regards,

michal