on 2006 Oct 20 7:44 AM
Hi All,
My source structure is
<root>
<a></a>
<type>
<val1>
</val1>
</type>
<type1>
<val2>
</val2>
</type1>
</root>
Here the cardinality goes like this
<a> 1..1
<type> 1..unbounded
<val1> 1..1
<type1> 1..unbounded
<val2> 1..1
Target structure
<test>
<action>insert</action>
<table>table1</table>
<access>
<tval></tval>
</access>
</test>
Here my requirement is if <b>a</b>'s value is "const" I need to have <b><access></b> node in my target as many times as <b><type></b> and <b><tval></b> must be mapped with <b><val1></b>. If <b>a</b>'s value is "const1" I need to have b]<access></b> node in my target as many times as <b><type1></b> and <b><tval></b> must be mapped with <b><val2></b>. Can this be achieved in graphical mapping???
Thanks & Regards,
Jai Shankar.
Hi,
You will have.
a) <access> element
here you can use user defined function with two inputs we can call this function ifExtended. It will have three inputs. A is condition, B is queue no 1, C is queue no 2.
if(A.equals("true"){
for(int i=0;i<B.length;i++)
resultList.addValue(B<i>);
else{
for(int i=0;i<C.length;i++)
resultList.addValue(C<i>);
}
And now you are connecting your condition to condition input. And <type> to second input (without change of context) and <type1> to third.
Please check this function because I wrote it ad hoc.
b) <tval> element
here also use this function
Regards,
Wojtek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wojtek,
>>><i>here you can use user defined function with two inputs we can call this function ifExtended. It will have three inputs. A is condition, B is queue no 1, C is queue no 2.</i>
Can you pls expalin this part? How to create this UDF? What is the cache for this UDF(value or context or queue)? How can a UDF have 2 input queues
Thanks & Regards,
Jai Shankar.
from the above code i gather, you need to make a UDF with 3 inputs (in a UDF you can add any number of inputs) with the cache as <b>context</b>.
Just noticed;
<b>resultList.addValue(B);</b> in case it was B<i> etc it would be context but now it is queue ... My mistake
Message was edited by: Shabarish Vijayakumar
Dear Wojtek,
Am on XI/PI7.0 SP08. I have not worked on UDF with cache as context or queues, hence the problem...
I can create a UDF with 3 inputs and cache as context..
The 2nd input of ifExtended is <type> and 3rd input of ifExtended is <type1>.
Pls let me know the first input? Is it [b}if(<a>equals"const")</b>
Thanks a lot,
Jai Shankar..
Wojtek,
When I pass false as 1st arguement I am getting <access> node as many times as <type1>. This part is correct.
but I can get only one <access> node in my target. I am passing 3 inputs to the UDF when I pass "true" as first arguement. This part is not what I expected.
What I expected was <access> should be produced as many times as <type> if the first arguement is "true"...
Thanks & Regards,
Jai Shankar.
Wojtek,
<b>if(a.equals("true"))
{
for(int i=0;i<b.length;i++)
result.addValue(b<i>);
}
else {
for(int i=0;i<c.length;i++)
result.addValue(c<i>);
}</b>
I think even if I pass true as input the control passes to else part in the JAVA code.... What might be the reason here????
Thanks & Regards,
Jai Shankar.
Wojtek,
Yes, now the if condition evaluates as expected. One last help to ebd this issue...
HOw do I need to map <tval> is it like this?
ifExtended inputs
1. true or false based on <a>
2. <val1>
3. <val2>
But if I map like this, I am getting array index out of bound exception...
Thanks & Regards,
Jai Shankar.
Hi,
If you are using the same function there shouldn't be any problems. You can also add some additional checks.
<b>if(a!=null){</b>
if(a.equals("true"))
{
for(int i=0;<b>(b!=null)&&</b>i<(b.length);i++)
result.addValue(b);
}
else {
for(int i=0;<b>(c!=null)&&</b>(i<c.length);i++)
result.addValue(c);
}
<b>}</b>
Regards,
Wojtek
Hi Wojtek & Shabz,
Yes you did it man...... The problex was with context change. <val1> and <val2> had context changes I used a remove contexts here before passing as input to UDF and then output I used Split by value and mapped to <tval>...
Now it is working perfectly the way I wanted....
Thanks a lot frnz.....
(P.S: Now I can have a joyful DIWALI - a festival of lights)
Wish you all SDNers a happy DIWALI
Thanks & Regards,
Jai Shankar.
use the same UDF as for the other field; except that replace it with <type1> & <val2> fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think this will do. I can't test it here bcoz i am not haveing any server
if(a="const")---> map tval to tval1, map type to access
else ---> map to tval to tval2, map type1 to access
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.