on 09-14-2007 6:38 AM
Hi All,
I encountered one question in the mapping. The following is my source message:
<MsgIn>
<SID>1</SID>
<SID>2</SID>
<Goods>
<Name>G1</Name>
<Price>10</Price>
</Goods>
<Goods>
<Name>G2</Name>
<Price>20</Price>
</Goods>
</MsgIn>
I wanted to get the following result by message mapping:
<MsgOut>
<Out>
<SID>1</SID>
<Goods>
<Name>G1</Name>
<Price>10</Price>
</Goods>
<Goods>
<Name>G2</Name>
<Price>20</Price>
</Goods>
</Out>
<Out>
<SID>2</SID>
<Goods>
<Name>G1</Name>
<Price>10</Price>
</Goods>
<Goods>
<Name>G2</Name>
<Price>20</Price>
</Goods>
</Out>
</MsgOut>
Did anyone encounter the same question?
Hi Chris,
I guess your mapping needs UDFs.i tried without UDFs but could not find any solution,so finallay i came up with 2 UDFs.
1. when you are mapping <b>Goods</b> in Source with <b>Goods</b> in target use the following <b>Context</b> UDF code
//write your code here
for(int k = 0;k < b.length;k++)
{
for(int j=0;j<a.length;j++)
result.addValue("");
if(k != (b.length-1))
result.addValue(ResultList.CC);
}
This UDF takes 2 inputs <b>a</b> and <b>b</b>.
<b>a</b>: Goods node from Source
<b>b</b>: SID element from Source
2. when you are mapping <b>Name</b> field in Source with <b>Name</b> field in Target use the following - <b>Context</b> UDF
//write your code here
for(int k = 0;k<b.length;k++)
{
for(int j = 0;j<a.length; j++)
result.addValue(a[j]);
}
This UDF takes 2 inputs <b>a</b> and <b>b</b>.
<b>a</b>: Name node from Source,but change context to <b>MsdIn</b>
<b>b</b>: SID element from Source
<b>Note:</b> The output of this UDF send to <b>SplitByValue</b>[Each Value] and output of this send to <b>Name</b> field in target
3. Use same UDF and logic as <b>Name</b> field for <b>Price</b> field mapping
please let me know if you have any issues regarding this.
Thanks,
Jag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jag,
Your UDF work fine. That's great. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SID / Goods- > Out ( target)> this specifies the no of times SID/Goods occur in source those many times u want Out node to occur in the target.. give a thought for context as well
map SID -> SplitByValue--> SID ( this is to put each occurrence of SID into different parent Out
Map Goods as like SID
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
your target message occurance should be unbounded.
mapping your source field (SID) to target message.
Thanks
Anu SInghal
<b>Reward point if useful to u in nyway!!</b>
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 |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.