cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for count no of elements under parent element.

Former Member
0 Kudos

Hi

I want to caliculate no of elements present under the parent element using UDF.

Example

<Employee>

-


</Name>

-


</No>

-


</Address>

-


</City>

So it has 4 elements undre Main tag Emoloyee.

How to caliculate the no of elements under parent element using UDF.

I want to use this for error handling. Whenever the message in coming in I want to caliculate the no of fields if i get the no of fields is lessthank 4 i want to throw an error.

And could any one please provide the JAVA API for mapping

Thanks & Regards

Sowmya.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Create the UDF of type Queue and give Employee as input

if(employee.length() < 4)

{

throw .......... exception.

}

This link may be useful to you

http://java.sun.com/j2se/1.4.2/docs/api/java/util/package-summary.html

Former Member
0 Kudos

Hi Venkataramesh B...

It didnt work.. Its returning 1.

Regards

Sowmya

Former Member
0 Kudos

Hello,

u can check "exists" node function for all the four elements. If anyone of that is absent throw the error.

regards

rajeev

Former Member
0 Kudos

use java UDF... pass the four values in to the UDF and check

simple if for length with a counter shd work...

if (name.length>0 && No.lenght>0 &&....)

counter==4;

else

counter==0;