On Wed, 2004-04-21 at 02:30, Aristos Stavrou wrote:
> Could you please help me on the following problem?
> 
> 
> If I have an xml file containing the following element:
> ...
>     <author name="....">
>         <address> ... </address>
>     </author>
> ....
> 
> and I have the following class defined for author element:
> 
> public class Author{
>   private string name;
>   private string address;
> 
>   public setName(name){
>    name=this.name;
>   }
>   public getName(){
>    return this.name;
>   }
>   public setAddress(addr){
>    this.address=addr;
>   }
>   public getAddress(){
>    return this.address;
>   }
> 
> }
> 
> how do I say digester parser to set the "name" property of the stack top
> object equal to the value of the "name" attribute of the author element.
> I have tried:
> addSetProperty(*/author, "name", "name");
> but it doesn?t work. Is this the right rule?

No, it's not the right rule to use for this.

You can use the SetPropertiesRule, which tries to map all xml attributes
to matching set methods on the top object:
  digester.addSetProperties("*/author");

Or you can use the CallMethodRule:
  digester.addCallMethod("*/author", "setName", 1);
  digester.addCallParam("*/author", 0, "name");

Regards,

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to