commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [Digester] "dynamic" attributes
Date Mon, 22 Mar 2004 01:35:52 GMT
Better late than never ...

Quoting Barnabas Davoti <barna@empolis.no>:

> Hi,
> 
> I'd like to process a configuration file with Digester. The element structure
> is 
> given (predefined), but the attributes are not. It means the user can
> introduce 
> new attribute names.
> I was not able to implement this feature with Digester. Since it stores the 
> attribute values as bean propery values, I should know all the attribute
> names 
> in advance to configure the bean (I use DynaBeans). It's not quite possible 
> since these custom attribute names will be discovered only during the parsing
> 
> time. The XML instance is well-formed, but obviously not validated.
> 
> Is this a limitation of Digester? Any possible workaround?
> 
> Thanks for your help!
> 
> Barna
> 

In addition to the FactoryCreateRule suggestion (which is a good one), you
should also note that the standard SetPropertiesRule will match up attributes
to properties without knowing any of that ahead of time ... the only constraint
is that the name of the attribute has to correspond to the name of the
property.  The ways that Struts and Tomcat use [digester] to parse
configuration files, for example, benefits tremendously from this feature,
because you don't have to add any new digester rules for custom subclasses that
have additional properties.

Craig McClanahan


> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message