on 03-01-2007 12:14 PM
Hello,
i have the following source structure:
<rec> (1:1)
<field1>aaa</field1> (1:1)
<field2>bbb</field2> (1:1)
<b><struc> <u>(1:unbounded)</u>
<name>myName</name>
<value>myValue</value>
</struc></b>
</rec>
Destination structure:
<rec> (1:1)
<field1>aaa</field1> (1:1)
<field2>bbb</field2> (1:1)
<b><field3>bbb</field2> (1:1)</b>
</rec>
In order to fill the destination field3 i have to loop over the input-structure struc.
My problem is, that i don't know how to get access to the name/value pair with a
extended user-defined function. Since each occurrence in struc i not a simple string but consists of 2 fields, i guess it is not enough simply to loop over input String Array.
Please help.
just like u have a loop stmt in java prgm. a simple code:
Here a and b are the strings that comes to the udf
for(int i=0;i<a.length;i++)
{
boolean found = false;
int j = 0;
for(j=0;j<b.length;j++)
{
if (a<i>.equals(b[j]))
{
found = true;
break;
}
}
if (found == true)
result.addValue(c[j]);
else
result.addValue("");
}
Message was edited by:
Prabhu S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so far.
Unfortunately i'm not a java expert... What i do not understand:
in your example 'a' is the input string array of the function. This input array has
<struc> as input according to my example. Thus for each iteration 'a' consists of the next occurence of the pair <name> and the <value>. But how to get access to them? How can i tell the function that 'a' is a another string array consisting of <name> as index 0 and <value> as index 1? Where do 'b' and 'c' come from in your example?
<b>struc</b> will be <b>a</b>. and looping into <b>struc</b> will fetch the value for the fields under <b>struc</b>
<b>Where do 'b' and 'c' come from in your example?</b>
it is just a piece of code what i had used earlier in my scenario...hence not customized to ur post
Message was edited by:
Prabhu S
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.