on 08-11-2009 11:34 AM
The source input XML is like:
<bookstore>
<book>
<item1>xxx</item1>
<item2>yyy</item2>
</book>
<book>
<item1>zzz</item1>
<item2>www</item2>
</book>
........
</bookstore>
I want to create an output XML like
<output>
<item>
<item1>xxx</item1>
<item2>yyy</item2>
</item>
<item>
<item1>xxx</item1>
<item2>www</item2>
</item>
<item>
<item1>zzz</item1>
<item2>www</item2>
</item>
<item>
<item1>xxx</item1>
<item2>yyy</item2>
</item>
.....
</output>
That means I want to do permutation and combination for all <item1> <item2> under <book>.
Of course I can write a customer function to do it, but I want to basically use the buildin functions to do the graphical message mapping for this.
Any idea? thank you.
Which do you want to do Permutation or Combination?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well, I'm not very clear of those 2 English words
What I want is to list all possible combination of item1 and item2 (and in fact, we have item3, item4, ....etc).
example
input:
<item>
<item1> 111 </item1>
<item2> 222 </item2>
<item3> 333 </item3>
</item>
<item>
<item1> aaa </item1>
<item2> bbb </item2>
<item3> ccc </item3>
</item>
I want to get
<item><Item1>111>/item1> <item2>222</item2> <item3>333</item3> </item>
<item><Item1>111>/item1> <item2>222</item2> <item3>ccc</item3> </item>
<item><Item1>111>/item1> <item2>bbb</item2> <item3>333</item3> </item>
<item><Item1>111>/item1> <item2>bbb</item2> <item3>ccc</item3> </item>
<item><Item1>aaa>/item1> <item2>222</item2> <item3>333</item3> </item>
<item><Item1>aaa>/item1> <item2>222</item2> <item3>ccc</item3> </item>
<item><Item1>aaa>/item1> <item2>bbb</item2> <item3>333</item3> </item>
<item><Item1>aaa>/item1> <item2>bbb</item2> <item3>ccc</item3> </item>
Can you explain it more clearly you requeriment ?
Because on your 3st target the Item1 is ZZZ and the and the 4th is XXX I guess maybe has a specific rule.
In other case if value is "XXX" you need to write an UDF function to replicate the value ,however your target Item is generated in based your mapping or is a static structure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oh, sorry, I did a typo.
the 4th <item1> should be "zzz".
What I expect is:
<output>
<item>
<item1>xxx</item1>
<item2>yyy</item2>
</item>
<item>
<item1>xxx</item1>
<item2>www</item2>
</item>
<item>
<item1>zzz</item1>
<item2>www</item2>
</item>
<item>
<item1>zzz</item1>
<item2>yyy</item2>
</item>
.....
</output>
I tried useOneAsmany, but it did not work out my request.
Hi
You can try to use this code
//write your code here
int rep = Integer.parseInt(repeat[0]);
for(int i = 0 ; i < list.length;i++){
for (int j = 0 ; j < rep;j++) {
result.addValue(list<i>);
}
}
the parameters repeat is the value how many time you need to repeat the value. for this case (2)
for you root node use this Source>> UDF >>RemoveContext>>Target
for you field use this Source>> UDF >>SplitByValue>>Target
Hi WuDao,
This is not possible without using UDF because you would need to combine the contexts i.e item a has two, item b has two..so the output should have four contexts (item a1, item a1, item a2, item a2) for item1
hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try to use UseOneAsMany or FormatByExample standard node functions, to achive this with out using UDF. All the best
Regards,
Prasanna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.