on 09-17-2008 7:22 AM
Hi,
i need to merge multiple "rows" into one single row and want to know if there is a possibility to do this with a graphical mapping.
To elaborate my problem, here is an example of what i need to do:
Origin XML structure looks like this:
<root>
<item>
<tag1>A</tag1>
<tag2>B</tag2>
</item>
<item>
<tag1>C</tag1>
<tag2>D</tag2>
</item>
...
</root>
and the target structure should be:
<root>
<text>ABCD...</text>
</root>
To get one item into this "simple" structure is no problem. But how do i build something like a "for each item do".
I sure could build a java mapping, but i want to know if this problem can be solved using XIs grapfical mapping.
I really would appreciate any help.
Regards,
Benjamin
Hi ,
I think you can write one udf which will contain a loop for the no. of occurence of items and the inputs will be tag1 and tag2 value of each occurence and keep on appending the tag1 and tag2 values.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i went through all the linked blogs, but i still dont get it.
I made a screenshot of my Message Mapping:
[n:1 problem|http://img222.imageshack.us/img222/2838/1tonlf4.jpg]
Pay attention to the red marked occurrences. Can someone please explaine me, how exactly my mapping has to look, so that multiple "row"s get merged into one single "text".
If there is no way to do that with the graphical mapping i am also fine with that. Then i write a java mapping. But if it is possible i would prefer the graphical way.
Thanks alot in advance.
Hi Benjamin,
I think you could do something like that.
Remove all the change contexts in Char1 and Char2 nodes. The result should be two queues. One of them belongs to Char1 node and the other one belongs to Char2 node. Both of them must be with change contexts.
Fed an advanced user defined function with Char1 and Char2.
The code must be something lik.
String Resulttext,Resulttext2
(for int i=0; i < Char1.length; i++)
{
Resulttext = Concat (Char1[0], Char2[0]);
Resultext2= Concat (Resultext2, Resulttext);
}
result.addValue (Resulttext2)
Hope this help you,
Carlos
Hi,
It is possible in graphics mapping through UDF function. according to ur requirement develop one simple UDF and put logic for concatenate all source string into one and transfer to receiver, it will sort out easily.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
as both are form different contexts i think you have to use removecontext
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Benjamin
You can get this by using Concate function.
use logic like text = (ABC+D)
which can be achived by (((AB)C)+D)
Hope u got it.
Regards
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, first of all, thank you all for your quick responses.
But unfortunately nothing really solved my problem.
Of course i can use the function Concatenate to get the tags of ONE item into the desired output format, but how can i execute this concatenation multiple times (as often as item appears in the origin xml).
<root>
<item>
<tag1>A</tag1>
<tag2>B</tag2>
</item>
<item>
<tag1>C</tag1>
<tag2>D</tag2>
</item>
...
</root>
With a mapping like this:
{tag1} --- {concatenate} --- {text}
{tag2} ---´
i can get an output like this:
<root>
<text>AB</text>
</root>
But it does not concatenate all and tags of all items.
The first blog posted by Chetan is unfortunately exactly the wrong way: 1:n
But what i need is a n:1 mapping.
And if i am not wrong the function useOneAsMany is also for a 1:n mapping.
If i can solve my n:1 problem with that function too, i would appreciate a detailed explanation of how this works.
Yes , you can do this by function Concatenate avaialble in Graphical mapping.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.