commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <>
Subject Re: Digester:
Date Thu, 09 May 2002 02:31:11 GMT
Being new to Digester, I hadn't really taken the xmlrules stuff into
account. After a quick look, I came away thinking that perhaps I'm
attacking the problem at the wrong point. The existing core rules will
work just fine as long as I can transform attribute names to match bean
properties. I admit I haven't worked much with XSLT, but isn't this
right up its alley? Perhaps the more general-purpose solution is to
apply a stylesheet and then have the digester parse the transformed
output. Any thoughts?

Simon Kitching wrote:
> Hi Kris/Craig,
> I've been following your emails with interest.
> As a user of digester, I also miss an easy way of mapping an
> arbitrarily-named
> xml atribute onto a setter method. This seems *such* a common
> requirement
> particularly as the xml convention for attribute names is xxx-yyy-xxx
> but the
> Java convention is xxxYyyZzz.
> Yes, the bean approach and the CallMethodRule approach handle it, but
> each needs
> more than one line of code :-)
> Kris' rule that uses a HashMap is interesting, but it doesn't seem quite
> right to
> me, and I can't see for the moment how it can be implemented in the
> xmlrules format.
> May I suggest this alternative API?
> Extend the SetProperties rule to take an optional hashmap that it scans
> before
> trying to use introspection, ie:
> in code:
>    HashMap x = new HashMap();
>    x.put("prop-name", "method-name");
>    digester.addSetProperties(pattern, hashMap);
> in xml format (ie using xml-rules):
>   <pattern value="some-pattern">
>     <create-object-rule class="foo"/>
>     <set-properties-rule>
>       <property-mapping attribute="some-attr" method="some-method"/>
>     </set-properties-rule>
>   </pattern>
> This shouldn't break any existing code or xmlrules..
> Hope this isn't too far off the beam..
> Cheers,
> Simon

Kris Schneider <>
D.O.Tech       <>
View raw message