commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gogineni, Pratima" <pgogin...@selectica.com>
Subject RE: [digester] include in xmlrules
Date Tue, 22 Feb 2005 22:55:24 GMT

Sorry for the delayed response (long weekend).

I have retested this and I do find that addRule("f",rule) does NOT work for
me. Im looking at the code and yes I see a ruleprefixadaptor and I cant find
anything wrong with the code so not sure why its not prepending "/" - Ill
check this in a debugger later today.

Thanks 
Pratima
-----Original Message-----
From: Simon Kitching [mailto:skitching@apache.org]
Sent: Wednesday, February 16, 2005 9:58 PM
To: Jakarta Commons Users List
Subject: RE: [digester] include in xmlrules


On Wed, 2005-02-16 at 11:54 -0800, Gogineni, Pratima wrote:
> On examining the stack I think I found the problem:
> 
> In my rule creator:  digester.addRule("f", rule); should actually be
> digester.addRule("/f", rule);
> 
> i.e. I need to have the path separator as well.
> 
> Which means the Example given in the JavaDoc also needs to be corrected

Could you please confirm this? It sure looks to me like the javadoc
correctly reflects what the code is doing.

DigesterRuleParser has a nested class RulesPrefixAdapter, which is the
object that the custom addRules method actually adds its rules to. This
class overrides the Rules.add method to transparently prepend the
current match prefix when rules are added. And this method does:

        public void add(String pattern, Rule rule) {
            StringBuffer buffer = new StringBuffer();
            buffer.append(prefix);
            if (!pattern.startsWith("/")) {
                buffer.append('/'); 
            }
            buffer.append(pattern);
            delegate.add(buffer.toString(), rule);
        }

So in your example, it looks to me like the rule is added with a pattern
of
  a/b/c/d/e/f
regardless of whether you call
   digester.addRule("f", ...);
or
   digester.addRule("/f", ...);

Regards,

Simon



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