on 07-28-2016 6:58 AM
Hi,
I have a problem about UDF. Using fixed length,4, to split the source string and write them into one table with many rows.
LIKE THIS:
Source
<record>
<details>
TESTSTRING
</details> |
</record>
Target
<result>
<name>1</name>
<data>1</data>
<status>1</status>
</result>
<result>
<name>2</name>
<data>2</data>
<status>2</status>
</result>
<result>
<name>3</name>
<data>3</data>
<status>3</status>
</result>
I create a UDF, for example, var1 is the length of the source string.
public void calculate2(int[] var1, ResultList title, ResultList name, ResultList result, ResultList status, Container container) throws StreamTransformationException{
int i = var1[0]+1;
for (int i2 = 1; i2 < i; i2++)
{
title.addValue(i2);
name.addValue(i2);
result.addValue(i2);
status.addValue(i2);
}
}
UDF:
Mapping:
Test result :
<result1> | |
<name>1</name> | |
<name>2</name> | |
<name>3</name> | |
<result>1</result> | |
<result>2</result> | |
<result>3</result> | |
<status>1</status> | |
<status>2</status> | |
<status>3</status> | |
</result1> | |
<result1/> | |
<result1/> |
Test Result
Do you have any good ideas?
Thanks a lot!
Regards,
Lily
Change your UDF by adding a context Change to the name , result and status node as shown in bold below.
int i = var1[0]+1;
for (int i2 = 1; i2 < i; i2++)
{
title.addValue(i2);
name.addValue(i2);
name.addContextChange();
result.addValue(i2);
result.addContextChange();
status.addValue(i2);
status.addContextChange();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.