cancel
Showing results for 
Search instead for 
Did you mean: 

Generating target nodes dynamically in message mapping

Former Member
0 Kudos

Hi XI GURUS

I am trying to generate target node using using more then source node. Is it possible to do this.

I need this as in source I have 2 different nodes (0 to unbounded) and in target I want to create corresponding number of target nodes. For e.g if I have 2 + 1 nodes in source then I want to create 3 nodes in target

Source as below

<FIRSTNAME>

<Raj>

<Kum>

</FIRSTNAME>

<FIRSTNAME>

<Naveen>

<Kumar>

</FIRSTNAME>

<CITY>

<bANGALORE>

</CITY>

Desired output in target as below

<ADDRESS>

<qwerty1>

<ADDRESS>

<ADDRESS>

<qwerty2>

<ADDRESS>

<ADDRESS>

<qwerty2>

<ADDRESS>

Can i follow an alternative approach (using java function) of counting the total number of occurences of source nodes and generating as many number of the target node

Thanx

Accepted Solutions (1)

Accepted Solutions (1)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

You can do a 1:1 mapping to create the target node as many time of the source node.

If you case assuming that the source node are A & B and the targe node as C you may duplicate the target node C in the message mapping(right click--> Duplicate Subtree) and map A & B to twice the occurance of C.

Thanks

SaNv...

Answers (2)

Answers (2)

Former Member
0 Kudos

HI

You can create the UDF

1. pass the input string to the queue

2. Loop to find the length

3. result.addValue(input)

This will create the number of nodes equal to the length of queue.

Thanks

Gaurav

Former Member
0 Kudos

Thanx Santhosh for a quick reply .

But it seems my problem is a bit more complex and I need to determine the number of output nodes using a java function .

I can not consider all nodes in the source to be mapped to target. I need to do a condition check on the source nodes before deciding the number of out put nodes.

Can some thing be done using SplitByValue function . I have used that earlier for creating output elements dynamically but not nodes

Thanx.

santhosh_kumarv
Active Contributor
0 Kudos

Make use of the Advanced UDF...

1. Pass the input to it as a queue.

2. Check the condition using IF.

3. For successfull value alone make a result.addValue(<input>).

This will do the job. Make use of the duplicatation and use the same UDF in other case also.

Thanks

SaNv...

SudhirT
Active Contributor
0 Kudos

Hi ,

If you want to use UDF do as suggested by santosh, you can write a code like

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

{

if( your condition)

result.addValue("");

}

Here source will be node from source structure and target will be node which you want to repeat according to source node.

Thanks!

Former Member
0 Kudos

If you have a condition check for each of the source node to be mapped to the target node,

use "create if" standard function and pass the boolean result of your Condition check as an input to this standard function. For each "true" a value would be added to the output queue. If you have a simple condition check on some source field value for each correspoding node, use "if without else" or depending on the complexity of the condition you may use a udf to get the boolean outcome.

And for mapping from more than on type of source node, you may duplicate subtree for target node.

Regards,

Suddha