cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic nuber of fields during java map

Former Member
0 Kudos

my src structure

<appointment>

<empno> 1 </empno>

<empno>2 </empno>

</appointment>

empno is 0..unbounded.

how do we know how may times this empno element is coming in the source

I have a setempno method and getempno method inside appointment class.

private String[] empno = null;

public void setempno (String o){

empno<i> = o;

}

public String getempno (int i){

return empno<i>;

}

but as i initialized empno[] = null; it is taking null and could not retrive how many empno are coming.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Viswanath

Your requirement is to know how many times the Empno occurs is it ?

You can try using the standard count function in message mapping. This can give you the count of empno.

Thanks

Gaurav

Former Member
0 Kudos

Iam not using message mapping, iam using java mapping .

my src structure

<appointment>

<empno> 1 </empno>

<empno>2 </empno>

.

.

</appointment>

empno is 0..unbounded.

appointment is 0..unbounded

as I said Iam SAX parser, i have setter and getter methods, to set the values.

what shud be written to capture all the elements under appointment.

Former Member
0 Kudos

Hi

Try

String[] empno ={};
	
	public void setempno (String[] o){
			this.empno = o;
	}
	public String[] getempno (int i){
			return empno;
	}

Thanks

Gaurav

Answers (2)

Answers (2)

Former Member
0 Kudos
private String[] empno = null;
public void setempno (String o){
empno = o;
}

public String getempno (int i){
return empno;
}

you code is incorrect too. You are assigning String to String array.

Former Member
0 Kudos

can anybody share your thoughts on this please