UDF and Standard Function
Posted on Apr. 27, 2010 at 06.22 PM - Kuala Lumpur, Malaysia
Some time, we need to replicate certain element in the source XML to the target XML. There are several techniques available:
1. UDF and Standard Function
Create a simple UDF to copy certain element based on the existence of other element
for (int i=0; i<var1.length; i++) {
result.addValue(var2[0]);
}
And then use standard function SplitByValue to add context change.
2. UDF Only
Create a UDF to copy certain element based on the existence of other element, and add context change
int var2_counter = 0;
for (int i=0; i<var1.length; i++) {
if (var1[i] == ResultList.CC) {
var2_counter = var2_counter + 2;
}
else {
result.addValue(var2[var2_counter]);
if (i<var1.length - 1)
result.addContextChange();
}
}
Use standard function useOneAsMany
Life is beautiful! Let's make it meaningful and colorful!