cancel
Showing results for 
Search instead for 
Did you mean: 

how to create target node a constant number of times

Former Member
0 Kudos

hi! can anyone tell me how to generate an element in a target XML messages a constant number of times. similar kind of idea as useoneasmany() but with a fixed value for the number of 'many' instead of a node in the source message. any ideas appreciated and points awarded. thx, duncan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Praveen... thanks for the reply. I am using a standard schema which sets the note properties as min 1 and max 2. I don't want to modify the schema as that means I am changing a standard that is used by multiple trading partners on their system. I just need to force for one use case that the the node is genarated the maximum of two times. any other ideas? thx, duncan

Former Member
0 Kudos

Create a simple user defined function which doesnt take any input but gives an array with elements equal to the required no of nodes. And assign this output in combination with splitByValues and/or collpseContexts depending on your need regarding the context change.

for(int i=0; i<maxoccurs; i++)

result.addValue("");

Former Member
0 Kudos

Smitha, KNS Kumar, Praveen

Three great answers. All solved the problem. Many many thanks. Points awarded.

Cheers

Duncan

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can do this by writing a user defined function.

source node -> function -> <target node>

<target node>

In the function, declare a ResultList. Add the number of nodes you want to the ResultList.

Regards,

Smitha.

Former Member
0 Kudos

Hi,

You can do this as suggested by Smitha Rao, i.e.

sourcenode--\

|>functionCreate>Targetnode

Constant----/

code for functionCretae

public void functionCreate(String[] source,String[] constantStr, ResultList result,Container container){

int constant = Integer.parseInt(constantStr[0]);

for(int i=0;i<constant;i++)

result.addValue(source[0]);

}

Regards,

KNS Kumar.

Former Member
0 Kudos

If you want the node to be created fixed number of times and if you know it design time...you can set that in data type...minoccurs = maxoccurs = <fixd_no>.

If it is known only at the runtime, you can use the determining source node or use the node funtion collapseContext. You need to give an array with required number of nodes as input to collapse context.