commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [Digester] Passing attributes to child elements from parent element
Date Sun, 13 Apr 2003 20:47:48 GMT
i don't think that there is a standard rule (ie one that ships with 
digester) that provides this functionality directly. it would be possible 
to create custom rule implementations that would provide this 
functionality.

the way that i'd suggest that you go about it is to create a method that 
pushes the attribute value onto the main digester stack (push it when 
begin is called and pop it when end is called on the rule) and then use a 
CallParamRule that sets the parameter from the stack. i've added some code 
(which i think will help you) that allows any object on the stack to be 
used as a parameter (rather than just the top one) so you'll need to build 
from CVS HEAD or wait until the next nightly build to use this 
functionality.

- robert

On Sunday, April 13, 2003, at 06:33 AM, jakarta wrote:

> Is it possible to pass the parents attribute as a parameter to the method
> call of a child element?
>
> For example:
>
> <store name="XXX">
>     <catalog catalog-name="YYY"/>
> </store>
>
> Now every time I cross over the catalog element I want to call a method
> named
>      foo(storeName, catalogName)
>
> The storeName parameter is from the parent element's name attribute.
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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