Hi Dimitri, Adding custom rules using the xml-rules module is quite awkward. That's one of the reasons I dislike xml-rules. I recommend you avoid it, and write your rules using java.
http://wiki.apache.org/jakarta-commons/Digester/FAQ/XmlRulesOrNotXmlRules Regards, Simon On Fri, 2005-12-30 at 23:49 +0100, Dimitri Frederickx wrote: > Thanks a lot, I'll try to make my own rule. To add a rule, do I always have > to do that in java the way you described it, or can I also add the rule by > configuring it in the xml-file? Normally I always describe my rules in xml, > and this way a can keep all the rules at one place. Can I do that or does it > has to be in java? > > Regards, > Dimitri > > > -----Original Message----- > From: Simon Kitching [mailto:[EMAIL PROTECTED] > Sent: vrijdag 30 december 2005 23:40 > To: Jakarta Commons Users List > Subject: Re: [Digester] How to map html-td elements to methods? > > On Fri, 2005-12-30 at 14:41 +0100, Dimitri Frederickx wrote: > > > <td class="command">open</td> > > <td class="target">./tests/html/test_open.html</td> > > > > > > I want that the value of the class-attribute maps to the property (and > > method name), and the value of the tag must be the value to pass to this > > method. > > > > Is there a way to do this with digester? Does anyone has done something > like > > this? It would help me a lot, because I'm really stuck at this moment. > > I don't believe there is an existing rule that does exactly what you > want, but you should be able to create your own rule to achieve your > goal. I would suggest starting with BeanPropertySetterRule, then > modifying the begin method so that it saves away the target property > name in a member variable for later use. Using member variables like > that isn't actually a good idea in general (doesn't work when rules are > nested) but in this case it's fine as this rule won't be nested. > > Don't be concerned about creating your own rule; that's not unusual, nor > particularly difficult. > > Once you've got your custom rule class, just add it do digester like: > digester.addRule("tbody/tr/td", new MyNewRule()); > > Regards, > > Simon > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
