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] Attribute Mapping
Date Tue, 25 Feb 2003 19:29:36 GMT
Assuming your bean property is set via setName(), I think you want to use:

digester.addSetProperties( "/Employee" );

If it were set via setFoo(), you use: 
digester.addSetProperties( "/Employee", new String [] { "Name" }, new String
[] { "foo" } );

Is the sample code you provided working?  I would expect it to fail because
Name_Key = "Name", not "name".  I'm not positive that my original piece of
code will work with an attribute named "Name".  I think it expects "name". 

Silly bean naming rules...

K.C.

> -----Original Message-----
> From: Venkatarman, Rajagopal
> [mailto:rajagopal_venkatarman@groton.pfizer.com]
> Sent: Tuesday, February 25, 2003 11:17 AM
> To: 'commons-user@jakarta.apache.org'
> Subject: [Digester] Attribute Mapping
> 
> 
> Im trying to use the Digester to map attribute key-value to a 
> bean property.
> This is the format of my XML
> 
> <Employee Name="Raj">
> 
> Now to parse this using digester, i had to split the 
> Attribute into key and
> value, like
> <Employee Name_Key="Name" Name_Value="Raj">
> And using digester code as
> 
> digester.addSetProperty("Root", "Name_Key", "Name_Value");
> which would assign the Attribute Name to "Raj" in my bean.
> 
> Is there an easier way to do this? Right now, i have to use a 
> stylesheet to
> convert my original XML into the Name-Value formatted XML and 
> pass through
> Digester.
> 
> TIA
> Raj
> 
> 
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is 
> confidential and may be privileged. It is intended for the 
> addressee(s) only. Access to this E-mail by anyone else is 
> unauthorized. If you are not an addressee, any disclosure or 
> copying of the contents of this E-mail or any action taken 
> (or not taken) in reliance on it is unauthorized and may be 
> unlawful. If you are not an addressee, please inform the 
> sender immediately.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

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