commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baltz, Kenneth" <Kba...@firstam.com>
Subject RE: Digester question
Date Thu, 13 Feb 2003 16:49:45 GMT
> 
> 
> Is it possible to handle duplicate elements in commons digester using 
> the following example ?

Yes.  Digester will fire whatever rules you assign to the given element as
many times as that element appears.

> 
> 
> <phonebook>
> 	<entry>
> 	 <owner>Owner</owner>
> 	 <number>Number</number>
> 	 [ and many other numbers to follow..]
> 	 </entry>
> </phonebook>
> 
> I can handle many <entry> elements but can't quite yet grasp 
> how to do 
> the multiple number elements. Does anyone have any idea how 
> to do this ?

It depends on what you want to do with these elements.  Originally I was
going to say that you handle <number> exactly the way you handle <entry>,
there's no difference.  Give us a description of what you would like to have
happen and we can tell you how to do it. 

I'm guessing that you have something like an Entry bean, with an owner
property and a numbers property that returns a collection.  If you have a
method addNumber() in your Entry bean, then just use a SetNextRule() to call
addNumber and pass the contents of each <number> to your Entry bean.

K.C.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message