on 02-03-2007 4:32 PM
Hi experts,
I implemented the lookups according to the blog from Alessandro. I am using the makeArray function to build the fields array for the RT call.
In my scenario the mapping is for an order XML with several items and I have to do the lookup for each item...
<order>
...
<item>
<unused_field></unused_field>
...
</item>
<item>
<unused_field></unused_field>
...
</item>
</order>
I am triggering the lookup on an unused field.
Everything works fine for the first item, but for the second one, the function makeArray is not called???
I removed the lookup function and only kept the makeArray with a concatArray function to isolate the issue.
public void makeArray(String[] el1,String[] el2,ResultList result,Container container){
for (int j=0;j<el1.length;j++) {
result.addValue(el1[j]);
}
result.addValue(el2[0]);
}
//Concanates the values in the parameter a and add to the result
public void concatArray(String[] a,ResultList result,Container container){
String res = "";
for (int j=0;j<a.length;j++) {
res = res + a[j];
}
result.addValue(res);
}
The mapping is the following:
[Constant1] --->
[Constant2] ---> makeArray() --->
[Constant3] ---> makeArray() ---> concatArray() ---> dest_field
The input sample XML is:
<src_order>
<src_item> <!first item -->
<src_field></src_field>
</src_item>
<src_item> <!second item -->
<src_field></src_field>
</src_item>
</src_order>
The result is the following:
<dest_order>
<dest_item>
<dest_field>Constant1Contant2Constant3</dest_field>
</dest_item>
<dest_item></dest_item>
</dest_order>
The second
dest_item
element is empty and does not contain the expecteddest_field
elt !!!I have no idea why the array construction is called for the first item and is not for the next iteration
I would really appreciate your help!
Thanks
Adalbert
Hi,
provide the context for the root level and check the output.
Also debug based on the Queue context in the graphical editor.
hope you have used adavanced user defined function. also try to use Queue context in the user defined function
rgds,
moorthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Krishna for your response.
I checked the Queues in the Graphic Editor. It seems there is no issues there.
The queue for dest_field elt is the following:
/dest_order/dest_item/dest_field
SUPPRESS
[Contant1Constant2Constant3]
[Contant1Constant2Constant3]
Isnt it missing one final element is this queue?
The mapping for the dest_item is:
src_item ---> dest_item
and the queue:
/dest_order/dest_item
SUPPRESS
[]
[]
[]
The execution trace of the test mapping is:
23:35:48 Start of test
Compilation of MM_Test_MakeArray successful
Document start
Start tag [dest_order]
Start tag [dest_item]
Start tag [dest_field]
Put value [Constant1Constant2Constant3]
Close tag [dest_field]
Close tag [dest_item]
Start tag [dest_item]
Close tag [dest_item]
Close tag [dest_order]
Document end
Executed successfully
23:35:50 End of test
One put value is missing for the dest_item element???
What do you mean by providing the context for the root level?
I also do not understand why using UDF with Queue context as the Context should be adapted for my use. I want my function to be called at each iteration without need to access values from hierarchically higher elements.
Thanks for your help
Sandro,
There is no cardinality on this element as I built the mapping from sample XMLs and not from XSDs. As default the mapping assumes that it is a 0..unbounded elt.
But the issue is not there as where I am mapping a simple constant on this field, everything works fine and the element dest_item is replicated with for each a single dest_item elt...
Adalbert
Hi,
Context type UDFs will be called for each context the input to that function has.
So you can try something like this.
Add <src_field> elt also as one more input to both ur UDFs(as third input, so that u dont need to modify ur code).
Check the UDF if they are in Context type(Just for confirmation).
So now for each context of <src_field> your UDFs will execute and u might possibly get the required output.
Regards,
P.Venkat
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.