cancel
Showing results for 
Search instead for 
Did you mean: 

About mapping function

xinjiang_li
Active Participant
0 Kudos

Hi,gurus:

My source XML payload is like below:

<recordset>

<content>

<line>1111</line>

</content>

<content>

<line>2222</line>

</content>

<content>

<line>1111</line>

</content>

</recordset>

we want to get the result like below:

<record>

<test>

111122221111

</test>

</record>

Which function should I choose to use?Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Choose the concat function from the Text functions to concatenate the <line> fields and set the context of <line> to <recordset> in stead of <content>

former_member200962
Active Contributor
0 Kudos

will concat function work here?

Concat requires two inputs and since the content node is repeating you cant predict for how many times the concat should be called....need to go for a UDF in this case....

Former Member
0 Kudos

You are right, however if the lines number is fixed (as i though at the beginning) and equals n you can use n-1 concat functions with correctly set context. Obviously the UDF solution is more efficient.

Regards,

Radek

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Using node function Remove Context and text concat should solve your case.

Regards,

Radek

Shabarish_Nair
Active Contributor
0 Kudos

>

> Hi,gurus:

>

> My source XML payload is like below:

> <recordset>

> <content>

> <line>1111</line>

> </content>

> <content>

> <line>2222</line>

> </content>

> <content>

> <line>1111</line>

> </content>

> </recordset>

>

> we want to get the result like below:

> <record>

> <test>

> 111122221111

> </test>

> </record>

>

>

> Which function should I choose to use?Thanks in advance.

use a UDF

String output = "";
for(int i=0;i<a.length;i++)
{
output = output + a<i>.toString();
}

result.addValue(output);

xinjiang_li
Active Participant
0 Kudos

Hi,

The problem was solved by using UDF and changing the context to <recordset>.

Thanks all.