commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [Digester] parameter value from a parent node attribute
Date Fri, 21 Apr 2006 15:38:17 GMT
On 4/21/06, Rahul Akolkar <rahul.akolkar@gmail.com> wrote:
> On 4/21/06, Valerio Schiavoni <valerio.schiavoni@gmail.com> wrote:
> > Hello,
> > i have the following xml:
> > <root>
> > <element id="A">
> >   <subelement id="B"/>
> > </element>
> > </root>
> >
> > whenever I match path element/subelement, i need to invoke a 2-parameters
> > method  defined on the object on the stack
> > ,call it twoParamMethod(String idElement,String idSubElement).
> >
> > i was able to code up to this code:
> >
> > digester.addCallMethod("root/element/subelement", "twoParamMethod", 2);
> > //HOW DO I GET THE VALUE FOR THE FIRST PARAMETER ?
> <snip/>
>
> Personally, I wouldn't use CallMethodRule here, but I rarely use it
> anywhere. In this case, some options:
>
>  * Add a SetNextRule where you have access to both the "element" and
> "subelement", and therefore, all params to call the method
>
<snip/>

... or a SetTopRule.

>  * Add a custom rule that peeks one down the stack to find the
> "element" (custom rules are not hard, ofcourse if you can do what you
> need with "provided" rules, thats better most of the times)
>
> -Rahul
>
<snap/>

---------------------------------------------------------------------
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