on 03-03-2016 12:16 PM
Hello,
I want to traverse a XML tree(or read all the XML nodes/count) i have the code with me in regular java program format it uses recursion
public Static void main(String[] args)
{
ThirdParser(node);
}
ThirdParser(node)
{
visit(child)
}
visit(child)
{
if condtn
visit(child)
}
is it possible to write a class in a udf or a function and calling that function recursively.
PS: i know how to implement java mapping but want to explore if recursion is possible in udf or declaring a function inside a udf is possible.
Regards
Vinay
Hi Vinay
You can declare the recursive method under "Attributes and Method" section of MM as shown below.
You can then call the method from any UDF as shown below:-
As you can see, the recursive method is called five times as shown by the trace. You can ignore declaring and passing the container object in your method if you do not require any tracing, but it might be useful for debugging.
Caution: As it will be a recursive function, be careful to avoid an endless loop. You might want to code the function and test it locally in NWDS first prior to testing in the server.
Regards
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.