on 09-11-2009 2:50 PM
Hi Experts,
I have a requirement, where I have to genrate the target node according to the number of values in a field in the source structure.
Eg:
Source:
</source>
<name>Reyaz</name>
<empno>2215</empno>
<mobno>9885313131,9836123123</mobno>
</source>
I want the out put as
<target>
<tagetnode>
<name>Reyaz</name>
<empno>2215</empno>
<mobno>9885313131</mobno>
</tagetnode>
<tagetnode>
<name>Reyaz</name>
<empno>2215</empno>
<mobno>9836123123</mobno>
</tagetnode>
</target>
Can some body tell , How I can achieve this.
Thanks&Regards,
Reyaz
Hi Reyaz,
Create a queue udf Addnode with one input argrument input and add this code:
Imports: java.*;
//write your code here
String werks = input[0];
StringTokenizer st = new StringTokenizer(werks,",");
while(st.hasMoreTokens())
{
result.addValue(st.nextToken());
}
Now map like this.
mobno --> Addnode(udf) --> targetnode
name --> copyvalue --> name
empno --> copyvalue -->empno
mobno --> Addnode (udf) --> splitbyvalue --> mobno.
I just tested with your test case. Its working and it is giving the output as you expected. Here test thorougly, I doubt on copy value, if you run into any issues then instead of copyvalue you may need to use useoneasmany function.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reyaz,
Your logic can be written by a udf where you need to break your targetnode based upon your mobno. Then for the rest of the fields name and empno, you can use oneusasmany or copyvalue and for mob no udf with split by value should work. Let me write a udf and give it to you.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try with UseOneAsMany function or create an UDF to solve this.
Regards,
Sarvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you going to get only two values (mobile numbers)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
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.